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, ExprTuple, K, Lambda, V, n
from proveit.core_expr_types import a_1_to_n, x_1_to_n
from proveit.linear_algebra import VecSpaces, lin_comb_axn
from proveit.logic import Forall, InSet
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [K], instance_expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [x_1_to_n], instance_expr = InSet(lin_comb_axn, V), domain = V), domain = K), domain = VecSpaces(K))), InSet(n, NaturalPos))))
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_{K}~\left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{n} \in K}~\left[\forall_{x_{1}, x_{2}, \ldots, x_{n} \in V}~\left(\left(\left(a_{1} \cdot x_{1}\right) +  \left(a_{2} \cdot x_{2}\right) +  \ldots +  \left(a_{n} \cdot x_{n}\right)\right) \in V\right)\right]\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: 57
body: 3
2ExprTuple57
3Conditionalvalue: 4
condition: 5
4Operationoperator: 30
operand: 8
5Operationoperator: 58
operands: 7
6ExprTuple8
7ExprTuple57, 9
8Lambdaparameter: 49
body: 10
9Literal
10Operationoperator: 30
operand: 12
11ExprTuple12
12Lambdaparameter: 61
body: 14
13ExprTuple61
14Conditionalvalue: 15
condition: 16
15Operationoperator: 30
operand: 20
16Operationoperator: 18
operands: 19
17ExprTuple20
18Literal
19ExprTuple61, 21
20Lambdaparameters: 22
body: 23
21Operationoperator: 24
operand: 49
22ExprTuple26
23Conditionalvalue: 27
condition: 28
24Literal
25ExprTuple49
26ExprRangelambda_map: 29
start_index: 56
end_index: 57
27Operationoperator: 30
operand: 33
28Operationoperator: 44
operands: 32
29Lambdaparameter: 69
body: 64
30Literal
31ExprTuple33
32ExprTuple34
33Lambdaparameters: 35
body: 36
34ExprRangelambda_map: 37
start_index: 56
end_index: 57
35ExprTuple38
36Conditionalvalue: 39
condition: 40
37Lambdaparameter: 69
body: 41
38ExprRangelambda_map: 42
start_index: 56
end_index: 57
39Operationoperator: 58
operands: 43
40Operationoperator: 44
operands: 45
41Operationoperator: 58
operands: 46
42Lambdaparameter: 69
body: 65
43ExprTuple47, 61
44Literal
45ExprTuple48
46ExprTuple64, 49
47Operationoperator: 50
operands: 51
48ExprRangelambda_map: 52
start_index: 56
end_index: 57
49Variable
50Literal
51ExprTuple53
52Lambdaparameter: 69
body: 54
53ExprRangelambda_map: 55
start_index: 56
end_index: 57
54Operationoperator: 58
operands: 59
55Lambdaparameter: 69
body: 60
56Literal
57Variable
58Literal
59ExprTuple65, 61
60Operationoperator: 62
operands: 63
61Variable
62Literal
63ExprTuple64, 65
64IndexedVarvariable: 66
index: 69
65IndexedVarvariable: 67
index: 69
66Variable
67Variable
68ExprTuple69
69Variable