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 Conditional, ExprTuple, Lambda, a, b, k, m
from proveit.core_expr_types import U_1_to_m
from proveit.logic import And, Forall, Implies, InSet
from proveit.numbers import NaturalPos
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([k, m], Conditional(Forall(instance_param_or_params = [a, b, U_1_to_m], instance_expr = Implies(circuit_aUb, QcircuitEquiv(circuit_aU, circuit_b))), And(InSet(k, NaturalPos), InSet(m, NaturalPos)))))
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(k, m\right) \mapsto \left\{\forall_{a, b, U_{1}, U_{2}, \ldots, U_{m}}~\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) \textrm{ if } k \in \mathbb{N}^+ ,  m \in \mathbb{N}^+\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
2ExprTuple67, 40
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12
10Lambdaparameters: 13
body: 14
11Operationoperator: 16
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple63, 64, 35
14Operationoperator: 18
operands: 19
15ExprTuple67, 20
16Literal
17ExprTuple40, 20
18Literal
19ExprTuple21, 22
20Literal
21Operationoperator: 31
operands: 23
22Operationoperator: 24
operands: 25
23ExprTuple34, 35, 26
24Literal
25ExprTuple27, 28
26ExprTuple29
27Operationoperator: 31
operands: 30
28Operationoperator: 31
operand: 36
29ExprRangelambda_map: 33
start_index: 66
end_index: 67
30ExprTuple34, 35
31Literal
32ExprTuple36
33Lambdaparameter: 65
body: 37
34ExprTuple38
35ExprRangelambda_map: 39
start_index: 66
end_index: 40
36ExprTuple41
37Operationoperator: 53
operands: 42
38ExprRangelambda_map: 43
start_index: 66
end_index: 67
39Lambdaparameter: 65
body: 44
40Variable
41ExprRangelambda_map: 45
start_index: 66
end_index: 67
42NamedExprselement: 46
targets: 57
43Lambdaparameter: 65
body: 47
44IndexedVarvariable: 48
index: 65
45Lambdaparameter: 65
body: 50
46Operationoperator: 51
operands: 60
47Operationoperator: 53
operands: 52
48Variable
49ExprTuple65
50Operationoperator: 53
operands: 54
51Literal
52NamedExprselement: 55
targets: 57
53Literal
54NamedExprselement: 56
targets: 57
55Operationoperator: 59
operands: 58
56Operationoperator: 59
operands: 60
57Operationoperator: 61
operands: 62
58NamedExprsstate: 63
part: 65
59Literal
60NamedExprsstate: 64
part: 65
61Literal
62ExprTuple66, 67
63Variable
64Variable
65Variable
66Literal
67Variable