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, k, l, m
from proveit.core_expr_types.expr_arrays import A11_to_Akl
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import NaturalPos
from proveit.physics.quantum import l_ket_domain, m_ket_domain, var_ket_psi, var_ket_u, var_ket_v
from proveit.physics.quantum.circuits import circuit__u_Akl_v, circuit__u_Akl_v__psi_m
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [var_ket_u, var_ket_v], instance_expr = Forall(instance_param_or_params = [var_ket_psi], instance_expr = Forall(instance_param_or_params = [A11_to_Akl], instance_expr = Equals(Prob(circuit__u_Akl_v), Prob(circuit__u_Akl_v__psi_m)).with_wrapping_at(2)).with_wrapping(), domain = m_ket_domain), domain = l_ket_domain), And(InSet(k, NaturalPos), InSet(l, 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\{\forall_{\lvert u \rangle, \lvert v \rangle \in \mathbb{C}^{2^{l}}}~\left[\forall_{\lvert \psi \rangle \in \mathbb{C}^{2^{m}}}~\left[\begin{array}{l}\forall_{A_{1, 1}, A_{1, 2}, \ldots, A_{1, l}, A_{2, 1}, A_{2, 2}, \ldots, A_{2, l}, \ldots\ldots, A_{k, 1}, A_{k, 2}, \ldots, A_{k, l}}~\\
\left(\begin{array}{c} \begin{array}{l} \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\multiqin{3}{\lvert u \rangle} & \gate{A_{1, 1}} \qwx[1] & \gate{A_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 1}} \qwx[1] & \multiqout{3}{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{A_{1, 2}} \qwx[1] & \gate{A_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 2}} \qwx[1] & \ghostqout{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \ghostqout{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{A_{1, l}} & \gate{A_{2, l}} & \gate{\cdots} & \gate{A_{k, l}} & \ghostqout{\lvert v \rangle}
} \end{array}\right) =  \\ \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\multiqin{3}{\lvert u \rangle} & \gate{A_{1, 1}} \qwx[1] & \gate{A_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 1}} \qwx[1] & \multiqout{3}{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{A_{1, 2}} \qwx[1] & \gate{A_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 2}} \qwx[1] & \ghostqout{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \ghostqout{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{A_{1, l}} & \gate{A_{2, l}} & \gate{\cdots} & \gate{A_{k, l}} & \ghostqout{\lvert v \rangle} \\
\qin{\lvert \psi \rangle} & { /^{m} } \qw & { /^{m} } \qw & \gate{\cdots} & { /^{m} } \qw & \qout{\lvert \psi \rangle}
} \end{array}\right) \end{array} \end{array}\right)\end{array}\right]\right] \textrm{ if } k \in \mathbb{N}^+ ,  l \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: 30
operand: 5
2Operationoperator: 18
operands: 4
3ExprTuple5
4ExprTuple6, 7, 8
5Lambdaparameters: 9
body: 10
6Operationoperator: 32
operands: 11
7Operationoperator: 32
operands: 12
8Operationoperator: 32
operands: 13
9ExprTuple116, 119
10Conditionalvalue: 14
condition: 15
11ExprTuple72, 16
12ExprTuple128, 16
13ExprTuple129, 16
14Operationoperator: 30
operand: 20
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20
18Literal
19ExprTuple21, 22
20Lambdaparameter: 120
body: 24
21Operationoperator: 32
operands: 25
22Operationoperator: 32
operands: 26
23ExprTuple120
24Conditionalvalue: 27
condition: 28
25ExprTuple116, 29
26ExprTuple119, 29
27Operationoperator: 30
operand: 35
28Operationoperator: 32
operands: 33
29Operationoperator: 40
operands: 34
30Literal
31ExprTuple35
32Literal
33ExprTuple120, 36
34ExprTuple46, 37
35Lambdaparameters: 38
body: 39
36Operationoperator: 40
operands: 41
37Operationoperator: 51
operands: 42
38ExprTuple43
39Operationoperator: 44
operands: 45
40Literal
41ExprTuple46, 47
42ExprTuple56, 128
43ExprRangelambda_map: 48
start_index: 127
end_index: 72
44Literal
45ExprTuple49, 50
46Literal
47Operationoperator: 51
operands: 52
48Lambdaparameter: 117
body: 84
49Operationoperator: 54
operand: 57
50Operationoperator: 54
operand: 58
51Literal
52ExprTuple56, 129
53ExprTuple57
54Literal
55ExprTuple58
56Literal
57Operationoperator: 60
operands: 59
58Operationoperator: 60
operands: 61
59ExprTuple62, 63, 64
60Literal
61ExprTuple65, 66, 67
62ExprTuple69
63ExprRangelambda_map: 68
start_index: 127
end_index: 72
64ExprTuple73
65ExprTuple69, 70
66ExprRangelambda_map: 71
start_index: 127
end_index: 72
67ExprTuple73, 74
68Lambdaparameter: 117
body: 75
69ExprRangelambda_map: 76
start_index: 127
end_index: 128
70ExprRangelambda_map: 77
start_index: 127
end_index: 129
71Lambdaparameter: 117
body: 79
72Variable
73ExprRangelambda_map: 80
start_index: 127
end_index: 128
74ExprRangelambda_map: 81
start_index: 127
end_index: 129
75ExprTuple84
76Lambdaparameter: 121
body: 82
77Lambdaparameter: 121
body: 83
78ExprTuple117
79ExprTuple84, 85
80Lambdaparameter: 121
body: 86
81Lambdaparameter: 121
body: 87
82Operationoperator: 93
operands: 88
83Operationoperator: 93
operands: 89
84ExprRangelambda_map: 90
start_index: 127
end_index: 128
85ExprRangelambda_map: 91
start_index: 127
end_index: 129
86Operationoperator: 93
operands: 92
87Operationoperator: 93
operands: 94
88NamedExprselement: 95
targets: 101
89NamedExprselement: 96
targets: 103
90Lambdaparameter: 121
body: 97
91Lambdaparameter: 121
body: 99
92NamedExprselement: 100
targets: 101
93Literal
94NamedExprselement: 102
targets: 103
95Operationoperator: 105
operands: 104
96Operationoperator: 105
operands: 113
97IndexedVarvariable: 106
indices: 107
98ExprTuple121
99Operationoperator: 108
operands: 109
100Operationoperator: 112
operands: 110
101Operationoperator: 114
operands: 111
102Operationoperator: 112
operands: 113
103Operationoperator: 114
operands: 115
104NamedExprsstate: 116
part: 121
105Literal
106Variable
107ExprTuple117, 121
108Literal
109NamedExprsoperation: 118
110NamedExprsstate: 119
part: 121
111ExprTuple127, 128
112Literal
113NamedExprsstate: 120
part: 121
114Literal
115ExprTuple122, 123
116Variable
117Variable
118Literal
119Variable
120Variable
121Variable
122Operationoperator: 125
operands: 124
123Operationoperator: 125
operands: 126
124ExprTuple128, 127
125Literal
126ExprTuple128, 129
127Literal
128Variable
129Variable