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__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_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__u_Akl_v__psi_m)).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{
\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] \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
2ExprTuple105, 108
3Conditionalvalue: 4
condition: 5
4Operationoperator: 19
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple10, 11
9Lambdaparameter: 109
body: 13
10Operationoperator: 21
operands: 14
11Operationoperator: 21
operands: 15
12ExprTuple109
13Conditionalvalue: 16
condition: 17
14ExprTuple105, 18
15ExprTuple108, 18
16Operationoperator: 19
operand: 24
17Operationoperator: 21
operands: 22
18Operationoperator: 29
operands: 23
19Literal
20ExprTuple24
21Literal
22ExprTuple109, 25
23ExprTuple35, 26
24Lambdaparameters: 27
body: 28
25Operationoperator: 29
operands: 30
26Operationoperator: 40
operands: 31
27ExprTuple32
28Operationoperator: 33
operands: 34
29Literal
30ExprTuple35, 36
31ExprTuple45, 117
32ExprRangelambda_map: 37
start_index: 116
end_index: 61
33Literal
34ExprTuple38, 39
35Literal
36Operationoperator: 40
operands: 41
37Lambdaparameter: 106
body: 73
38Operationoperator: 43
operand: 46
39Operationoperator: 43
operand: 47
40Literal
41ExprTuple45, 118
42ExprTuple46
43Literal
44ExprTuple47
45Literal
46Operationoperator: 49
operands: 48
47Operationoperator: 49
operands: 50
48ExprTuple51, 52, 53
49Literal
50ExprTuple54, 55, 56
51ExprTuple58
52ExprRangelambda_map: 57
start_index: 116
end_index: 61
53ExprTuple62
54ExprTuple58, 59
55ExprRangelambda_map: 60
start_index: 116
end_index: 61
56ExprTuple62, 63
57Lambdaparameter: 106
body: 64
58ExprRangelambda_map: 65
start_index: 116
end_index: 117
59ExprRangelambda_map: 66
start_index: 116
end_index: 118
60Lambdaparameter: 106
body: 68
61Variable
62ExprRangelambda_map: 69
start_index: 116
end_index: 117
63ExprRangelambda_map: 70
start_index: 116
end_index: 118
64ExprTuple73
65Lambdaparameter: 110
body: 71
66Lambdaparameter: 110
body: 72
67ExprTuple106
68ExprTuple73, 74
69Lambdaparameter: 110
body: 75
70Lambdaparameter: 110
body: 76
71Operationoperator: 82
operands: 77
72Operationoperator: 82
operands: 78
73ExprRangelambda_map: 79
start_index: 116
end_index: 117
74ExprRangelambda_map: 80
start_index: 116
end_index: 118
75Operationoperator: 82
operands: 81
76Operationoperator: 82
operands: 83
77NamedExprselement: 84
targets: 90
78NamedExprselement: 85
targets: 92
79Lambdaparameter: 110
body: 86
80Lambdaparameter: 110
body: 88
81NamedExprselement: 89
targets: 90
82Literal
83NamedExprselement: 91
targets: 92
84Operationoperator: 94
operands: 93
85Operationoperator: 94
operands: 102
86IndexedVarvariable: 95
indices: 96
87ExprTuple110
88Operationoperator: 97
operands: 98
89Operationoperator: 101
operands: 99
90Operationoperator: 103
operands: 100
91Operationoperator: 101
operands: 102
92Operationoperator: 103
operands: 104
93NamedExprsstate: 105
part: 110
94Literal
95Variable
96ExprTuple106, 110
97Literal
98NamedExprsoperation: 107
99NamedExprsstate: 108
part: 110
100ExprTuple116, 117
101Literal
102NamedExprsstate: 109
part: 110
103Literal
104ExprTuple111, 112
105Variable
106Variable
107Literal
108Variable
109Variable
110Variable
111Operationoperator: 114
operands: 113
112Operationoperator: 114
operands: 115
113ExprTuple117, 116
114Literal
115ExprTuple117, 118
116Literal
117Variable
118Variable