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 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 = ExprTuple(Lambda(var_ket_psi, 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(\lvert \psi \rangle \mapsto \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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 93
body: 3
2ExprTuple93
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple93, 11
10Lambdaparameters: 12
body: 13
11Operationoperator: 14
operands: 15
12ExprTuple16
13Operationoperator: 17
operands: 18
14Literal
15ExprTuple19, 20
16ExprRangelambda_map: 21
start_index: 100
end_index: 45
17Literal
18ExprTuple22, 23
19Literal
20Operationoperator: 24
operands: 25
21Lambdaparameter: 90
body: 57
22Operationoperator: 27
operand: 30
23Operationoperator: 27
operand: 31
24Literal
25ExprTuple29, 102
26ExprTuple30
27Literal
28ExprTuple31
29Literal
30Operationoperator: 33
operands: 32
31Operationoperator: 33
operands: 34
32ExprTuple35, 36, 37
33Literal
34ExprTuple38, 39, 40
35ExprTuple42
36ExprRangelambda_map: 41
start_index: 100
end_index: 45
37ExprTuple46
38ExprTuple42, 43
39ExprRangelambda_map: 44
start_index: 100
end_index: 45
40ExprTuple46, 47
41Lambdaparameter: 90
body: 48
42ExprRangelambda_map: 49
start_index: 100
end_index: 101
43ExprRangelambda_map: 50
start_index: 100
end_index: 102
44Lambdaparameter: 90
body: 52
45Variable
46ExprRangelambda_map: 53
start_index: 100
end_index: 101
47ExprRangelambda_map: 54
start_index: 100
end_index: 102
48ExprTuple57
49Lambdaparameter: 94
body: 55
50Lambdaparameter: 94
body: 56
51ExprTuple90
52ExprTuple57, 58
53Lambdaparameter: 94
body: 59
54Lambdaparameter: 94
body: 60
55Operationoperator: 66
operands: 61
56Operationoperator: 66
operands: 62
57ExprRangelambda_map: 63
start_index: 100
end_index: 101
58ExprRangelambda_map: 64
start_index: 100
end_index: 102
59Operationoperator: 66
operands: 65
60Operationoperator: 66
operands: 67
61NamedExprselement: 68
targets: 74
62NamedExprselement: 69
targets: 76
63Lambdaparameter: 94
body: 70
64Lambdaparameter: 94
body: 72
65NamedExprselement: 73
targets: 74
66Literal
67NamedExprselement: 75
targets: 76
68Operationoperator: 78
operands: 77
69Operationoperator: 78
operands: 86
70IndexedVarvariable: 79
indices: 80
71ExprTuple94
72Operationoperator: 81
operands: 82
73Operationoperator: 85
operands: 83
74Operationoperator: 87
operands: 84
75Operationoperator: 85
operands: 86
76Operationoperator: 87
operands: 88
77NamedExprsstate: 89
part: 94
78Literal
79Variable
80ExprTuple90, 94
81Literal
82NamedExprsoperation: 91
83NamedExprsstate: 92
part: 94
84ExprTuple100, 101
85Literal
86NamedExprsstate: 93
part: 94
87Literal
88ExprTuple95, 96
89Variable
90Variable
91Literal
92Variable
93Variable
94Variable
95Operationoperator: 98
operands: 97
96Operationoperator: 98
operands: 99
97ExprTuple101, 100
98Literal
99ExprTuple101, 102
100Literal
101Variable
102Variable