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 Equals, Forall, InSet
from proveit.physics.quantum import m_ket_domain, var_ket_psi
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 = [A11_to_Akl], instance_expr = Equals(Prob(circuit__u_Akl_v), Prob(circuit__psi_m__u_Akl_v)).with_wrapping_at(2)).with_wrapping(), InSet(var_ket_psi, m_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\{\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} \textrm{ if } \lvert \psi \rangle \in \mathbb{C}^{2^{m}}\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: 3
operand: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple99, 8
7Lambdaparameters: 9
body: 10
8Operationoperator: 11
operands: 12
9ExprTuple13
10Operationoperator: 14
operands: 15
11Literal
12ExprTuple16, 17
13ExprRangelambda_map: 18
start_index: 107
end_index: 44
14Literal
15ExprTuple19, 20
16Literal
17Operationoperator: 21
operands: 22
18Lambdaparameter: 98
body: 61
19Operationoperator: 24
operand: 27
20Operationoperator: 24
operand: 28
21Literal
22ExprTuple26, 108
23ExprTuple27
24Literal
25ExprTuple28
26Literal
27Operationoperator: 30
operands: 29
28Operationoperator: 30
operands: 31
29ExprTuple32, 33, 34
30Literal
31ExprTuple35, 36, 37
32ExprTuple38
33ExprRangelambda_map: 39
start_index: 107
end_index: 44
34ExprTuple40
35ExprTuple41, 42
36ExprRangelambda_map: 43
start_index: 107
end_index: 44
37ExprTuple45, 46
38ExprRangelambda_map: 47
start_index: 107
end_index: 109
39Lambdaparameter: 98
body: 48
40ExprRangelambda_map: 49
start_index: 107
end_index: 109
41ExprRangelambda_map: 50
start_index: 107
end_index: 108
42ExprRangelambda_map: 51
start_index: 107
end_index: 109
43Lambdaparameter: 98
body: 53
44Variable
45ExprRangelambda_map: 54
start_index: 107
end_index: 108
46ExprRangelambda_map: 55
start_index: 107
end_index: 109
47Lambdaparameter: 101
body: 56
48ExprTuple61
49Lambdaparameter: 101
body: 57
50Lambdaparameter: 101
body: 58
51Lambdaparameter: 101
body: 59
52ExprTuple98
53ExprTuple60, 61
54Lambdaparameter: 101
body: 62
55Lambdaparameter: 101
body: 63
56Operationoperator: 71
operands: 64
57Operationoperator: 71
operands: 65
58Operationoperator: 71
operands: 66
59Operationoperator: 71
operands: 67
60ExprRangelambda_map: 68
start_index: 107
end_index: 108
61ExprRangelambda_map: 69
start_index: 107
end_index: 109
62Operationoperator: 71
operands: 70
63Operationoperator: 71
operands: 72
64NamedExprselement: 75
targets: 73
65NamedExprselement: 81
targets: 73
66NamedExprselement: 74
targets: 80
67NamedExprselement: 75
targets: 82
68Lambdaparameter: 101
body: 76
69Lambdaparameter: 101
body: 78
70NamedExprselement: 79
targets: 80
71Literal
72NamedExprselement: 81
targets: 82
73Operationoperator: 94
operands: 83
74Operationoperator: 84
operands: 90
75Operationoperator: 84
operands: 85
76Operationoperator: 86
operands: 87
77ExprTuple101
78IndexedVarvariable: 88
indices: 89
79Operationoperator: 92
operands: 90
80Operationoperator: 94
operands: 91
81Operationoperator: 92
operands: 93
82Operationoperator: 94
operands: 95
83ExprTuple107, 109
84Literal
85NamedExprsstate: 96
part: 101
86Literal
87NamedExprsoperation: 97
88Variable
89ExprTuple98, 101
90NamedExprsstate: 99
part: 101
91ExprTuple107, 108
92Literal
93NamedExprsstate: 100
part: 101
94Literal
95ExprTuple102, 103
96Variable
97Literal
98Variable
99Variable
100Variable
101Variable
102Operationoperator: 105
operands: 104
103Operationoperator: 105
operands: 106
104ExprTuple108, 107
105Literal
106ExprTuple108, 109
107Literal
108Variable
109Variable