logo

Expression of type Conditional

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, 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 = 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_psi_m_Vj), one), Equals(Prob(circuit_Ui_Vj), Prob(circuit_Ui_psi_m)).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\{\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{
\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) = 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{
& \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) \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..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 18
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8, 9
6Lambdaparameter: 84
body: 11
7Operationoperator: 20
operands: 12
8Operationoperator: 20
operands: 13
9Operationoperator: 20
operands: 14
10ExprTuple84
11Conditionalvalue: 15
condition: 16
12ExprTuple62, 17
13ExprTuple60, 17
14ExprTuple87, 17
15Operationoperator: 18
operand: 22
16Operationoperator: 20
operands: 21
17Literal
18Literal
19ExprTuple22
20Literal
21ExprTuple84, 23
22Lambdaparameters: 24
body: 25
23Operationoperator: 26
operands: 27
24ExprTuple56, 55
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple30, 31
28Literal
29ExprTuple32, 33
30Literal
31Operationoperator: 34
operands: 35
32Operationoperator: 37
operands: 36
33Operationoperator: 37
operands: 38
34Literal
35ExprTuple39, 87
36ExprTuple40, 86
37Literal
38ExprTuple41, 42
39Literal
40Operationoperator: 45
operand: 47
41Operationoperator: 45
operand: 48
42Operationoperator: 45
operand: 49
43ExprTuple47
44ExprTuple48
45Literal
46ExprTuple49
47Operationoperator: 52
operands: 50
48Operationoperator: 52
operands: 51
49Operationoperator: 52
operands: 53
50ExprTuple54, 55
51ExprTuple56, 55
52Literal
53ExprTuple56, 57
54ExprTuple58
55ExprRangelambda_map: 59
start_index: 86
end_index: 60
56ExprRangelambda_map: 61
start_index: 86
end_index: 62
57ExprTuple63
58ExprRangelambda_map: 64
start_index: 86
end_index: 87
59Lambdaparameter: 85
body: 65
60Variable
61Lambdaparameter: 85
body: 66
62Variable
63ExprRangelambda_map: 67
start_index: 86
end_index: 87
64Lambdaparameter: 85
body: 68
65IndexedVarvariable: 69
index: 85
66IndexedVarvariable: 70
index: 85
67Lambdaparameter: 85
body: 72
68Operationoperator: 74
operands: 73
69Variable
70Variable
71ExprTuple85
72Operationoperator: 74
operands: 75
73NamedExprselement: 76
targets: 78
74Literal
75NamedExprselement: 77
targets: 78
76Operationoperator: 79
operands: 81
77Operationoperator: 80
operands: 81
78Operationoperator: 82
operands: 83
79Literal
80Literal
81NamedExprsstate: 84
part: 85
82Literal
83ExprTuple86, 87
84Variable
85Variable
86Literal
87Variable