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, i, j, m
from proveit.core_expr_types import U_1_to_i, V_1_to_j
from proveit.logic import And, Equals, Forall, Implies, InSet
from proveit.numbers import NaturalPos, one
from proveit.physics.quantum import m_ket_domain, var_ket_psi
from proveit.physics.quantum.circuits import circuit_Ui_Vj, circuit_Ui_psi_m, circuit_psi_m_Vj
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([i, j, m], Conditional(Forall(instance_param_or_params = [var_ket_psi], instance_expr = Forall(instance_param_or_params = [U_1_to_i, V_1_to_j], instance_expr = Implies(Equals(Prob(circuit_Ui_psi_m), one), Equals(Prob(circuit_Ui_Vj), Prob(circuit_psi_m_Vj)).with_wrapping_at(2)).with_wrapping_at(2)).with_wrapping(), domain = m_ket_domain).with_wrapping(), And(InSet(i, NaturalPos), InSet(j, 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(i, j, m\right) \mapsto \left\{\begin{array}{l}\forall_{\lvert \psi \rangle \in \mathbb{C}^{2^{m}}}~\\
\left[\begin{array}{l}\forall_{U_{1}, U_{2}, \ldots, U_{i}, V_{1}, V_{2}, \ldots, V_{j}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{i} \\ \downarrow\end{array}} & \qout{\lvert \psi \rangle}
} \end{array}\right) = 1\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \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_{i} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{j} \\ \downarrow\end{array}} & \qw
} \end{array}\right) =  \\ \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \gate{\begin{array}{c} \uparrow \\V_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{j} \\ \downarrow\end{array}} & { /^{m} } \qw
} \end{array}\right) \end{array} \end{array}\right) \end{array} \end{array}\right)\end{array}\right]\end{array} \textrm{ if } i \in \mathbb{N}^+ ,  j \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
2ExprTuple63, 66, 90
3Conditionalvalue: 4
condition: 5
4Operationoperator: 21
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameter: 87
body: 14
10Operationoperator: 23
operands: 15
11Operationoperator: 23
operands: 16
12Operationoperator: 23
operands: 17
13ExprTuple87
14Conditionalvalue: 18
condition: 19
15ExprTuple63, 20
16ExprTuple66, 20
17ExprTuple90, 20
18Operationoperator: 21
operand: 25
19Operationoperator: 23
operands: 24
20Literal
21Literal
22ExprTuple25
23Literal
24ExprTuple87, 26
25Lambdaparameters: 27
body: 28
26Operationoperator: 29
operands: 30
27ExprTuple58, 60
28Operationoperator: 31
operands: 32
29Literal
30ExprTuple33, 34
31Literal
32ExprTuple35, 36
33Literal
34Operationoperator: 37
operands: 38
35Operationoperator: 40
operands: 39
36Operationoperator: 40
operands: 41
37Literal
38ExprTuple42, 90
39ExprTuple43, 89
40Literal
41ExprTuple44, 45
42Literal
43Operationoperator: 48
operand: 50
44Operationoperator: 48
operand: 51
45Operationoperator: 48
operand: 52
46ExprTuple50
47ExprTuple51
48Literal
49ExprTuple52
50Operationoperator: 55
operands: 53
51Operationoperator: 55
operands: 54
52Operationoperator: 55
operands: 56
53ExprTuple58, 57
54ExprTuple58, 60
55Literal
56ExprTuple59, 60
57ExprTuple61
58ExprRangelambda_map: 62
start_index: 89
end_index: 63
59ExprTuple64
60ExprRangelambda_map: 65
start_index: 89
end_index: 66
61ExprRangelambda_map: 67
start_index: 89
end_index: 90
62Lambdaparameter: 88
body: 68
63Variable
64ExprRangelambda_map: 69
start_index: 89
end_index: 90
65Lambdaparameter: 88
body: 70
66Variable
67Lambdaparameter: 88
body: 71
68IndexedVarvariable: 72
index: 88
69Lambdaparameter: 88
body: 73
70IndexedVarvariable: 74
index: 88
71Operationoperator: 77
operands: 76
72Variable
73Operationoperator: 77
operands: 78
74Variable
75ExprTuple88
76NamedExprselement: 79
targets: 81
77Literal
78NamedExprselement: 80
targets: 81
79Operationoperator: 82
operands: 84
80Operationoperator: 83
operands: 84
81Operationoperator: 85
operands: 86
82Literal
83Literal
84NamedExprsstate: 87
part: 88
85Literal
86ExprTuple89, 90
87Variable
88Variable
89Literal
90Variable