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__u_Akl_v, circuit__u_Akl_v__psi_m
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__u_Akl_v__psi_m)).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{
\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]
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: 94
body: 4
3ExprTuple94
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple94, 12
11Lambdaparameters: 13
body: 14
12Operationoperator: 15
operands: 16
13ExprTuple17
14Operationoperator: 18
operands: 19
15Literal
16ExprTuple20, 21
17ExprRangelambda_map: 22
start_index: 101
end_index: 46
18Literal
19ExprTuple23, 24
20Literal
21Operationoperator: 25
operands: 26
22Lambdaparameter: 91
body: 58
23Operationoperator: 28
operand: 31
24Operationoperator: 28
operand: 32
25Literal
26ExprTuple30, 103
27ExprTuple31
28Literal
29ExprTuple32
30Literal
31Operationoperator: 34
operands: 33
32Operationoperator: 34
operands: 35
33ExprTuple36, 37, 38
34Literal
35ExprTuple39, 40, 41
36ExprTuple43
37ExprRangelambda_map: 42
start_index: 101
end_index: 46
38ExprTuple47
39ExprTuple43, 44
40ExprRangelambda_map: 45
start_index: 101
end_index: 46
41ExprTuple47, 48
42Lambdaparameter: 91
body: 49
43ExprRangelambda_map: 50
start_index: 101
end_index: 102
44ExprRangelambda_map: 51
start_index: 101
end_index: 103
45Lambdaparameter: 91
body: 53
46Variable
47ExprRangelambda_map: 54
start_index: 101
end_index: 102
48ExprRangelambda_map: 55
start_index: 101
end_index: 103
49ExprTuple58
50Lambdaparameter: 95
body: 56
51Lambdaparameter: 95
body: 57
52ExprTuple91
53ExprTuple58, 59
54Lambdaparameter: 95
body: 60
55Lambdaparameter: 95
body: 61
56Operationoperator: 67
operands: 62
57Operationoperator: 67
operands: 63
58ExprRangelambda_map: 64
start_index: 101
end_index: 102
59ExprRangelambda_map: 65
start_index: 101
end_index: 103
60Operationoperator: 67
operands: 66
61Operationoperator: 67
operands: 68
62NamedExprselement: 69
targets: 75
63NamedExprselement: 70
targets: 77
64Lambdaparameter: 95
body: 71
65Lambdaparameter: 95
body: 73
66NamedExprselement: 74
targets: 75
67Literal
68NamedExprselement: 76
targets: 77
69Operationoperator: 79
operands: 78
70Operationoperator: 79
operands: 87
71IndexedVarvariable: 80
indices: 81
72ExprTuple95
73Operationoperator: 82
operands: 83
74Operationoperator: 86
operands: 84
75Operationoperator: 88
operands: 85
76Operationoperator: 86
operands: 87
77Operationoperator: 88
operands: 89
78NamedExprsstate: 90
part: 95
79Literal
80Variable
81ExprTuple91, 95
82Literal
83NamedExprsoperation: 92
84NamedExprsstate: 93
part: 95
85ExprTuple101, 102
86Literal
87NamedExprsstate: 94
part: 95
88Literal
89ExprTuple96, 97
90Variable
91Variable
92Literal
93Variable
94Variable
95Variable
96Operationoperator: 99
operands: 98
97Operationoperator: 99
operands: 100
98ExprTuple102, 101
99Literal
100ExprTuple102, 103
101Literal
102Variable
103Variable