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 Conditional, ExprTuple, K, Lambda, V, i, j, k, v
from proveit.linear_algebra import ScalarMult, VecSpaces, VecSum
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Integer, Interval, LessEq, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([j, k], Conditional(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)), And(InSet(j, Integer), InSet(k, Integer), 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(\left(j, k\right) \mapsto \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] \textrm{ if } j \in \mathbb{Z} ,  k \in \mathbb{Z} ,  j \leq k\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
1Lambdaparameters: 60
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 20
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple9, 10, 11
8Lambdaparameter: 38
body: 13
9Operationoperator: 52
operands: 14
10Operationoperator: 52
operands: 15
11Operationoperator: 16
operands: 60
12ExprTuple38
13Conditionalvalue: 17
condition: 18
14ExprTuple64, 19
15ExprTuple63, 19
16Literal
17Operationoperator: 20
operand: 24
18Operationoperator: 22
operands: 23
19Literal
20Literal
21ExprTuple24
22Literal
23ExprTuple38, 25
24Lambdaparameter: 48
body: 27
25Operationoperator: 28
operand: 32
26ExprTuple48
27Conditionalvalue: 30
condition: 31
28Literal
29ExprTuple32
30Operationoperator: 33
operands: 34
31Operationoperator: 52
operands: 35
32Variable
33Literal
34ExprTuple36, 37
35ExprTuple48, 38
36Operationoperator: 39
operand: 43
37Operationoperator: 41
operands: 42
38Variable
39Literal
40ExprTuple43
41Literal
42ExprTuple44, 48
43Lambdaparameter: 56
body: 46
44Operationoperator: 54
operands: 47
45ExprTuple56
46Conditionalvalue: 48
condition: 49
47ExprTuple50, 51
48Variable
49Operationoperator: 52
operands: 53
50Operationoperator: 54
operands: 55
51Literal
52Literal
53ExprTuple56, 57
54Literal
55ExprTuple63, 58
56Variable
57Operationoperator: 59
operands: 60
58Operationoperator: 61
operand: 64
59Literal
60ExprTuple64, 63
61Literal
62ExprTuple64
63Variable
64Variable