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 a, b
from proveit.core_expr_types import U_1_to_m
from proveit.logic import Forall, Implies
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_aU, circuit_aUb, circuit_b
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [a, b, U_1_to_m], instance_expr = Implies(circuit_aUb, QcircuitEquiv(circuit_aU, circuit_b)))
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_{a, b, U_{1}, U_{2}, \ldots, U_{m}}~\left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{a} & \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{m} \\ \downarrow\end{array}} & \qout{b}
} \end{array}\right) \Rightarrow \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{a} & \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{m} \\ \downarrow\end{array}} & { /^{k} } \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{b} & { /^{k} } \qw
} \end{array}\right)\right)\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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple50, 51, 22
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Operationoperator: 18
operands: 10
9Operationoperator: 11
operands: 12
10ExprTuple21, 22, 13
11Literal
12ExprTuple14, 15
13ExprTuple16
14Operationoperator: 18
operands: 17
15Operationoperator: 18
operand: 23
16ExprRangelambda_map: 20
start_index: 53
end_index: 54
17ExprTuple21, 22
18Literal
19ExprTuple23
20Lambdaparameter: 52
body: 24
21ExprTuple25
22ExprRangelambda_map: 26
start_index: 53
end_index: 27
23ExprTuple28
24Operationoperator: 40
operands: 29
25ExprRangelambda_map: 30
start_index: 53
end_index: 54
26Lambdaparameter: 52
body: 31
27Variable
28ExprRangelambda_map: 32
start_index: 53
end_index: 54
29NamedExprselement: 33
targets: 44
30Lambdaparameter: 52
body: 34
31IndexedVarvariable: 35
index: 52
32Lambdaparameter: 52
body: 37
33Operationoperator: 38
operands: 47
34Operationoperator: 40
operands: 39
35Variable
36ExprTuple52
37Operationoperator: 40
operands: 41
38Literal
39NamedExprselement: 42
targets: 44
40Literal
41NamedExprselement: 43
targets: 44
42Operationoperator: 46
operands: 45
43Operationoperator: 46
operands: 47
44Operationoperator: 48
operands: 49
45NamedExprsstate: 50
part: 52
46Literal
47NamedExprsstate: 51
part: 52
48Literal
49ExprTuple53, 54
50Variable
51Variable
52Variable
53Literal
54Variable