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 ExprTuple, K, Lambda, V, c, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, d_1_to_k
from proveit.linear_algebra import VecAdd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(K, Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [i, j, k], instance_expr = Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c, d_1_to_k], instance_expr = Equals(VecAdd(a_1_to_i, b_1_to_j, c, d_1_to_k), VecAdd(a_1_to_i, c, b_1_to_j, d_1_to_k)).with_wrapping_at(2), domain = V), domain = Natural), domain = 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(K \mapsto \left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\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, d_{1}, d_{2}, \ldots, d_{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+ d_{1} +  d_{2} +  \ldots +  d_{k}\right) =  \\ \left(a_{1} +  a_{2} +  \ldots +  a_{i} + c+ b_{1} +  b_{2} +  \ldots +  b_{j}+ d_{1} +  d_{2} +  \ldots +  d_{k}\right) \end{array} \end{array}\right)\right]\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: 20
body: 2
2Operationoperator: 21
operand: 4
3ExprTuple4
4Lambdaparameter: 73
body: 6
5ExprTuple73
6Conditionalvalue: 7
condition: 8
7Operationoperator: 21
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple73, 13
12Lambdaparameters: 14
body: 15
13Operationoperator: 16
operand: 20
14ExprTuple60, 62, 65
15Conditionalvalue: 18
condition: 19
16Literal
17ExprTuple20
18Operationoperator: 21
operand: 24
19Operationoperator: 37
operands: 23
20Variable
21Literal
22ExprTuple24
23ExprTuple25, 26, 27
24Lambdaparameters: 45
body: 28
25Operationoperator: 68
operands: 29
26Operationoperator: 68
operands: 30
27Operationoperator: 68
operands: 31
28Conditionalvalue: 32
condition: 33
29ExprTuple60, 34
30ExprTuple62, 34
31ExprTuple65, 34
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operands: 38
34Literal
35Literal
36ExprTuple39, 40
37Literal
38ExprTuple41, 42, 43, 44
39Operationoperator: 46
operands: 45
40Operationoperator: 46
operands: 47
41ExprRangelambda_map: 48
start_index: 64
end_index: 60
42ExprRangelambda_map: 49
start_index: 64
end_index: 62
43Operationoperator: 68
operands: 50
44ExprRangelambda_map: 51
start_index: 64
end_index: 65
45ExprTuple52, 53, 57, 54
46Literal
47ExprTuple52, 57, 53, 54
48Lambdaparameter: 78
body: 55
49Lambdaparameter: 78
body: 56
50ExprTuple57, 73
51Lambdaparameter: 78
body: 58
52ExprRangelambda_map: 59
start_index: 64
end_index: 60
53ExprRangelambda_map: 61
start_index: 64
end_index: 62
54ExprRangelambda_map: 63
start_index: 64
end_index: 65
55Operationoperator: 68
operands: 66
56Operationoperator: 68
operands: 67
57Variable
58Operationoperator: 68
operands: 69
59Lambdaparameter: 78
body: 70
60Variable
61Lambdaparameter: 78
body: 71
62Variable
63Lambdaparameter: 78
body: 72
64Literal
65Variable
66ExprTuple70, 73
67ExprTuple71, 73
68Literal
69ExprTuple72, 73
70IndexedVarvariable: 74
index: 78
71IndexedVarvariable: 75
index: 78
72IndexedVarvariable: 76
index: 78
73Variable
74Variable
75Variable
76Variable
77ExprTuple78
78Variable