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
from proveit.core_expr_types.expr_arrays import A11_to_Akl
from proveit.logic import And, Equals, Forall, InSet
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_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), And(InSet(var_ket_u, l_ket_domain), InSet(var_ket_v, l_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\{\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] \textrm{ if } \lvert u \rangle \in \mathbb{C}^{2^{l}} ,  \lvert v \rangle \in \mathbb{C}^{2^{l}}\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: 16
operand: 6
2Operationoperator: 4
operands: 5
3ExprTuple6
4Literal
5ExprTuple7, 8
6Lambdaparameter: 115
body: 10
7Operationoperator: 18
operands: 11
8Operationoperator: 18
operands: 12
9ExprTuple115
10Conditionalvalue: 13
condition: 14
11ExprTuple112, 15
12ExprTuple116, 15
13Operationoperator: 16
operand: 21
14Operationoperator: 18
operands: 19
15Operationoperator: 26
operands: 20
16Literal
17ExprTuple21
18Literal
19ExprTuple115, 22
20ExprTuple32, 23
21Lambdaparameters: 24
body: 25
22Operationoperator: 26
operands: 27
23Operationoperator: 37
operands: 28
24ExprTuple29
25Operationoperator: 30
operands: 31
26Literal
27ExprTuple32, 33
28ExprTuple42, 125
29ExprRangelambda_map: 34
start_index: 123
end_index: 60
30Literal
31ExprTuple35, 36
32Literal
33Operationoperator: 37
operands: 38
34Lambdaparameter: 114
body: 77
35Operationoperator: 40
operand: 43
36Operationoperator: 40
operand: 44
37Literal
38ExprTuple42, 124
39ExprTuple43
40Literal
41ExprTuple44
42Literal
43Operationoperator: 46
operands: 45
44Operationoperator: 46
operands: 47
45ExprTuple48, 49, 50
46Literal
47ExprTuple51, 52, 53
48ExprTuple54
49ExprRangelambda_map: 55
start_index: 123
end_index: 60
50ExprTuple56
51ExprTuple57, 58
52ExprRangelambda_map: 59
start_index: 123
end_index: 60
53ExprTuple61, 62
54ExprRangelambda_map: 63
start_index: 123
end_index: 125
55Lambdaparameter: 114
body: 64
56ExprRangelambda_map: 65
start_index: 123
end_index: 125
57ExprRangelambda_map: 66
start_index: 123
end_index: 124
58ExprRangelambda_map: 67
start_index: 123
end_index: 125
59Lambdaparameter: 114
body: 69
60Variable
61ExprRangelambda_map: 70
start_index: 123
end_index: 124
62ExprRangelambda_map: 71
start_index: 123
end_index: 125
63Lambdaparameter: 117
body: 72
64ExprTuple77
65Lambdaparameter: 117
body: 73
66Lambdaparameter: 117
body: 74
67Lambdaparameter: 117
body: 75
68ExprTuple114
69ExprTuple76, 77
70Lambdaparameter: 117
body: 78
71Lambdaparameter: 117
body: 79
72Operationoperator: 87
operands: 80
73Operationoperator: 87
operands: 81
74Operationoperator: 87
operands: 82
75Operationoperator: 87
operands: 83
76ExprRangelambda_map: 84
start_index: 123
end_index: 124
77ExprRangelambda_map: 85
start_index: 123
end_index: 125
78Operationoperator: 87
operands: 86
79Operationoperator: 87
operands: 88
80NamedExprselement: 91
targets: 89
81NamedExprselement: 97
targets: 89
82NamedExprselement: 90
targets: 96
83NamedExprselement: 91
targets: 98
84Lambdaparameter: 117
body: 92
85Lambdaparameter: 117
body: 94
86NamedExprselement: 95
targets: 96
87Literal
88NamedExprselement: 97
targets: 98
89Operationoperator: 110
operands: 99
90Operationoperator: 100
operands: 106
91Operationoperator: 100
operands: 101
92Operationoperator: 102
operands: 103
93ExprTuple117
94IndexedVarvariable: 104
indices: 105
95Operationoperator: 108
operands: 106
96Operationoperator: 110
operands: 107
97Operationoperator: 108
operands: 109
98Operationoperator: 110
operands: 111
99ExprTuple123, 125
100Literal
101NamedExprsstate: 112
part: 117
102Literal
103NamedExprsoperation: 113
104Variable
105ExprTuple114, 117
106NamedExprsstate: 115
part: 117
107ExprTuple123, 124
108Literal
109NamedExprsstate: 116
part: 117
110Literal
111ExprTuple118, 119
112Variable
113Literal
114Variable
115Variable
116Variable
117Variable
118Operationoperator: 121
operands: 120
119Operationoperator: 121
operands: 122
120ExprTuple124, 123
121Literal
122ExprTuple124, 125
123Literal
124Variable
125Variable