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__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 = [A11_to_Akl], instance_expr = Equals(Prob(circuit__u_Akl_v), Prob(circuit__u_Akl_v__psi_m)).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{
\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}
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: 85
end_index: 30
7Literal
8ExprTuple10, 11
9Lambdaparameter: 75
body: 42
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
20ExprTuple27
21ExprRangelambda_map: 26
start_index: 85
end_index: 30
22ExprTuple31
23ExprTuple27, 28
24ExprRangelambda_map: 29
start_index: 85
end_index: 30
25ExprTuple31, 32
26Lambdaparameter: 75
body: 33
27ExprRangelambda_map: 34
start_index: 85
end_index: 86
28ExprRangelambda_map: 35
start_index: 85
end_index: 87
29Lambdaparameter: 75
body: 37
30Variable
31ExprRangelambda_map: 38
start_index: 85
end_index: 86
32ExprRangelambda_map: 39
start_index: 85
end_index: 87
33ExprTuple42
34Lambdaparameter: 79
body: 40
35Lambdaparameter: 79
body: 41
36ExprTuple75
37ExprTuple42, 43
38Lambdaparameter: 79
body: 44
39Lambdaparameter: 79
body: 45
40Operationoperator: 51
operands: 46
41Operationoperator: 51
operands: 47
42ExprRangelambda_map: 48
start_index: 85
end_index: 86
43ExprRangelambda_map: 49
start_index: 85
end_index: 87
44Operationoperator: 51
operands: 50
45Operationoperator: 51
operands: 52
46NamedExprselement: 53
targets: 59
47NamedExprselement: 54
targets: 61
48Lambdaparameter: 79
body: 55
49Lambdaparameter: 79
body: 57
50NamedExprselement: 58
targets: 59
51Literal
52NamedExprselement: 60
targets: 61
53Operationoperator: 63
operands: 62
54Operationoperator: 63
operands: 71
55IndexedVarvariable: 64
indices: 65
56ExprTuple79
57Operationoperator: 66
operands: 67
58Operationoperator: 70
operands: 68
59Operationoperator: 72
operands: 69
60Operationoperator: 70
operands: 71
61Operationoperator: 72
operands: 73
62NamedExprsstate: 74
part: 79
63Literal
64Variable
65ExprTuple75, 79
66Literal
67NamedExprsoperation: 76
68NamedExprsstate: 77
part: 79
69ExprTuple85, 86
70Literal
71NamedExprsstate: 78
part: 79
72Literal
73ExprTuple80, 81
74Variable
75Variable
76Literal
77Variable
78Variable
79Variable
80Operationoperator: 83
operands: 82
81Operationoperator: 83
operands: 84
82ExprTuple86, 85
83Literal
84ExprTuple86, 87
85Literal
86Variable
87Variable