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__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 = [A11_to_Akl], instance_expr = Equals(Prob(circuit__u_Akl_v), Prob(circuit__u_Akl_v__psi_m)).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{
\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} \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
6ExprTuple90, 8
7Lambdaparameters: 9
body: 10
8Operationoperator: 11
operands: 12
9ExprTuple13
10Operationoperator: 14
operands: 15
11Literal
12ExprTuple16, 17
13ExprRangelambda_map: 18
start_index: 97
end_index: 42
14Literal
15ExprTuple19, 20
16Literal
17Operationoperator: 21
operands: 22
18Lambdaparameter: 87
body: 54
19Operationoperator: 24
operand: 27
20Operationoperator: 24
operand: 28
21Literal
22ExprTuple26, 99
23ExprTuple27
24Literal
25ExprTuple28
26Literal
27Operationoperator: 30
operands: 29
28Operationoperator: 30
operands: 31
29ExprTuple32, 33, 34
30Literal
31ExprTuple35, 36, 37
32ExprTuple39
33ExprRangelambda_map: 38
start_index: 97
end_index: 42
34ExprTuple43
35ExprTuple39, 40
36ExprRangelambda_map: 41
start_index: 97
end_index: 42
37ExprTuple43, 44
38Lambdaparameter: 87
body: 45
39ExprRangelambda_map: 46
start_index: 97
end_index: 98
40ExprRangelambda_map: 47
start_index: 97
end_index: 99
41Lambdaparameter: 87
body: 49
42Variable
43ExprRangelambda_map: 50
start_index: 97
end_index: 98
44ExprRangelambda_map: 51
start_index: 97
end_index: 99
45ExprTuple54
46Lambdaparameter: 91
body: 52
47Lambdaparameter: 91
body: 53
48ExprTuple87
49ExprTuple54, 55
50Lambdaparameter: 91
body: 56
51Lambdaparameter: 91
body: 57
52Operationoperator: 63
operands: 58
53Operationoperator: 63
operands: 59
54ExprRangelambda_map: 60
start_index: 97
end_index: 98
55ExprRangelambda_map: 61
start_index: 97
end_index: 99
56Operationoperator: 63
operands: 62
57Operationoperator: 63
operands: 64
58NamedExprselement: 65
targets: 71
59NamedExprselement: 66
targets: 73
60Lambdaparameter: 91
body: 67
61Lambdaparameter: 91
body: 69
62NamedExprselement: 70
targets: 71
63Literal
64NamedExprselement: 72
targets: 73
65Operationoperator: 75
operands: 74
66Operationoperator: 75
operands: 83
67IndexedVarvariable: 76
indices: 77
68ExprTuple91
69Operationoperator: 78
operands: 79
70Operationoperator: 82
operands: 80
71Operationoperator: 84
operands: 81
72Operationoperator: 82
operands: 83
73Operationoperator: 84
operands: 85
74NamedExprsstate: 86
part: 91
75Literal
76Variable
77ExprTuple87, 91
78Literal
79NamedExprsoperation: 88
80NamedExprsstate: 89
part: 91
81ExprTuple97, 98
82Literal
83NamedExprsstate: 90
part: 91
84Literal
85ExprTuple92, 93
86Variable
87Variable
88Literal
89Variable
90Variable
91Variable
92Operationoperator: 95
operands: 94
93Operationoperator: 95
operands: 96
94ExprTuple98, 97
95Literal
96ExprTuple98, 99
97Literal
98Variable
99Variable