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
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__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([var_ket_u, var_ket_v], 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__psi_m__u_Akl_v)).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(\left(\lvert u \rangle, \lvert v \rangle\right) \mapsto \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] \textrm{ if } \lvert u \rangle \in \mathbb{C}^{2^{l}} ,  \lvert v \rangle \in \mathbb{C}^{2^{l}}\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
2ExprTuple115, 119
3Conditionalvalue: 4
condition: 5
4Operationoperator: 19
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 118
body: 13
10Operationoperator: 21
operands: 14
11Operationoperator: 21
operands: 15
12ExprTuple118
13Conditionalvalue: 16
condition: 17
14ExprTuple115, 18
15ExprTuple119, 18
16Operationoperator: 19
operand: 24
17Operationoperator: 21
operands: 22
18Operationoperator: 29
operands: 23
19Literal
20ExprTuple24
21Literal
22ExprTuple118, 25
23ExprTuple35, 26
24Lambdaparameters: 27
body: 28
25Operationoperator: 29
operands: 30
26Operationoperator: 40
operands: 31
27ExprTuple32
28Operationoperator: 33
operands: 34
29Literal
30ExprTuple35, 36
31ExprTuple45, 128
32ExprRangelambda_map: 37
start_index: 126
end_index: 63
33Literal
34ExprTuple38, 39
35Literal
36Operationoperator: 40
operands: 41
37Lambdaparameter: 117
body: 80
38Operationoperator: 43
operand: 46
39Operationoperator: 43
operand: 47
40Literal
41ExprTuple45, 127
42ExprTuple46
43Literal
44ExprTuple47
45Literal
46Operationoperator: 49
operands: 48
47Operationoperator: 49
operands: 50
48ExprTuple51, 52, 53
49Literal
50ExprTuple54, 55, 56
51ExprTuple57
52ExprRangelambda_map: 58
start_index: 126
end_index: 63
53ExprTuple59
54ExprTuple60, 61
55ExprRangelambda_map: 62
start_index: 126
end_index: 63
56ExprTuple64, 65
57ExprRangelambda_map: 66
start_index: 126
end_index: 128
58Lambdaparameter: 117
body: 67
59ExprRangelambda_map: 68
start_index: 126
end_index: 128
60ExprRangelambda_map: 69
start_index: 126
end_index: 127
61ExprRangelambda_map: 70
start_index: 126
end_index: 128
62Lambdaparameter: 117
body: 72
63Variable
64ExprRangelambda_map: 73
start_index: 126
end_index: 127
65ExprRangelambda_map: 74
start_index: 126
end_index: 128
66Lambdaparameter: 120
body: 75
67ExprTuple80
68Lambdaparameter: 120
body: 76
69Lambdaparameter: 120
body: 77
70Lambdaparameter: 120
body: 78
71ExprTuple117
72ExprTuple79, 80
73Lambdaparameter: 120
body: 81
74Lambdaparameter: 120
body: 82
75Operationoperator: 90
operands: 83
76Operationoperator: 90
operands: 84
77Operationoperator: 90
operands: 85
78Operationoperator: 90
operands: 86
79ExprRangelambda_map: 87
start_index: 126
end_index: 127
80ExprRangelambda_map: 88
start_index: 126
end_index: 128
81Operationoperator: 90
operands: 89
82Operationoperator: 90
operands: 91
83NamedExprselement: 94
targets: 92
84NamedExprselement: 100
targets: 92
85NamedExprselement: 93
targets: 99
86NamedExprselement: 94
targets: 101
87Lambdaparameter: 120
body: 95
88Lambdaparameter: 120
body: 97
89NamedExprselement: 98
targets: 99
90Literal
91NamedExprselement: 100
targets: 101
92Operationoperator: 113
operands: 102
93Operationoperator: 103
operands: 109
94Operationoperator: 103
operands: 104
95Operationoperator: 105
operands: 106
96ExprTuple120
97IndexedVarvariable: 107
indices: 108
98Operationoperator: 111
operands: 109
99Operationoperator: 113
operands: 110
100Operationoperator: 111
operands: 112
101Operationoperator: 113
operands: 114
102ExprTuple126, 128
103Literal
104NamedExprsstate: 115
part: 120
105Literal
106NamedExprsoperation: 116
107Variable
108ExprTuple117, 120
109NamedExprsstate: 118
part: 120
110ExprTuple126, 127
111Literal
112NamedExprsstate: 119
part: 120
113Literal
114ExprTuple121, 122
115Variable
116Literal
117Variable
118Variable
119Variable
120Variable
121Operationoperator: 124
operands: 123
122Operationoperator: 124
operands: 125
123ExprTuple127, 126
124Literal
125ExprTuple127, 128
126Literal
127Variable
128Variable