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__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_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), 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{
\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] \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: 106
body: 10
7Operationoperator: 18
operands: 11
8Operationoperator: 18
operands: 12
9ExprTuple106
10Conditionalvalue: 13
condition: 14
11ExprTuple102, 15
12ExprTuple105, 15
13Operationoperator: 16
operand: 21
14Operationoperator: 18
operands: 19
15Operationoperator: 26
operands: 20
16Literal
17ExprTuple21
18Literal
19ExprTuple106, 22
20ExprTuple32, 23
21Lambdaparameters: 24
body: 25
22Operationoperator: 26
operands: 27
23Operationoperator: 37
operands: 28
24ExprTuple29
25Operationoperator: 30
operands: 31
26Literal
27ExprTuple32, 33
28ExprTuple42, 114
29ExprRangelambda_map: 34
start_index: 113
end_index: 58
30Literal
31ExprTuple35, 36
32Literal
33Operationoperator: 37
operands: 38
34Lambdaparameter: 103
body: 70
35Operationoperator: 40
operand: 43
36Operationoperator: 40
operand: 44
37Literal
38ExprTuple42, 115
39ExprTuple43
40Literal
41ExprTuple44
42Literal
43Operationoperator: 46
operands: 45
44Operationoperator: 46
operands: 47
45ExprTuple48, 49, 50
46Literal
47ExprTuple51, 52, 53
48ExprTuple55
49ExprRangelambda_map: 54
start_index: 113
end_index: 58
50ExprTuple59
51ExprTuple55, 56
52ExprRangelambda_map: 57
start_index: 113
end_index: 58
53ExprTuple59, 60
54Lambdaparameter: 103
body: 61
55ExprRangelambda_map: 62
start_index: 113
end_index: 114
56ExprRangelambda_map: 63
start_index: 113
end_index: 115
57Lambdaparameter: 103
body: 65
58Variable
59ExprRangelambda_map: 66
start_index: 113
end_index: 114
60ExprRangelambda_map: 67
start_index: 113
end_index: 115
61ExprTuple70
62Lambdaparameter: 107
body: 68
63Lambdaparameter: 107
body: 69
64ExprTuple103
65ExprTuple70, 71
66Lambdaparameter: 107
body: 72
67Lambdaparameter: 107
body: 73
68Operationoperator: 79
operands: 74
69Operationoperator: 79
operands: 75
70ExprRangelambda_map: 76
start_index: 113
end_index: 114
71ExprRangelambda_map: 77
start_index: 113
end_index: 115
72Operationoperator: 79
operands: 78
73Operationoperator: 79
operands: 80
74NamedExprselement: 81
targets: 87
75NamedExprselement: 82
targets: 89
76Lambdaparameter: 107
body: 83
77Lambdaparameter: 107
body: 85
78NamedExprselement: 86
targets: 87
79Literal
80NamedExprselement: 88
targets: 89
81Operationoperator: 91
operands: 90
82Operationoperator: 91
operands: 99
83IndexedVarvariable: 92
indices: 93
84ExprTuple107
85Operationoperator: 94
operands: 95
86Operationoperator: 98
operands: 96
87Operationoperator: 100
operands: 97
88Operationoperator: 98
operands: 99
89Operationoperator: 100
operands: 101
90NamedExprsstate: 102
part: 107
91Literal
92Variable
93ExprTuple103, 107
94Literal
95NamedExprsoperation: 104
96NamedExprsstate: 105
part: 107
97ExprTuple113, 114
98Literal
99NamedExprsstate: 106
part: 107
100Literal
101ExprTuple108, 109
102Variable
103Variable
104Literal
105Variable
106Variable
107Variable
108Operationoperator: 111
operands: 110
109Operationoperator: 111
operands: 112
110ExprTuple114, 113
111Literal
112ExprTuple114, 115
113Literal
114Variable
115Variable