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
from proveit.core_expr_types import U_1_to_i, V_1_to_j
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import 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(var_ket_psi, Conditional(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(), InSet(var_ket_psi, m_ket_domain))))
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(\lvert \psi \rangle \mapsto \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} \textrm{ if } \lvert \psi \rangle \in \mathbb{C}^{2^{m}}\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
1Lambdaparameter: 72
body: 3
2ExprTuple72
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple72, 11
10Lambdaparameters: 12
body: 13
11Operationoperator: 14
operands: 15
12ExprTuple43, 45
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple20, 21
18Literal
19Operationoperator: 22
operands: 23
20Operationoperator: 25
operands: 24
21Operationoperator: 25
operands: 26
22Literal
23ExprTuple27, 75
24ExprTuple28, 74
25Literal
26ExprTuple29, 30
27Literal
28Operationoperator: 33
operand: 35
29Operationoperator: 33
operand: 36
30Operationoperator: 33
operand: 37
31ExprTuple35
32ExprTuple36
33Literal
34ExprTuple37
35Operationoperator: 40
operands: 38
36Operationoperator: 40
operands: 39
37Operationoperator: 40
operands: 41
38ExprTuple43, 42
39ExprTuple43, 45
40Literal
41ExprTuple44, 45
42ExprTuple46
43ExprRangelambda_map: 47
start_index: 74
end_index: 48
44ExprTuple49
45ExprRangelambda_map: 50
start_index: 74
end_index: 51
46ExprRangelambda_map: 52
start_index: 74
end_index: 75
47Lambdaparameter: 73
body: 53
48Variable
49ExprRangelambda_map: 54
start_index: 74
end_index: 75
50Lambdaparameter: 73
body: 55
51Variable
52Lambdaparameter: 73
body: 56
53IndexedVarvariable: 57
index: 73
54Lambdaparameter: 73
body: 58
55IndexedVarvariable: 59
index: 73
56Operationoperator: 62
operands: 61
57Variable
58Operationoperator: 62
operands: 63
59Variable
60ExprTuple73
61NamedExprselement: 64
targets: 66
62Literal
63NamedExprselement: 65
targets: 66
64Operationoperator: 67
operands: 69
65Operationoperator: 68
operands: 69
66Operationoperator: 70
operands: 71
67Literal
68Literal
69NamedExprsstate: 72
part: 73
70Literal
71ExprTuple74, 75
72Variable
73Variable
74Literal
75Variable