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, v
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 Complex, 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 = [a_1_to_i, v], instance_expr = Equals(VecAdd(ExprRange(sub_expr1, ScalarMult(IndexedVar(a, sub_expr1), v), one, i)), ScalarMult(VecAdd(a_1_to_i), v)).with_wrapping_at(2), domains = [Complex, 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_{\left(a_{1} \in \mathbb{C}\right), \left(a_{2} \in \mathbb{C}\right), \ldots, \left(a_{i} \in \mathbb{C}\right), v \in V}~\left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} \cdot v\right) +  \left(a_{2} \cdot v\right) +  \ldots +  \left(a_{i} \cdot v\right)\right) =  \\ \left(\left(a_{1} +  a_{2} +  \ldots +  a_{i}\right) \cdot v\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: 45
body: 6
5ExprTuple45
6Conditionalvalue: 7
condition: 8
7Operationoperator: 21
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple45, 13
12Lambdaparameter: 58
body: 15
13Operationoperator: 16
operand: 20
14ExprTuple58
15Conditionalvalue: 18
condition: 19
16Literal
17ExprTuple20
18Operationoperator: 21
operand: 24
19Operationoperator: 49
operands: 23
20Variable
21Literal
22ExprTuple24
23ExprTuple58, 25
24Lambdaparameters: 26
body: 27
25Literal
26ExprTuple52, 59
27Conditionalvalue: 28
condition: 29
28Operationoperator: 30
operands: 31
29Operationoperator: 32
operands: 33
30Literal
31ExprTuple34, 35
32Literal
33ExprTuple36, 37
34Operationoperator: 47
operands: 38
35Operationoperator: 54
operands: 39
36ExprRangelambda_map: 40
start_index: 57
end_index: 58
37Operationoperator: 49
operands: 41
38ExprTuple42
39ExprTuple43, 59
40Lambdaparameter: 63
body: 44
41ExprTuple59, 45
42ExprRangelambda_map: 46
start_index: 57
end_index: 58
43Operationoperator: 47
operands: 48
44Operationoperator: 49
operands: 50
45Variable
46Lambdaparameter: 63
body: 51
47Literal
48ExprTuple52
49Literal
50ExprTuple60, 53
51Operationoperator: 54
operands: 55
52ExprRangelambda_map: 56
start_index: 57
end_index: 58
53Literal
54Literal
55ExprTuple60, 59
56Lambdaparameter: 63
body: 60
57Literal
58Variable
59Variable
60IndexedVarvariable: 61
index: 63
61Variable
62ExprTuple63
63Variable