logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.circuits

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, Lambda, a, b
from proveit.core_expr_types import U_1_to_m
from proveit.logic import Implies
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_aU, circuit_aUb, circuit_b
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([a, b, U_1_to_m], Implies(circuit_aUb, QcircuitEquiv(circuit_aU, circuit_b))))
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, b, U_{1}, U_{2}, \ldots, U_{m}\right) \mapsto \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{a} & \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{m} \\ \downarrow\end{array}} & \qout{b}
} \end{array}\right) \Rightarrow \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{a} & \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{m} \\ \downarrow\end{array}} & { /^{k} } \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{b} & { /^{k} } \qw
} \end{array}\right)\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: 2
body: 3
2ExprTuple48, 49, 20
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 16
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple19, 20, 11
9Literal
10ExprTuple12, 13
11ExprTuple14
12Operationoperator: 16
operands: 15
13Operationoperator: 16
operand: 21
14ExprRangelambda_map: 18
start_index: 51
end_index: 52
15ExprTuple19, 20
16Literal
17ExprTuple21
18Lambdaparameter: 50
body: 22
19ExprTuple23
20ExprRangelambda_map: 24
start_index: 51
end_index: 25
21ExprTuple26
22Operationoperator: 38
operands: 27
23ExprRangelambda_map: 28
start_index: 51
end_index: 52
24Lambdaparameter: 50
body: 29
25Variable
26ExprRangelambda_map: 30
start_index: 51
end_index: 52
27NamedExprselement: 31
targets: 42
28Lambdaparameter: 50
body: 32
29IndexedVarvariable: 33
index: 50
30Lambdaparameter: 50
body: 35
31Operationoperator: 36
operands: 45
32Operationoperator: 38
operands: 37
33Variable
34ExprTuple50
35Operationoperator: 38
operands: 39
36Literal
37NamedExprselement: 40
targets: 42
38Literal
39NamedExprselement: 41
targets: 42
40Operationoperator: 44
operands: 43
41Operationoperator: 44
operands: 45
42Operationoperator: 46
operands: 47
43NamedExprsstate: 48
part: 50
44Literal
45NamedExprsstate: 49
part: 50
46Literal
47ExprTuple51, 52
48Variable
49Variable
50Variable
51Literal
52Variable