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 Equals, Forall, InClass
from proveit.numbers import Add, Interval, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(V, Conditional(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), InClass(V, VecSpaces(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(V \mapsto \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) \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\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: 24
body: 3
2ExprTuple24
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple24, 11
10Lambdaparameter: 34
body: 13
11Operationoperator: 14
operand: 18
12ExprTuple34
13Conditionalvalue: 16
condition: 17
14Literal
15ExprTuple18
16Operationoperator: 19
operands: 20
17Operationoperator: 38
operands: 21
18Variable
19Literal
20ExprTuple22, 23
21ExprTuple34, 24
22Operationoperator: 25
operand: 29
23Operationoperator: 27
operands: 28
24Variable
25Literal
26ExprTuple29
27Literal
28ExprTuple30, 34
29Lambdaparameter: 42
body: 32
30Operationoperator: 40
operands: 33
31ExprTuple42
32Conditionalvalue: 34
condition: 35
33ExprTuple36, 37
34Variable
35Operationoperator: 38
operands: 39
36Operationoperator: 40
operands: 41
37Literal
38Literal
39ExprTuple42, 43
40Literal
41ExprTuple49, 44
42Variable
43Operationoperator: 45
operands: 46
44Operationoperator: 47
operand: 50
45Literal
46ExprTuple50, 49
47Literal
48ExprTuple50
49Variable
50Variable