logo

Expression of type ExprTuple

from the theory of proveit.linear_algebra.scalar_multiplication

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 ExprRange, ExprTuple, IndexedVar, K, Lambda, V, Variable, a, i, k
from proveit.core_expr_types import a_1_to_i
from proveit.linear_algebra import ScalarMult, VecAdd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda(K, Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [i], instance_expr = Forall(instance_param_or_params = [k, a_1_to_i], instance_expr = Equals(VecAdd(ExprRange(sub_expr1, ScalarMult(k, IndexedVar(a, sub_expr1)), one, i)), ScalarMult(k, VecAdd(a_1_to_i))).with_wrapping_at(2), domains = [K, 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 \in \mathbb{N}}~\left[\forall_{k \in K,\left(a_{1} \in V\right), \left(a_{2} \in V\right), \ldots, \left(a_{i} \in V\right)}~\left(\begin{array}{c} \begin{array}{l} \left(\left(k \cdot a_{1}\right) +  \left(k \cdot a_{2}\right) +  \ldots +  \left(k \cdot a_{i}\right)\right) =  \\ \left(k \cdot \left(a_{1} +  a_{2} +  \ldots +  a_{i}\right)\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: 43
body: 2
2Operationoperator: 20
operand: 4
3ExprTuple4
4Lambdaparameter: 52
body: 6
5ExprTuple52
6Conditionalvalue: 7
condition: 8
7Operationoperator: 20
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple52, 13
12Lambdaparameter: 57
body: 15
13Operationoperator: 16
operand: 43
14ExprTuple57
15Conditionalvalue: 18
condition: 19
16Literal
17ExprTuple43
18Operationoperator: 20
operand: 23
19Operationoperator: 48
operands: 22
20Literal
21ExprTuple23
22ExprTuple57, 24
23Lambdaparameters: 25
body: 26
24Literal
25ExprTuple58, 51
26Conditionalvalue: 27
condition: 28
27Operationoperator: 29
operands: 30
28Operationoperator: 31
operands: 32
29Literal
30ExprTuple33, 34
31Literal
32ExprTuple35, 36
33Operationoperator: 46
operands: 37
34Operationoperator: 53
operands: 38
35Operationoperator: 48
operands: 39
36ExprRangelambda_map: 40
start_index: 56
end_index: 57
37ExprTuple41
38ExprTuple58, 42
39ExprTuple58, 43
40Lambdaparameter: 62
body: 44
41ExprRangelambda_map: 45
start_index: 56
end_index: 57
42Operationoperator: 46
operands: 47
43Variable
44Operationoperator: 48
operands: 49
45Lambdaparameter: 62
body: 50
46Literal
47ExprTuple51
48Literal
49ExprTuple59, 52
50Operationoperator: 53
operands: 54
51ExprRangelambda_map: 55
start_index: 56
end_index: 57
52Variable
53Literal
54ExprTuple58, 59
55Lambdaparameter: 62
body: 59
56Literal
57Variable
58Variable
59IndexedVarvariable: 60
index: 62
60Variable
61ExprTuple62
62Variable