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
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(n, Conditional(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), InSet(n, 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(n \mapsto \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] \textrm{ if } n \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: 45
body: 3
2ExprTuple45
3Conditionalvalue: 4
condition: 5
4Operationoperator: 14
operand: 8
5Operationoperator: 38
operands: 7
6ExprTuple8
7ExprTuple45, 9
8Lambdaparameter: 48
body: 11
9Literal
10ExprTuple48
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operand: 17
13Operationoperator: 38
operands: 16
14Literal
15ExprTuple17
16ExprTuple48, 18
17Lambdaparameters: 36
body: 19
18Variable
19Conditionalvalue: 20
condition: 21
20Operationoperator: 22
operands: 23
21Operationoperator: 24
operands: 25
22Literal
23ExprTuple26, 27
24Literal
25ExprTuple28
26Operationoperator: 46
operands: 29
27Operationoperator: 35
operands: 30
28ExprRangelambda_map: 31
start_index: 44
end_index: 45
29ExprTuple48, 32
30ExprTuple33
31Lambdaparameter: 52
body: 34
32Operationoperator: 35
operands: 36
33ExprRangelambda_map: 37
start_index: 44
end_index: 45
34Operationoperator: 38
operands: 39
35Literal
36ExprTuple40
37Lambdaparameter: 52
body: 41
38Literal
39ExprTuple49, 42
40ExprRangelambda_map: 43
start_index: 44
end_index: 45
41Operationoperator: 46
operands: 47
42Variable
43Lambdaparameter: 52
body: 49
44Literal
45Variable
46Literal
47ExprTuple48, 49
48Variable
49IndexedVarvariable: 50
index: 52
50Variable
51ExprTuple52
52Variable