logo

Expression of type ExprTuple

from the theory of proveit.linear_algebra.addition

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 ExprTuple, K, Lambda, V, i, j, k, v
from proveit.linear_algebra import ScalarMult, VecSpaces, VecSum
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, LessEq, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(K, Forall(instance_param_or_params = [j, k], instance_expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [v], instance_expr = Equals(VecSum(index_or_indices = [i], summand = v, domain = Interval(j, k)), ScalarMult(Add(subtract(k, j), one), v)), domain = V), domain = VecSpaces(K)), domain = Integer, condition = LessEq(j, 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_{j, k \in \mathbb{Z}~|~j \leq k}~\left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{v \in V}~\left(\left(\sum_{i=j}^{k} v\right) = \left(\left(\left(k - j\right) + 1\right) \cdot v\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: 35
body: 2
2Operationoperator: 23
operand: 4
3ExprTuple4
4Lambdaparameters: 63
body: 5
5Conditionalvalue: 6
condition: 7
6Operationoperator: 23
operand: 11
7Operationoperator: 9
operands: 10
8ExprTuple11
9Literal
10ExprTuple12, 13, 14
11Lambdaparameter: 41
body: 16
12Operationoperator: 55
operands: 17
13Operationoperator: 55
operands: 18
14Operationoperator: 19
operands: 63
15ExprTuple41
16Conditionalvalue: 20
condition: 21
17ExprTuple67, 22
18ExprTuple66, 22
19Literal
20Operationoperator: 23
operand: 27
21Operationoperator: 25
operands: 26
22Literal
23Literal
24ExprTuple27
25Literal
26ExprTuple41, 28
27Lambdaparameter: 51
body: 30
28Operationoperator: 31
operand: 35
29ExprTuple51
30Conditionalvalue: 33
condition: 34
31Literal
32ExprTuple35
33Operationoperator: 36
operands: 37
34Operationoperator: 55
operands: 38
35Variable
36Literal
37ExprTuple39, 40
38ExprTuple51, 41
39Operationoperator: 42
operand: 46
40Operationoperator: 44
operands: 45
41Variable
42Literal
43ExprTuple46
44Literal
45ExprTuple47, 51
46Lambdaparameter: 59
body: 49
47Operationoperator: 57
operands: 50
48ExprTuple59
49Conditionalvalue: 51
condition: 52
50ExprTuple53, 54
51Variable
52Operationoperator: 55
operands: 56
53Operationoperator: 57
operands: 58
54Literal
55Literal
56ExprTuple59, 60
57Literal
58ExprTuple66, 61
59Variable
60Operationoperator: 62
operands: 63
61Operationoperator: 64
operand: 67
62Literal
63ExprTuple67, 66
64Literal
65ExprTuple67
66Variable
67Variable