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 Conditional, 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, InClass
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(V, Conditional(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), 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 \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] \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: 42
body: 3
2ExprTuple42
3Conditionalvalue: 4
condition: 5
4Operationoperator: 18
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple42, 10
9Lambdaparameter: 55
body: 12
10Operationoperator: 13
operand: 17
11ExprTuple55
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple17
15Operationoperator: 18
operand: 21
16Operationoperator: 46
operands: 20
17Variable
18Literal
19ExprTuple21
20ExprTuple55, 22
21Lambdaparameters: 23
body: 24
22Literal
23ExprTuple49, 56
24Conditionalvalue: 25
condition: 26
25Operationoperator: 27
operands: 28
26Operationoperator: 29
operands: 30
27Literal
28ExprTuple31, 32
29Literal
30ExprTuple33, 34
31Operationoperator: 44
operands: 35
32Operationoperator: 51
operands: 36
33ExprRangelambda_map: 37
start_index: 54
end_index: 55
34Operationoperator: 46
operands: 38
35ExprTuple39
36ExprTuple40, 56
37Lambdaparameter: 60
body: 41
38ExprTuple56, 42
39ExprRangelambda_map: 43
start_index: 54
end_index: 55
40Operationoperator: 44
operands: 45
41Operationoperator: 46
operands: 47
42Variable
43Lambdaparameter: 60
body: 48
44Literal
45ExprTuple49
46Literal
47ExprTuple57, 50
48Operationoperator: 51
operands: 52
49ExprRangelambda_map: 53
start_index: 54
end_index: 55
50Literal
51Literal
52ExprTuple57, 56
53Lambdaparameter: 60
body: 57
54Literal
55Variable
56Variable
57IndexedVarvariable: 58
index: 60
58Variable
59ExprTuple60
60Variable