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, n, v
from proveit.core_expr_types import a_1_to_n
from proveit.linear_algebra import ScalarMult, VecAdd, VecSpaces
from proveit.logic import Equals, Forall, InClass
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(V, Conditional(Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [v], instance_expr = Equals(ScalarMult(VecAdd(a_1_to_n), v), VecAdd(ExprRange(sub_expr1, ScalarMult(IndexedVar(a, sub_expr1), v), one, n))).with_wrapping_at(2), domain = V), domain = K), 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_{n \in \mathbb{N}}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{n} \in K}~\left[\forall_{v \in V}~\left(\begin{array}{c} \begin{array}{l} \left(\left(a_{1} +  a_{2} +  \ldots +  a_{n}\right) \cdot v\right) =  \\ \left(\left(a_{1} \cdot v\right) +  \left(a_{2} \cdot v\right) +  \ldots +  \left(a_{n} \cdot v\right)\right) \end{array} \end{array}\right)\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: 43
body: 3
2ExprTuple43
3Conditionalvalue: 4
condition: 5
4Operationoperator: 24
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple43, 10
9Lambdaparameter: 56
body: 12
10Operationoperator: 13
operand: 44
11ExprTuple56
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple44
15Operationoperator: 24
operand: 19
16Operationoperator: 39
operands: 18
17ExprTuple19
18ExprTuple56, 20
19Lambdaparameters: 50
body: 21
20Literal
21Conditionalvalue: 22
condition: 23
22Operationoperator: 24
operand: 28
23Operationoperator: 26
operands: 27
24Literal
25ExprTuple28
26Literal
27ExprTuple29
28Lambdaparameter: 60
body: 31
29ExprRangelambda_map: 32
start_index: 55
end_index: 56
30ExprTuple60
31Conditionalvalue: 33
condition: 34
32Lambdaparameter: 63
body: 35
33Operationoperator: 36
operands: 37
34Operationoperator: 39
operands: 38
35Operationoperator: 39
operands: 40
36Literal
37ExprTuple41, 42
38ExprTuple60, 43
39Literal
40ExprTuple59, 44
41Operationoperator: 57
operands: 45
42Operationoperator: 49
operands: 46
43Variable
44Variable
45ExprTuple47, 60
46ExprTuple48
47Operationoperator: 49
operands: 50
48ExprRangelambda_map: 51
start_index: 55
end_index: 56
49Literal
50ExprTuple52
51Lambdaparameter: 63
body: 53
52ExprRangelambda_map: 54
start_index: 55
end_index: 56
53Operationoperator: 57
operands: 58
54Lambdaparameter: 63
body: 59
55Literal
56Variable
57Literal
58ExprTuple59, 60
59IndexedVarvariable: 61
index: 63
60Variable
61Variable
62ExprTuple63
63Variable