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, 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, 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], 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), 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 \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] \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: 53
body: 3
2ExprTuple53
3Conditionalvalue: 4
condition: 5
4Operationoperator: 25
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple53, 10
9Lambdaparameter: 56
body: 12
10Operationoperator: 13
operand: 29
11ExprTuple56
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple29
15Operationoperator: 25
operand: 19
16Operationoperator: 49
operands: 18
17ExprTuple19
18ExprTuple56, 20
19Lambdaparameter: 59
body: 22
20Literal
21ExprTuple59
22Conditionalvalue: 23
condition: 24
23Operationoperator: 25
operand: 28
24Operationoperator: 49
operands: 27
25Literal
26ExprTuple28
27ExprTuple59, 29
28Lambdaparameters: 47
body: 30
29Variable
30Conditionalvalue: 31
condition: 32
31Operationoperator: 33
operands: 34
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple37, 38
35Literal
36ExprTuple39
37Operationoperator: 57
operands: 40
38Operationoperator: 46
operands: 41
39ExprRangelambda_map: 42
start_index: 55
end_index: 56
40ExprTuple59, 43
41ExprTuple44
42Lambdaparameter: 63
body: 45
43Operationoperator: 46
operands: 47
44ExprRangelambda_map: 48
start_index: 55
end_index: 56
45Operationoperator: 49
operands: 50
46Literal
47ExprTuple51
48Lambdaparameter: 63
body: 52
49Literal
50ExprTuple60, 53
51ExprRangelambda_map: 54
start_index: 55
end_index: 56
52Operationoperator: 57
operands: 58
53Variable
54Lambdaparameter: 63
body: 60
55Literal
56Variable
57Literal
58ExprTuple59, 60
59Variable
60IndexedVarvariable: 61
index: 63
61Variable
62ExprTuple63
63Variable