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, ExprTuple, Lambda
from proveit.core_expr_types import A_1_to_l, C_1_to_n, b_1_to_j
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, C_1_to_n], Conditional(Equals(Qmult(A_1_to_l, b_1_to_j, C_1_to_n), Qmult(b_1_to_j, A_1_to_l, C_1_to_n)).with_wrapping_at(2), InClass(Qmult(A_1_to_l, 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}, 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 b_{1} \thinspace  b_{2} \thinspace  \ldots \thinspace  b_{j}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) =  \\ \left(b_{1} \thinspace  b_{2} \thinspace  \ldots \thinspace  b_{j}\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\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 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
14ExprTuple17, 18, 19
15Literal
16ExprTuple18, 19
17ExprRangelambda_map: 20
start_index: 25
end_index: 21
18ExprRangelambda_map: 22
start_index: 25
end_index: 23
19ExprRangelambda_map: 24
start_index: 25
end_index: 26
20Lambdaparameter: 34
body: 27
21Variable
22Lambdaparameter: 34
body: 28
23Variable
24Lambdaparameter: 34
body: 29
25Literal
26Variable
27IndexedVarvariable: 30
index: 34
28IndexedVarvariable: 31
index: 34
29IndexedVarvariable: 32
index: 34
30Variable
31Variable
32Variable
33ExprTuple34
34Variable