logo

Expression of type ExprTuple

from the theory of proveit.linear_algebra.tensors

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, beta, gamma, i, x, y
from proveit.linear_algebra import ScalarMult, TensorProd, VecSum
from proveit.numbers import Add, Interval, Mult, four, one, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
sub_expr2 = Add(i, one)
sub_expr3 = Interval(two, four)
expr = ExprTuple(VecSum(index_or_indices = sub_expr1, summand = ScalarMult(gamma, ScalarMult(i, ScalarMult(beta, ScalarMult(sub_expr2, TensorProd(x, y))))), domain = sub_expr3), ScalarMult(Mult(gamma, beta), TensorProd(x, VecSum(index_or_indices = sub_expr1, summand = ScalarMult(Mult(i, sub_expr2), y), domain = sub_expr3))))
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(\sum_{i=2}^{4} \left(\gamma \cdot \left(i \cdot \left(\beta \cdot \left(\left(i + 1\right) \cdot \left(x {\otimes} y\right)\right)\right)\right)\right), \left(\gamma \cdot \beta\right) \cdot \left(x {\otimes} \left(\sum_{i=2}^{4} \left(\left(i \cdot \left(i + 1\right)\right) \cdot y\right)\right)\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 14
operand: 5
2Operationoperator: 33
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameter: 49
body: 8
6Operationoperator: 35
operands: 9
7Operationoperator: 43
operands: 10
8Conditionalvalue: 11
condition: 24
9ExprTuple16, 29
10ExprTuple47, 12
11Operationoperator: 33
operands: 13
12Operationoperator: 14
operand: 18
13ExprTuple16, 17
14Literal
15ExprTuple18
16Variable
17Operationoperator: 33
operands: 19
18Lambdaparameter: 49
body: 21
19ExprTuple49, 22
20ExprTuple49
21Conditionalvalue: 23
condition: 24
22Operationoperator: 33
operands: 25
23Operationoperator: 33
operands: 26
24Operationoperator: 27
operands: 28
25ExprTuple29, 30
26ExprTuple31, 48
27Literal
28ExprTuple49, 32
29Variable
30Operationoperator: 33
operands: 34
31Operationoperator: 35
operands: 36
32Operationoperator: 37
operands: 38
33Literal
34ExprTuple40, 39
35Literal
36ExprTuple49, 40
37Literal
38ExprTuple41, 42
39Operationoperator: 43
operands: 44
40Operationoperator: 45
operands: 46
41Literal
42Literal
43Literal
44ExprTuple47, 48
45Literal
46ExprTuple49, 50
47Variable
48Variable
49Variable
50Literal