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__psi_m__u_Akl_v, circuit__u_Akl_v
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__psi_m__u_Akl_v)).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{
\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]\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
2ExprTuple77, 142, 141
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
12ExprTuple129, 133
13Conditionalvalue: 17
condition: 18
14ExprTuple77, 19
15ExprTuple142, 19
16ExprTuple141, 19
17Operationoperator: 33
operand: 23
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23
21Literal
22ExprTuple24, 25
23Lambdaparameter: 132
body: 27
24Operationoperator: 35
operands: 28
25Operationoperator: 35
operands: 29
26ExprTuple132
27Conditionalvalue: 30
condition: 31
28ExprTuple129, 32
29ExprTuple133, 32
30Operationoperator: 33
operand: 38
31Operationoperator: 35
operands: 36
32Operationoperator: 43
operands: 37
33Literal
34ExprTuple38
35Literal
36ExprTuple132, 39
37ExprTuple49, 40
38Lambdaparameters: 41
body: 42
39Operationoperator: 43
operands: 44
40Operationoperator: 54
operands: 45
41ExprTuple46
42Operationoperator: 47
operands: 48
43Literal
44ExprTuple49, 50
45ExprTuple59, 142
46ExprRangelambda_map: 51
start_index: 140
end_index: 77
47Literal
48ExprTuple52, 53
49Literal
50Operationoperator: 54
operands: 55
51Lambdaparameter: 131
body: 94
52Operationoperator: 57
operand: 60
53Operationoperator: 57
operand: 61
54Literal
55ExprTuple59, 141
56ExprTuple60
57Literal
58ExprTuple61
59Literal
60Operationoperator: 63
operands: 62
61Operationoperator: 63
operands: 64
62ExprTuple65, 66, 67
63Literal
64ExprTuple68, 69, 70
65ExprTuple71
66ExprRangelambda_map: 72
start_index: 140
end_index: 77
67ExprTuple73
68ExprTuple74, 75
69ExprRangelambda_map: 76
start_index: 140
end_index: 77
70ExprTuple78, 79
71ExprRangelambda_map: 80
start_index: 140
end_index: 142
72Lambdaparameter: 131
body: 81
73ExprRangelambda_map: 82
start_index: 140
end_index: 142
74ExprRangelambda_map: 83
start_index: 140
end_index: 141
75ExprRangelambda_map: 84
start_index: 140
end_index: 142
76Lambdaparameter: 131
body: 86
77Variable
78ExprRangelambda_map: 87
start_index: 140
end_index: 141
79ExprRangelambda_map: 88
start_index: 140
end_index: 142
80Lambdaparameter: 134
body: 89
81ExprTuple94
82Lambdaparameter: 134
body: 90
83Lambdaparameter: 134
body: 91
84Lambdaparameter: 134
body: 92
85ExprTuple131
86ExprTuple93, 94
87Lambdaparameter: 134
body: 95
88Lambdaparameter: 134
body: 96
89Operationoperator: 104
operands: 97
90Operationoperator: 104
operands: 98
91Operationoperator: 104
operands: 99
92Operationoperator: 104
operands: 100
93ExprRangelambda_map: 101
start_index: 140
end_index: 141
94ExprRangelambda_map: 102
start_index: 140
end_index: 142
95Operationoperator: 104
operands: 103
96Operationoperator: 104
operands: 105
97NamedExprselement: 108
targets: 106
98NamedExprselement: 114
targets: 106
99NamedExprselement: 107
targets: 113
100NamedExprselement: 108
targets: 115
101Lambdaparameter: 134
body: 109
102Lambdaparameter: 134
body: 111
103NamedExprselement: 112
targets: 113
104Literal
105NamedExprselement: 114
targets: 115
106Operationoperator: 127
operands: 116
107Operationoperator: 117
operands: 123
108Operationoperator: 117
operands: 118
109Operationoperator: 119
operands: 120
110ExprTuple134
111IndexedVarvariable: 121
indices: 122
112Operationoperator: 125
operands: 123
113Operationoperator: 127
operands: 124
114Operationoperator: 125
operands: 126
115Operationoperator: 127
operands: 128
116ExprTuple140, 142
117Literal
118NamedExprsstate: 129
part: 134
119Literal
120NamedExprsoperation: 130
121Variable
122ExprTuple131, 134
123NamedExprsstate: 132
part: 134
124ExprTuple140, 141
125Literal
126NamedExprsstate: 133
part: 134
127Literal
128ExprTuple135, 136
129Variable
130Literal
131Variable
132Variable
133Variable
134Variable
135Operationoperator: 138
operands: 137
136Operationoperator: 138
operands: 139
137ExprTuple141, 140
138Literal
139ExprTuple141, 142
140Literal
141Variable
142Variable