logo

Expression of type Forall

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.core_expr_types.expr_arrays import A11_to_Akl
from proveit.logic import Equals, Forall
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 = 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)
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())
\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]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 103
body: 4
3ExprTuple103
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple103, 12
11Lambdaparameters: 13
body: 14
12Operationoperator: 15
operands: 16
13ExprTuple17
14Operationoperator: 18
operands: 19
15Literal
16ExprTuple20, 21
17ExprRangelambda_map: 22
start_index: 111
end_index: 48
18Literal
19ExprTuple23, 24
20Literal
21Operationoperator: 25
operands: 26
22Lambdaparameter: 102
body: 65
23Operationoperator: 28
operand: 31
24Operationoperator: 28
operand: 32
25Literal
26ExprTuple30, 112
27ExprTuple31
28Literal
29ExprTuple32
30Literal
31Operationoperator: 34
operands: 33
32Operationoperator: 34
operands: 35
33ExprTuple36, 37, 38
34Literal
35ExprTuple39, 40, 41
36ExprTuple42
37ExprRangelambda_map: 43
start_index: 111
end_index: 48
38ExprTuple44
39ExprTuple45, 46
40ExprRangelambda_map: 47
start_index: 111
end_index: 48
41ExprTuple49, 50
42ExprRangelambda_map: 51
start_index: 111
end_index: 113
43Lambdaparameter: 102
body: 52
44ExprRangelambda_map: 53
start_index: 111
end_index: 113
45ExprRangelambda_map: 54
start_index: 111
end_index: 112
46ExprRangelambda_map: 55
start_index: 111
end_index: 113
47Lambdaparameter: 102
body: 57
48Variable
49ExprRangelambda_map: 58
start_index: 111
end_index: 112
50ExprRangelambda_map: 59
start_index: 111
end_index: 113
51Lambdaparameter: 105
body: 60
52ExprTuple65
53Lambdaparameter: 105
body: 61
54Lambdaparameter: 105
body: 62
55Lambdaparameter: 105
body: 63
56ExprTuple102
57ExprTuple64, 65
58Lambdaparameter: 105
body: 66
59Lambdaparameter: 105
body: 67
60Operationoperator: 75
operands: 68
61Operationoperator: 75
operands: 69
62Operationoperator: 75
operands: 70
63Operationoperator: 75
operands: 71
64ExprRangelambda_map: 72
start_index: 111
end_index: 112
65ExprRangelambda_map: 73
start_index: 111
end_index: 113
66Operationoperator: 75
operands: 74
67Operationoperator: 75
operands: 76
68NamedExprselement: 79
targets: 77
69NamedExprselement: 85
targets: 77
70NamedExprselement: 78
targets: 84
71NamedExprselement: 79
targets: 86
72Lambdaparameter: 105
body: 80
73Lambdaparameter: 105
body: 82
74NamedExprselement: 83
targets: 84
75Literal
76NamedExprselement: 85
targets: 86
77Operationoperator: 98
operands: 87
78Operationoperator: 88
operands: 94
79Operationoperator: 88
operands: 89
80Operationoperator: 90
operands: 91
81ExprTuple105
82IndexedVarvariable: 92
indices: 93
83Operationoperator: 96
operands: 94
84Operationoperator: 98
operands: 95
85Operationoperator: 96
operands: 97
86Operationoperator: 98
operands: 99
87ExprTuple111, 113
88Literal
89NamedExprsstate: 100
part: 105
90Literal
91NamedExprsoperation: 101
92Variable
93ExprTuple102, 105
94NamedExprsstate: 103
part: 105
95ExprTuple111, 112
96Literal
97NamedExprsstate: 104
part: 105
98Literal
99ExprTuple106, 107
100Variable
101Literal
102Variable
103Variable
104Variable
105Variable
106Operationoperator: 109
operands: 108
107Operationoperator: 109
operands: 110
108ExprTuple112, 111
109Literal
110ExprTuple112, 113
111Literal
112Variable
113Variable