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 Conditional, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, b, j
from proveit.core_expr_types import A_1_to_l, b_1_to_j
from proveit.logic import And, Equals, Forall, InClass, InSet
from proveit.numbers import Complex, Mult, one
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda([b_1_to_j], Conditional(Forall(instance_param_or_params = [A_1_to_l], instance_expr = Equals(Qmult(b_1_to_j, A_1_to_l), Qmult(Mult(b_1_to_j), A_1_to_l)).with_wrapping_at(2), condition = InClass(Qmult(A_1_to_l), QmultCodomain)), And(ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Complex), one, j)))))
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(b_{1}, b_{2}, \ldots, b_{j}\right) \mapsto \left\{\forall_{A_{1}, A_{2}, \ldots, A_{l}~|~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}}~\left(\begin{array}{c} \begin{array}{l} \left(b_{1} \thinspace  b_{2} \thinspace  \ldots \thinspace  b_{j}\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) =  \\ \left(\left(b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right)\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) \end{array} \end{array}\right) \textrm{ if } \left(b_{1} \in \mathbb{C}\right) \land  \left(b_{2} \in \mathbb{C}\right) \land  \ldots \land  \left(b_{j} \in \mathbb{C}\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
1Lambdaparameters: 34
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10
9Lambdaparameters: 30
body: 11
10ExprRangelambda_map: 12
start_index: 40
end_index: 41
11Conditionalvalue: 13
condition: 14
12Lambdaparameter: 46
body: 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 20
operands: 21
16Literal
17ExprTuple22, 23
18Literal
19ExprTuple24, 25
20Literal
21ExprTuple43, 26
22Operationoperator: 29
operands: 27
23Operationoperator: 29
operands: 28
24Operationoperator: 29
operands: 30
25Literal
26Literal
27ExprTuple37, 32
28ExprTuple31, 32
29Literal
30ExprTuple32
31Operationoperator: 33
operands: 34
32ExprRangelambda_map: 35
start_index: 40
end_index: 36
33Literal
34ExprTuple37
35Lambdaparameter: 46
body: 38
36Variable
37ExprRangelambda_map: 39
start_index: 40
end_index: 41
38IndexedVarvariable: 42
index: 46
39Lambdaparameter: 46
body: 43
40Literal
41Variable
42Variable
43IndexedVarvariable: 44
index: 46
44Variable
45ExprTuple46
46Variable