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(ScalarMult(gamma, 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(\left(\gamma \cdot i\right) \cdot \left(\beta \cdot \left(\left(i + 1\right) \cdot \left(x {\otimes} y\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: 29
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameter: 49
body: 8
6Operationoperator: 38
operands: 9
7Operationoperator: 36
operands: 10
8Conditionalvalue: 11
condition: 27
9ExprTuple23, 24
10ExprTuple42, 12
11Operationoperator: 29
operands: 13
12Operationoperator: 14
operand: 18
13ExprTuple16, 17
14Literal
15ExprTuple18
16Operationoperator: 29
operands: 19
17Operationoperator: 29
operands: 20
18Lambdaparameter: 49
body: 22
19ExprTuple23, 49
20ExprTuple24, 25
21ExprTuple49
22Conditionalvalue: 26
condition: 27
23Variable
24Variable
25Operationoperator: 29
operands: 28
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operands: 32
28ExprTuple44, 33
29Literal
30ExprTuple34, 43
31Literal
32ExprTuple49, 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35Operationoperator: 40
operands: 41
36Literal
37ExprTuple42, 43
38Literal
39ExprTuple49, 44
40Literal
41ExprTuple45, 46
42Variable
43Variable
44Operationoperator: 47
operands: 48
45Literal
46Literal
47Literal
48ExprTuple49, 50
49Variable
50Literal