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, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.linear_algebra import VecAdd, VecSpaces
from proveit.logic import Equals, Forall, InClass
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(V, Conditional(Forall(instance_param_or_params = [i, j, k], instance_expr = Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Equals(VecAdd(a_1_to_i, b_1_to_j, c_1_to_k), VecAdd(a_1_to_i, VecAdd(b_1_to_j), c_1_to_k)).with_wrapping_at(2), domain = V), domain = Natural), 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_{i, j, k \in \mathbb{N}}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k} \in V}~\left(\begin{array}{c} \begin{array}{l} \left(a_{1} +  a_{2} +  \ldots +  a_{i}+ b_{1} +  b_{2} +  \ldots +  b_{j}+ c_{1} +  c_{2} +  \ldots +  c_{k}\right) =  \\ \left(a_{1} +  a_{2} +  \ldots +  a_{i} + \left(b_{1} +  b_{2} +  \ldots +  b_{j}\right)+ c_{1} +  c_{2} +  \ldots +  c_{k}\right) \end{array} \end{array}\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: 65
body: 3
2ExprTuple65
3Conditionalvalue: 4
condition: 5
4Operationoperator: 18
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple65, 10
9Lambdaparameters: 11
body: 12
10Operationoperator: 13
operand: 17
11ExprTuple53, 68, 57
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple17
15Operationoperator: 18
operand: 21
16Operationoperator: 34
operands: 20
17Variable
18Literal
19ExprTuple21
20ExprTuple22, 23, 24
21Lambdaparameters: 41
body: 25
22Operationoperator: 60
operands: 26
23Operationoperator: 60
operands: 27
24Operationoperator: 60
operands: 28
25Conditionalvalue: 29
condition: 30
26ExprTuple53, 31
27ExprTuple68, 31
28ExprTuple57, 31
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operands: 35
31Literal
32Literal
33ExprTuple36, 37
34Literal
35ExprTuple38, 39, 40
36Operationoperator: 54
operands: 41
37Operationoperator: 54
operands: 42
38ExprRangelambda_map: 43
start_index: 67
end_index: 53
39ExprRangelambda_map: 44
start_index: 67
end_index: 68
40ExprRangelambda_map: 45
start_index: 67
end_index: 57
41ExprTuple46, 62, 48
42ExprTuple46, 47, 48
43Lambdaparameter: 74
body: 49
44Lambdaparameter: 74
body: 50
45Lambdaparameter: 74
body: 51
46ExprRangelambda_map: 52
start_index: 67
end_index: 53
47Operationoperator: 54
operands: 55
48ExprRangelambda_map: 56
start_index: 67
end_index: 57
49Operationoperator: 60
operands: 58
50Operationoperator: 60
operands: 59
51Operationoperator: 60
operands: 61
52Lambdaparameter: 74
body: 63
53Variable
54Literal
55ExprTuple62
56Lambdaparameter: 74
body: 64
57Variable
58ExprTuple63, 65
59ExprTuple71, 65
60Literal
61ExprTuple64, 65
62ExprRangelambda_map: 66
start_index: 67
end_index: 68
63IndexedVarvariable: 69
index: 74
64IndexedVarvariable: 70
index: 74
65Variable
66Lambdaparameter: 74
body: 71
67Literal
68Variable
69Variable
70Variable
71IndexedVarvariable: 72
index: 74
72Variable
73ExprTuple74
74Variable