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