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 j, k, l, m
from proveit.core_expr_types import A_1_to_j, B_1_to_k, C_1_to_l, D_1_to_m
from proveit.logic import Forall, Implies
from proveit.numbers import Natural
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_AjBkCl, circuit_AjDmCl, circuit_Bk, circuit_Dm
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [j, k, l, m], instance_expr = Forall(instance_param_or_params = [A_1_to_j, B_1_to_k, C_1_to_l, D_1_to_m], instance_expr = Implies(QcircuitEquiv(circuit_Bk, circuit_Dm), QcircuitEquiv(circuit_AjBkCl, circuit_AjDmCl).with_wrapping_at(1)).with_wrapping_at(2)).with_wrapping(), domain = Natural)
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_{j, k, l, m \in \mathbb{N}}~\left[\begin{array}{l}\forall_{A_{1}, A_{2}, \ldots, A_{j}, B_{1}, B_{2}, \ldots, B_{k}, C_{1}, C_{2}, \ldots, C_{l}, D_{1}, D_{2}, \ldots, D_{m}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\B_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\B_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\B_{k} \\ \downarrow\end{array}} & \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\D_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\D_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\D_{m} \\ \downarrow\end{array}} & \qw
} \end{array}\right)\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\A_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\A_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\A_{j} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\B_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\B_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\B_{k} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{l} \\ \downarrow\end{array}} & \qw
} \end{array}\right) \\  \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\A_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\A_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\A_{j} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\D_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\D_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\D_{m} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\C_{l} \\ \downarrow\end{array}} & \qw
} \end{array}\right) \end{array} \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
2Lambdaparameters: 3
body: 4
3ExprTuple47, 45, 52, 49
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13, 14, 15
11Lambdaparameters: 16
body: 17
12Operationoperator: 21
operands: 18
13Operationoperator: 21
operands: 19
14Operationoperator: 21
operands: 20
15Operationoperator: 21
operands: 22
16ExprTuple41, 40, 43, 42
17Operationoperator: 23
operands: 24
18ExprTuple47, 25
19ExprTuple45, 25
20ExprTuple52, 25
21Literal
22ExprTuple49, 25
23Literal
24ExprTuple26, 27
25Literal
26Operationoperator: 29
operands: 28
27Operationoperator: 29
operands: 30
28ExprTuple31, 32
29Literal
30ExprTuple33, 34
31Operationoperator: 38
operands: 35
32Operationoperator: 38
operands: 36
33Operationoperator: 38
operands: 37
34Operationoperator: 38
operands: 39
35ExprTuple40
36ExprTuple42
37ExprTuple41, 40, 43
38Literal
39ExprTuple41, 42, 43
40ExprRangelambda_map: 44
start_index: 51
end_index: 45
41ExprRangelambda_map: 46
start_index: 51
end_index: 47
42ExprRangelambda_map: 48
start_index: 51
end_index: 49
43ExprRangelambda_map: 50
start_index: 51
end_index: 52
44Lambdaparameter: 62
body: 53
45Variable
46Lambdaparameter: 62
body: 54
47Variable
48Lambdaparameter: 62
body: 55
49Variable
50Lambdaparameter: 62
body: 56
51Literal
52Variable
53IndexedVarvariable: 57
index: 62
54IndexedVarvariable: 58
index: 62
55IndexedVarvariable: 59
index: 62
56IndexedVarvariable: 60
index: 62
57Variable
58Variable
59Variable
60Variable
61ExprTuple62
62Variable