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 B, Conditional, ExprTuple, Lambda, alpha
from proveit.core_expr_types import A_1_to_l, C_1_to_n
from proveit.linear_algebra import ScalarMult
from proveit.logic import Equals, InClass
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([A_1_to_l, B, C_1_to_n], Conditional(Equals(Qmult(A_1_to_l, ScalarMult(alpha, B), C_1_to_n), Qmult(A_1_to_l, alpha, B, C_1_to_n)).with_wrapping_at(2), InClass(Qmult(A_1_to_l, B, C_1_to_n), QmultCodomain))))
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(A_{1}, A_{2}, \ldots, A_{l}, B, C_{1}, C_{2}, \ldots, C_{n}\right) \mapsto \left\{\begin{array}{c} \begin{array}{l} \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l} \thinspace \left(\alpha \cdot B\right)\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) =  \\ \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l} \thinspace \alpha \thinspace B\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \end{array} \end{array} \textrm{ if } \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l} \thinspace B\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\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: 16
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9Operationoperator: 15
operands: 13
10Operationoperator: 15
operands: 14
11Operationoperator: 15
operands: 16
12Literal
13ExprTuple18, 17, 19
14ExprTuple18, 27, 28, 19
15Literal
16ExprTuple18, 28, 19
17Operationoperator: 20
operands: 21
18ExprRangelambda_map: 22
start_index: 25
end_index: 23
19ExprRangelambda_map: 24
start_index: 25
end_index: 26
20Literal
21ExprTuple27, 28
22Lambdaparameter: 34
body: 29
23Variable
24Lambdaparameter: 34
body: 30
25Literal
26Variable
27Variable
28Variable
29IndexedVarvariable: 31
index: 34
30IndexedVarvariable: 32
index: 34
31Variable
32Variable
33ExprTuple34
34Variable