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_Akm, B11_to_Bkn, R11_to_Rkm, S11_to_Skn
from proveit.logic import Equals, Forall
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 = [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()
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, 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}
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, 7, 8, 9
5Operationoperator: 10
operands: 11
6ExprRangelambda_map: 12
start_index: 60
end_index: 61
7ExprRangelambda_map: 13
start_index: 60
end_index: 61
8ExprRangelambda_map: 14
start_index: 60
end_index: 61
9ExprRangelambda_map: 15
start_index: 60
end_index: 61
10Literal
11ExprTuple16, 17
12Lambdaparameter: 97
body: 18
13Lambdaparameter: 97
body: 19
14Lambdaparameter: 97
body: 20
15Lambdaparameter: 97
body: 21
16Operationoperator: 23
operands: 22
17Operationoperator: 23
operands: 24
18ExprRangelambda_map: 25
start_index: 60
end_index: 45
19ExprRangelambda_map: 26
start_index: 60
end_index: 45
20ExprRangelambda_map: 27
start_index: 60
end_index: 47
21ExprRangelambda_map: 28
start_index: 60
end_index: 47
22ExprTuple29, 30
23Literal
24ExprTuple31, 32
25Lambdaparameter: 94
body: 72
26Lambdaparameter: 94
body: 73
27Lambdaparameter: 94
body: 74
28Lambdaparameter: 94
body: 75
29Operationoperator: 36
operands: 33
30Operationoperator: 36
operands: 34
31Operationoperator: 36
operands: 35
32Operationoperator: 36
operands: 37
33ExprTuple38
34ExprTuple39
35ExprTuple40
36Literal
37ExprTuple41
38ExprRangelambda_map: 42
start_index: 60
end_index: 45
39ExprRangelambda_map: 43
start_index: 60
end_index: 47
40ExprRangelambda_map: 44
start_index: 60
end_index: 45
41ExprRangelambda_map: 46
start_index: 60
end_index: 47
42Lambdaparameter: 97
body: 48
43Lambdaparameter: 97
body: 49
44Lambdaparameter: 97
body: 50
45Variable
46Lambdaparameter: 97
body: 51
47Variable
48ExprTuple52
49ExprTuple53
50ExprTuple54
51ExprTuple55
52ExprRangelambda_map: 56
start_index: 60
end_index: 61
53ExprRangelambda_map: 57
start_index: 60
end_index: 61
54ExprRangelambda_map: 58
start_index: 60
end_index: 61
55ExprRangelambda_map: 59
start_index: 60
end_index: 61
56Lambdaparameter: 94
body: 62
57Lambdaparameter: 94
body: 63
58Lambdaparameter: 94
body: 64
59Lambdaparameter: 94
body: 66
60Literal
61Variable
62Operationoperator: 70
operands: 67
63Operationoperator: 70
operands: 68
64Operationoperator: 70
operands: 69
65ExprTuple94
66Operationoperator: 70
operands: 71
67NamedExprselement: 72
targets: 73
68NamedExprselement: 74
targets: 75
69NamedExprselement: 76
targets: 77
70Literal
71NamedExprselement: 78
targets: 79
72IndexedVarvariable: 81
indices: 80
73IndexedVarvariable: 90
indices: 80
74IndexedVarvariable: 83
indices: 80
75IndexedVarvariable: 91
indices: 80
76IndexedVarvariable: 81
indices: 92
77Operationoperator: 84
operand: 86
78IndexedVarvariable: 83
indices: 92
79Operationoperator: 84
operand: 89
80ExprTuple97, 94
81Variable
82ExprTuple86
83Variable
84Operationoperator: 87
operand: 95
85ExprTuple89
86IndexedVarvariable: 90
indices: 92
87Literal
88ExprTuple95
89IndexedVarvariable: 91
indices: 92
90Variable
91Variable
92ExprTuple93, 94
93Operationoperator: 95
operand: 97
94Variable
95Variable
96ExprTuple97
97Variable