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.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 = [A11_to_Akl], instance_expr = Equals(Prob(circuit__u_Akl_v), Prob(circuit__psi_m__u_Akl_v)).with_wrapping_at(2)).with_wrapping()
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())
\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}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple6
5Operationoperator: 7
operands: 8
6ExprRangelambda_map: 9
start_index: 95
end_index: 32
7Literal
8ExprTuple10, 11
9Lambdaparameter: 86
body: 49
10Operationoperator: 13
operand: 15
11Operationoperator: 13
operand: 16
12ExprTuple15
13Literal
14ExprTuple16
15Operationoperator: 18
operands: 17
16Operationoperator: 18
operands: 19
17ExprTuple20, 21, 22
18Literal
19ExprTuple23, 24, 25
20ExprTuple26
21ExprRangelambda_map: 27
start_index: 95
end_index: 32
22ExprTuple28
23ExprTuple29, 30
24ExprRangelambda_map: 31
start_index: 95
end_index: 32
25ExprTuple33, 34
26ExprRangelambda_map: 35
start_index: 95
end_index: 97
27Lambdaparameter: 86
body: 36
28ExprRangelambda_map: 37
start_index: 95
end_index: 97
29ExprRangelambda_map: 38
start_index: 95
end_index: 96
30ExprRangelambda_map: 39
start_index: 95
end_index: 97
31Lambdaparameter: 86
body: 41
32Variable
33ExprRangelambda_map: 42
start_index: 95
end_index: 96
34ExprRangelambda_map: 43
start_index: 95
end_index: 97
35Lambdaparameter: 89
body: 44
36ExprTuple49
37Lambdaparameter: 89
body: 45
38Lambdaparameter: 89
body: 46
39Lambdaparameter: 89
body: 47
40ExprTuple86
41ExprTuple48, 49
42Lambdaparameter: 89
body: 50
43Lambdaparameter: 89
body: 51
44Operationoperator: 59
operands: 52
45Operationoperator: 59
operands: 53
46Operationoperator: 59
operands: 54
47Operationoperator: 59
operands: 55
48ExprRangelambda_map: 56
start_index: 95
end_index: 96
49ExprRangelambda_map: 57
start_index: 95
end_index: 97
50Operationoperator: 59
operands: 58
51Operationoperator: 59
operands: 60
52NamedExprselement: 63
targets: 61
53NamedExprselement: 69
targets: 61
54NamedExprselement: 62
targets: 68
55NamedExprselement: 63
targets: 70
56Lambdaparameter: 89
body: 64
57Lambdaparameter: 89
body: 66
58NamedExprselement: 67
targets: 68
59Literal
60NamedExprselement: 69
targets: 70
61Operationoperator: 82
operands: 71
62Operationoperator: 72
operands: 78
63Operationoperator: 72
operands: 73
64Operationoperator: 74
operands: 75
65ExprTuple89
66IndexedVarvariable: 76
indices: 77
67Operationoperator: 80
operands: 78
68Operationoperator: 82
operands: 79
69Operationoperator: 80
operands: 81
70Operationoperator: 82
operands: 83
71ExprTuple95, 97
72Literal
73NamedExprsstate: 84
part: 89
74Literal
75NamedExprsoperation: 85
76Variable
77ExprTuple86, 89
78NamedExprsstate: 87
part: 89
79ExprTuple95, 96
80Literal
81NamedExprsstate: 88
part: 89
82Literal
83ExprTuple90, 91
84Variable
85Literal
86Variable
87Variable
88Variable
89Variable
90Operationoperator: 93
operands: 92
91Operationoperator: 93
operands: 94
92ExprTuple96, 95
93Literal
94ExprTuple96, 97
95Literal
96Variable
97Variable