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__psi_m__u_Akl_v, circuit__u_Akl_v
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__psi_m__u_Akl_v)).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{
\qin{\lvert \psi \rangle} & { /^{m} } \qw & { /^{m} } \qw & \gate{\cdots} & { /^{m} } \qw & \qout{\lvert \psi \rangle} \\
\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) \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
9ExprTuple126, 130
10Conditionalvalue: 14
condition: 15
11ExprTuple74, 16
12ExprTuple139, 16
13ExprTuple138, 16
14Operationoperator: 30
operand: 20
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20
18Literal
19ExprTuple21, 22
20Lambdaparameter: 129
body: 24
21Operationoperator: 32
operands: 25
22Operationoperator: 32
operands: 26
23ExprTuple129
24Conditionalvalue: 27
condition: 28
25ExprTuple126, 29
26ExprTuple130, 29
27Operationoperator: 30
operand: 35
28Operationoperator: 32
operands: 33
29Operationoperator: 40
operands: 34
30Literal
31ExprTuple35
32Literal
33ExprTuple129, 36
34ExprTuple46, 37
35Lambdaparameters: 38
body: 39
36Operationoperator: 40
operands: 41
37Operationoperator: 51
operands: 42
38ExprTuple43
39Operationoperator: 44
operands: 45
40Literal
41ExprTuple46, 47
42ExprTuple56, 139
43ExprRangelambda_map: 48
start_index: 137
end_index: 74
44Literal
45ExprTuple49, 50
46Literal
47Operationoperator: 51
operands: 52
48Lambdaparameter: 128
body: 91
49Operationoperator: 54
operand: 57
50Operationoperator: 54
operand: 58
51Literal
52ExprTuple56, 138
53ExprTuple57
54Literal
55ExprTuple58
56Literal
57Operationoperator: 60
operands: 59
58Operationoperator: 60
operands: 61
59ExprTuple62, 63, 64
60Literal
61ExprTuple65, 66, 67
62ExprTuple68
63ExprRangelambda_map: 69
start_index: 137
end_index: 74
64ExprTuple70
65ExprTuple71, 72
66ExprRangelambda_map: 73
start_index: 137
end_index: 74
67ExprTuple75, 76
68ExprRangelambda_map: 77
start_index: 137
end_index: 139
69Lambdaparameter: 128
body: 78
70ExprRangelambda_map: 79
start_index: 137
end_index: 139
71ExprRangelambda_map: 80
start_index: 137
end_index: 138
72ExprRangelambda_map: 81
start_index: 137
end_index: 139
73Lambdaparameter: 128
body: 83
74Variable
75ExprRangelambda_map: 84
start_index: 137
end_index: 138
76ExprRangelambda_map: 85
start_index: 137
end_index: 139
77Lambdaparameter: 131
body: 86
78ExprTuple91
79Lambdaparameter: 131
body: 87
80Lambdaparameter: 131
body: 88
81Lambdaparameter: 131
body: 89
82ExprTuple128
83ExprTuple90, 91
84Lambdaparameter: 131
body: 92
85Lambdaparameter: 131
body: 93
86Operationoperator: 101
operands: 94
87Operationoperator: 101
operands: 95
88Operationoperator: 101
operands: 96
89Operationoperator: 101
operands: 97
90ExprRangelambda_map: 98
start_index: 137
end_index: 138
91ExprRangelambda_map: 99
start_index: 137
end_index: 139
92Operationoperator: 101
operands: 100
93Operationoperator: 101
operands: 102
94NamedExprselement: 105
targets: 103
95NamedExprselement: 111
targets: 103
96NamedExprselement: 104
targets: 110
97NamedExprselement: 105
targets: 112
98Lambdaparameter: 131
body: 106
99Lambdaparameter: 131
body: 108
100NamedExprselement: 109
targets: 110
101Literal
102NamedExprselement: 111
targets: 112
103Operationoperator: 124
operands: 113
104Operationoperator: 114
operands: 120
105Operationoperator: 114
operands: 115
106Operationoperator: 116
operands: 117
107ExprTuple131
108IndexedVarvariable: 118
indices: 119
109Operationoperator: 122
operands: 120
110Operationoperator: 124
operands: 121
111Operationoperator: 122
operands: 123
112Operationoperator: 124
operands: 125
113ExprTuple137, 139
114Literal
115NamedExprsstate: 126
part: 131
116Literal
117NamedExprsoperation: 127
118Variable
119ExprTuple128, 131
120NamedExprsstate: 129
part: 131
121ExprTuple137, 138
122Literal
123NamedExprsstate: 130
part: 131
124Literal
125ExprTuple132, 133
126Variable
127Literal
128Variable
129Variable
130Variable
131Variable
132Operationoperator: 135
operands: 134
133Operationoperator: 135
operands: 136
134ExprTuple138, 137
135Literal
136ExprTuple138, 139
137Literal
138Variable
139Variable