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 import Function, Literal, k, p
from proveit.core_expr_types.expr_arrays import A11_to_Akm, B11_to_Bkn, R11_to_Rkm, S11_to_Skn
from proveit.logic import Equals, Forall
from proveit.numbers import Interval, one
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_Akm, circuit_Bkn, circuit_permuted_Akm, circuit_permuted_Bkn
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [p], instance_expr = Forall(instance_param_or_params = [A11_to_Akm, R11_to_Rkm, B11_to_Bkn, S11_to_Skn], instance_expr = Equals(QcircuitEquiv(circuit_Akm, circuit_Bkn), QcircuitEquiv(circuit_permuted_Akm, circuit_permuted_Bkn)).with_wrapping_at(2)).with_wrapping(), domain = Function(Literal("Perm", latex_format = r"\textrm{Perm}", theory = "proveit.physics.quantum.circuits"), [Interval(one, k)]))
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_{p \in \textrm{Perm}\left(\{1~\ldotp \ldotp~k\}\right)}~\left[\begin{array}{l}\forall_{A_{1, 1}, A_{1, 2}, \ldots, A_{1, m}, A_{2, 1}, A_{2, 2}, \ldots, A_{2, m}, \ldots\ldots, A_{k, 1}, A_{k, 2}, \ldots, A_{k, m}, R_{1, 1}, R_{1, 2}, \ldots, R_{1, m}, R_{2, 1}, R_{2, 2}, \ldots, R_{2, m}, \ldots\ldots, R_{k, 1}, R_{k, 2}, \ldots, R_{k, m}, B_{1, 1}, B_{1, 2}, \ldots, B_{1, n}, B_{2, 1}, B_{2, 2}, \ldots, B_{2, n}, \ldots\ldots, B_{k, 1}, B_{k, 2}, \ldots, B_{k, n}, S_{1, 1}, S_{1, 2}, \ldots, S_{1, n}, S_{2, 1}, S_{2, 2}, \ldots, S_{2, n}, \ldots\ldots, S_{k, 1}, S_{k, 2}, \ldots, S_{k, n}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{A_{1, 1}~\mbox{on}~R_{1, 1}} \qwx[1] & \gate{A_{2, 1}~\mbox{on}~R_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{m, 1}~\mbox{on}~R_{m, 1}} \qwx[1] & \qw \\
& \gate{A_{1, 2}~\mbox{on}~R_{1, 2}} \qwx[1] & \gate{A_{2, 2}~\mbox{on}~R_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{m, 2}~\mbox{on}~R_{m, 2}} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{A_{1, k}~\mbox{on}~R_{1, k}} & \gate{A_{2, k}~\mbox{on}~R_{2, k}} & \gate{\cdots} & \gate{A_{m, k}~\mbox{on}~R_{m, k}} & \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{B_{1, 1}~\mbox{on}~S_{1, 1}} \qwx[1] & \gate{B_{2, 1}~\mbox{on}~S_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{n, 1}~\mbox{on}~S_{n, 1}} \qwx[1] & \qw \\
& \gate{B_{1, 2}~\mbox{on}~S_{1, 2}} \qwx[1] & \gate{B_{2, 2}~\mbox{on}~S_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{n, 2}~\mbox{on}~S_{n, 2}} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{B_{1, k}~\mbox{on}~S_{1, k}} & \gate{B_{2, k}~\mbox{on}~S_{2, k}} & \gate{\cdots} & \gate{B_{n, k}~\mbox{on}~S_{n, k}} & \qw
} \end{array}\right)\right) =  \\ \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{A_{p\left(1\right), 1}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(1\right), 1}\right)} \qwx[1] & \gate{A_{p\left(2\right), 1}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(2\right), 1}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{p\left(m\right), 1}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(m\right), 1}\right)} \qwx[1] & \qw \\
& \gate{A_{p\left(1\right), 2}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(1\right), 2}\right)} \qwx[1] & \gate{A_{p\left(2\right), 2}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(2\right), 2}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{p\left(m\right), 2}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(m\right), 2}\right)} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{A_{p\left(1\right), k}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(1\right), k}\right)} & \gate{A_{p\left(2\right), k}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(2\right), k}\right)} & \gate{\cdots} & \gate{A_{p\left(m\right), k}~\mbox{on}~p^{\leftarrow}\left(R_{p\left(m\right), k}\right)} & \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{B_{p\left(1\right), 1}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(1\right), 1}\right)} \qwx[1] & \gate{B_{p\left(2\right), 1}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), 1}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{p\left(n\right), 1}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), 1}\right)} \qwx[1] & \qw \\
& \gate{B_{p\left(1\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(1\right), 2}\right)} \qwx[1] & \gate{B_{p\left(2\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), 2}\right)} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{B_{p\left(n\right), 2}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), 2}\right)} \qwx[1] & \qw \\
& \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \qw \\
& \gate{B_{p\left(1\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(1\right), k}\right)} & \gate{B_{p\left(2\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(2\right), k}\right)} & \gate{\cdots} & \gate{B_{p\left(n\right), k}~\mbox{on}~p^{\leftarrow}\left(S_{p\left(n\right), k}\right)} & \qw
} \end{array}\right)\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: 6
operand: 2
1ExprTuple2
2Lambdaparameter: 108
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple108, 11
10Lambdaparameters: 12
body: 13
11Operationoperator: 14
operand: 22
12ExprTuple16, 17, 18, 19
13Operationoperator: 20
operands: 21
14Literal
15ExprTuple22
16ExprRangelambda_map: 23
start_index: 73
end_index: 74
17ExprRangelambda_map: 24
start_index: 73
end_index: 74
18ExprRangelambda_map: 25
start_index: 73
end_index: 74
19ExprRangelambda_map: 26
start_index: 73
end_index: 74
20Literal
21ExprTuple27, 28
22Operationoperator: 29
operands: 30
23Lambdaparameter: 110
body: 31
24Lambdaparameter: 110
body: 32
25Lambdaparameter: 110
body: 33
26Lambdaparameter: 110
body: 34
27Operationoperator: 36
operands: 35
28Operationoperator: 36
operands: 37
29Literal
30ExprTuple73, 74
31ExprRangelambda_map: 38
start_index: 73
end_index: 58
32ExprRangelambda_map: 39
start_index: 73
end_index: 58
33ExprRangelambda_map: 40
start_index: 73
end_index: 60
34ExprRangelambda_map: 41
start_index: 73
end_index: 60
35ExprTuple42, 43
36Literal
37ExprTuple44, 45
38Lambdaparameter: 107
body: 85
39Lambdaparameter: 107
body: 86
40Lambdaparameter: 107
body: 87
41Lambdaparameter: 107
body: 88
42Operationoperator: 49
operands: 46
43Operationoperator: 49
operands: 47
44Operationoperator: 49
operands: 48
45Operationoperator: 49
operands: 50
46ExprTuple51
47ExprTuple52
48ExprTuple53
49Literal
50ExprTuple54
51ExprRangelambda_map: 55
start_index: 73
end_index: 58
52ExprRangelambda_map: 56
start_index: 73
end_index: 60
53ExprRangelambda_map: 57
start_index: 73
end_index: 58
54ExprRangelambda_map: 59
start_index: 73
end_index: 60
55Lambdaparameter: 110
body: 61
56Lambdaparameter: 110
body: 62
57Lambdaparameter: 110
body: 63
58Variable
59Lambdaparameter: 110
body: 64
60Variable
61ExprTuple65
62ExprTuple66
63ExprTuple67
64ExprTuple68
65ExprRangelambda_map: 69
start_index: 73
end_index: 74
66ExprRangelambda_map: 70
start_index: 73
end_index: 74
67ExprRangelambda_map: 71
start_index: 73
end_index: 74
68ExprRangelambda_map: 72
start_index: 73
end_index: 74
69Lambdaparameter: 107
body: 75
70Lambdaparameter: 107
body: 76
71Lambdaparameter: 107
body: 77
72Lambdaparameter: 107
body: 79
73Literal
74Variable
75Operationoperator: 83
operands: 80
76Operationoperator: 83
operands: 81
77Operationoperator: 83
operands: 82
78ExprTuple107
79Operationoperator: 83
operands: 84
80NamedExprselement: 85
targets: 86
81NamedExprselement: 87
targets: 88
82NamedExprselement: 89
targets: 90
83Literal
84NamedExprselement: 91
targets: 92
85IndexedVarvariable: 94
indices: 93
86IndexedVarvariable: 103
indices: 93
87IndexedVarvariable: 96
indices: 93
88IndexedVarvariable: 104
indices: 93
89IndexedVarvariable: 94
indices: 105
90Operationoperator: 97
operand: 99
91IndexedVarvariable: 96
indices: 105
92Operationoperator: 97
operand: 102
93ExprTuple110, 107
94Variable
95ExprTuple99
96Variable
97Operationoperator: 100
operand: 108
98ExprTuple102
99IndexedVarvariable: 103
indices: 105
100Literal
101ExprTuple108
102IndexedVarvariable: 104
indices: 105
103Variable
104Variable
105ExprTuple106, 107
106Operationoperator: 108
operand: 110
107Variable
108Variable
109ExprTuple110
110Variable