logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.algebra

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 ExprRange, ExprTuple, Function, IndexedVar, Q, Variable, alpha, beta, c, f, j
from proveit.linear_algebra import VecSum
from proveit.numbers import one
from proveit.physics.quantum import Qmult, bra_varphi
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, j)]
expr = ExprTuple(Qmult(bra_varphi, alpha, VecSum(index_or_indices = sub_expr2, summand = Function(f, sub_expr2), condition = Function(Q, sub_expr2)), beta))
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(\langle \varphi \rvert \thinspace \alpha \thinspace \left[\sum_{c_{1}, c_{2}, \ldots, c_{j}~|~Q\left(c_{1}, c_{2}, \ldots, c_{j}\right)}~f\left(c_{1}, c_{2}, \ldots, c_{j}\right)\right] \thinspace \beta\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Operationoperator: 2
operands: 3
2Literal
3ExprTuple4, 5, 6, 7
4Operationoperator: 8
operand: 12
5Variable
6Operationoperator: 10
operand: 13
7Variable
8Literal
9ExprTuple12
10Literal
11ExprTuple13
12Variable
13Lambdaparameters: 19
body: 14
14Conditionalvalue: 15
condition: 16
15Operationoperator: 17
operands: 19
16Operationoperator: 18
operands: 19
17Variable
18Variable
19ExprTuple20
20ExprRangelambda_map: 21
start_index: 22
end_index: 23
21Lambdaparameter: 27
body: 24
22Literal
23Variable
24IndexedVarvariable: 25
index: 27
25Variable
26ExprTuple27
27Variable