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, k
from proveit.core_expr_types import a_1_to_i
from proveit.linear_algebra import ScalarMult, VecAdd
from proveit.logic import Equals, Forall, InSet
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(i, Conditional(Forall(instance_param_or_params = [k, a_1_to_i], instance_expr = Equals(VecAdd(ExprRange(sub_expr1, ScalarMult(k, IndexedVar(a, sub_expr1)), one, i)), ScalarMult(k, VecAdd(a_1_to_i))).with_wrapping_at(2), domains = [K, V]), InSet(i, Natural))))
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(i \mapsto \left\{\forall_{k \in K,\left(a_{1} \in V\right), \left(a_{2} \in V\right), \ldots, \left(a_{i} \in V\right)}~\left(\begin{array}{c} \begin{array}{l} \left(\left(k \cdot a_{1}\right) +  \left(k \cdot a_{2}\right) +  \ldots +  \left(k \cdot a_{i}\right)\right) =  \\ \left(k \cdot \left(a_{1} +  a_{2} +  \ldots +  a_{i}\right)\right) \end{array} \end{array}\right) \textrm{ if } i \in \mathbb{N}\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: 6
operand: 9
5Operationoperator: 34
operands: 8
6Literal
7ExprTuple9
8ExprTuple43, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple44, 37
12Conditionalvalue: 13
condition: 14
13Operationoperator: 15
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple21, 22
19Operationoperator: 32
operands: 23
20Operationoperator: 39
operands: 24
21Operationoperator: 34
operands: 25
22ExprRangelambda_map: 26
start_index: 42
end_index: 43
23ExprTuple27
24ExprTuple44, 28
25ExprTuple44, 29
26Lambdaparameter: 48
body: 30
27ExprRangelambda_map: 31
start_index: 42
end_index: 43
28Operationoperator: 32
operands: 33
29Variable
30Operationoperator: 34
operands: 35
31Lambdaparameter: 48
body: 36
32Literal
33ExprTuple37
34Literal
35ExprTuple45, 38
36Operationoperator: 39
operands: 40
37ExprRangelambda_map: 41
start_index: 42
end_index: 43
38Variable
39Literal
40ExprTuple44, 45
41Lambdaparameter: 48
body: 45
42Literal
43Variable
44Variable
45IndexedVarvariable: 46
index: 48
46Variable
47ExprTuple48
48Variable