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__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_psi, Conditional(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(), 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{
\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} \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: 102
body: 3
2ExprTuple102
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple102, 11
10Lambdaparameters: 12
body: 13
11Operationoperator: 14
operands: 15
12ExprTuple16
13Operationoperator: 17
operands: 18
14Literal
15ExprTuple19, 20
16ExprRangelambda_map: 21
start_index: 110
end_index: 47
17Literal
18ExprTuple22, 23
19Literal
20Operationoperator: 24
operands: 25
21Lambdaparameter: 101
body: 64
22Operationoperator: 27
operand: 30
23Operationoperator: 27
operand: 31
24Literal
25ExprTuple29, 111
26ExprTuple30
27Literal
28ExprTuple31
29Literal
30Operationoperator: 33
operands: 32
31Operationoperator: 33
operands: 34
32ExprTuple35, 36, 37
33Literal
34ExprTuple38, 39, 40
35ExprTuple41
36ExprRangelambda_map: 42
start_index: 110
end_index: 47
37ExprTuple43
38ExprTuple44, 45
39ExprRangelambda_map: 46
start_index: 110
end_index: 47
40ExprTuple48, 49
41ExprRangelambda_map: 50
start_index: 110
end_index: 112
42Lambdaparameter: 101
body: 51
43ExprRangelambda_map: 52
start_index: 110
end_index: 112
44ExprRangelambda_map: 53
start_index: 110
end_index: 111
45ExprRangelambda_map: 54
start_index: 110
end_index: 112
46Lambdaparameter: 101
body: 56
47Variable
48ExprRangelambda_map: 57
start_index: 110
end_index: 111
49ExprRangelambda_map: 58
start_index: 110
end_index: 112
50Lambdaparameter: 104
body: 59
51ExprTuple64
52Lambdaparameter: 104
body: 60
53Lambdaparameter: 104
body: 61
54Lambdaparameter: 104
body: 62
55ExprTuple101
56ExprTuple63, 64
57Lambdaparameter: 104
body: 65
58Lambdaparameter: 104
body: 66
59Operationoperator: 74
operands: 67
60Operationoperator: 74
operands: 68
61Operationoperator: 74
operands: 69
62Operationoperator: 74
operands: 70
63ExprRangelambda_map: 71
start_index: 110
end_index: 111
64ExprRangelambda_map: 72
start_index: 110
end_index: 112
65Operationoperator: 74
operands: 73
66Operationoperator: 74
operands: 75
67NamedExprselement: 78
targets: 76
68NamedExprselement: 84
targets: 76
69NamedExprselement: 77
targets: 83
70NamedExprselement: 78
targets: 85
71Lambdaparameter: 104
body: 79
72Lambdaparameter: 104
body: 81
73NamedExprselement: 82
targets: 83
74Literal
75NamedExprselement: 84
targets: 85
76Operationoperator: 97
operands: 86
77Operationoperator: 87
operands: 93
78Operationoperator: 87
operands: 88
79Operationoperator: 89
operands: 90
80ExprTuple104
81IndexedVarvariable: 91
indices: 92
82Operationoperator: 95
operands: 93
83Operationoperator: 97
operands: 94
84Operationoperator: 95
operands: 96
85Operationoperator: 97
operands: 98
86ExprTuple110, 112
87Literal
88NamedExprsstate: 99
part: 104
89Literal
90NamedExprsoperation: 100
91Variable
92ExprTuple101, 104
93NamedExprsstate: 102
part: 104
94ExprTuple110, 111
95Literal
96NamedExprsstate: 103
part: 104
97Literal
98ExprTuple105, 106
99Variable
100Literal
101Variable
102Variable
103Variable
104Variable
105Operationoperator: 108
operands: 107
106Operationoperator: 108
operands: 109
107ExprTuple111, 110
108Literal
109ExprTuple111, 112
110Literal
111Variable
112Variable