logo

Expression of type ExprTuple

from the theory of proveit.linear_algebra.addition

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import Conditional, ExprTuple, K, Lambda, V, a, b
from proveit.linear_algebra import InnerProd, Norm, VecAdd, VecSpaces
from proveit.logic import Equals, Forall, InClass
from proveit.numbers import Add, Exp, sqrt, two, zero
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(V, Conditional(Forall(instance_param_or_params = [a, b], instance_expr = Equals(Norm(VecAdd(a, b)), sqrt(Add(Exp(Norm(a), two), Exp(Norm(b), two)))), domain = V, condition = Equals(InnerProd(a, b), zero)), InClass(V, VecSpaces(K)))))
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left(V \mapsto \left\{\forall_{a, b \in V~|~\left \langle a, b\right \rangle = 0}~\left(\left \|a + b\right \| = \sqrt{\left(\left \|a\right \|^{2} + \left \|b\right \|^{2}\right)}\right) \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 36
body: 3
2ExprTuple36
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple36, 11
10Lambdaparameters: 45
body: 12
11Operationoperator: 13
operand: 17
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple17
15Operationoperator: 31
operands: 18
16Operationoperator: 19
operands: 20
17Variable
18ExprTuple21, 22
19Literal
20ExprTuple23, 24, 25
21Operationoperator: 56
operand: 33
22Operationoperator: 50
operands: 27
23Operationoperator: 29
operands: 28
24Operationoperator: 29
operands: 30
25Operationoperator: 31
operands: 32
26ExprTuple33
27ExprTuple34, 35
28ExprTuple58, 36
29Literal
30ExprTuple59, 36
31Literal
32ExprTuple37, 38
33Operationoperator: 39
operands: 45
34Operationoperator: 40
operands: 41
35Operationoperator: 42
operands: 43
36Variable
37Operationoperator: 44
operands: 45
38Literal
39Literal
40Literal
41ExprTuple46, 47
42Literal
43ExprTuple48, 54
44Literal
45ExprTuple58, 59
46Operationoperator: 50
operands: 49
47Operationoperator: 50
operands: 51
48Literal
49ExprTuple52, 54
50Literal
51ExprTuple53, 54
52Operationoperator: 56
operand: 58
53Operationoperator: 56
operand: 59
54Literal
55ExprTuple58
56Literal
57ExprTuple59
58Variable
59Variable