logo

Expression of type ExprTuple

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, ExprTuple, Lambda, 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__u_Akl_v, circuit__u_Akl_v__psi_m
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([k, l, m], 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__u_Akl_v__psi_m)).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(\left(k, l, m\right) \mapsto \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{
\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]\right] \textrm{ if } k \in \mathbb{N}^+ ,  l \in \mathbb{N}^+ ,  m \in \mathbb{N}^+\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple75, 131, 132
3Conditionalvalue: 4
condition: 5
4Operationoperator: 33
operand: 8
5Operationoperator: 21
operands: 7
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameters: 12
body: 13
9Operationoperator: 35
operands: 14
10Operationoperator: 35
operands: 15
11Operationoperator: 35
operands: 16
12ExprTuple119, 122
13Conditionalvalue: 17
condition: 18
14ExprTuple75, 19
15ExprTuple131, 19
16ExprTuple132, 19
17Operationoperator: 33
operand: 23
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23
21Literal
22ExprTuple24, 25
23Lambdaparameter: 123
body: 27
24Operationoperator: 35
operands: 28
25Operationoperator: 35
operands: 29
26ExprTuple123
27Conditionalvalue: 30
condition: 31
28ExprTuple119, 32
29ExprTuple122, 32
30Operationoperator: 33
operand: 38
31Operationoperator: 35
operands: 36
32Operationoperator: 43
operands: 37
33Literal
34ExprTuple38
35Literal
36ExprTuple123, 39
37ExprTuple49, 40
38Lambdaparameters: 41
body: 42
39Operationoperator: 43
operands: 44
40Operationoperator: 54
operands: 45
41ExprTuple46
42Operationoperator: 47
operands: 48
43Literal
44ExprTuple49, 50
45ExprTuple59, 131
46ExprRangelambda_map: 51
start_index: 130
end_index: 75
47Literal
48ExprTuple52, 53
49Literal
50Operationoperator: 54
operands: 55
51Lambdaparameter: 120
body: 87
52Operationoperator: 57
operand: 60
53Operationoperator: 57
operand: 61
54Literal
55ExprTuple59, 132
56ExprTuple60
57Literal
58ExprTuple61
59Literal
60Operationoperator: 63
operands: 62
61Operationoperator: 63
operands: 64
62ExprTuple65, 66, 67
63Literal
64ExprTuple68, 69, 70
65ExprTuple72
66ExprRangelambda_map: 71
start_index: 130
end_index: 75
67ExprTuple76
68ExprTuple72, 73
69ExprRangelambda_map: 74
start_index: 130
end_index: 75
70ExprTuple76, 77
71Lambdaparameter: 120
body: 78
72ExprRangelambda_map: 79
start_index: 130
end_index: 131
73ExprRangelambda_map: 80
start_index: 130
end_index: 132
74Lambdaparameter: 120
body: 82
75Variable
76ExprRangelambda_map: 83
start_index: 130
end_index: 131
77ExprRangelambda_map: 84
start_index: 130
end_index: 132
78ExprTuple87
79Lambdaparameter: 124
body: 85
80Lambdaparameter: 124
body: 86
81ExprTuple120
82ExprTuple87, 88
83Lambdaparameter: 124
body: 89
84Lambdaparameter: 124
body: 90
85Operationoperator: 96
operands: 91
86Operationoperator: 96
operands: 92
87ExprRangelambda_map: 93
start_index: 130
end_index: 131
88ExprRangelambda_map: 94
start_index: 130
end_index: 132
89Operationoperator: 96
operands: 95
90Operationoperator: 96
operands: 97
91NamedExprselement: 98
targets: 104
92NamedExprselement: 99
targets: 106
93Lambdaparameter: 124
body: 100
94Lambdaparameter: 124
body: 102
95NamedExprselement: 103
targets: 104
96Literal
97NamedExprselement: 105
targets: 106
98Operationoperator: 108
operands: 107
99Operationoperator: 108
operands: 116
100IndexedVarvariable: 109
indices: 110
101ExprTuple124
102Operationoperator: 111
operands: 112
103Operationoperator: 115
operands: 113
104Operationoperator: 117
operands: 114
105Operationoperator: 115
operands: 116
106Operationoperator: 117
operands: 118
107NamedExprsstate: 119
part: 124
108Literal
109Variable
110ExprTuple120, 124
111Literal
112NamedExprsoperation: 121
113NamedExprsstate: 122
part: 124
114ExprTuple130, 131
115Literal
116NamedExprsstate: 123
part: 124
117Literal
118ExprTuple125, 126
119Variable
120Variable
121Literal
122Variable
123Variable
124Variable
125Operationoperator: 128
operands: 127
126Operationoperator: 128
operands: 129
127ExprTuple131, 130
128Literal
129ExprTuple131, 132
130Literal
131Variable
132Variable