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
from proveit.core_expr_types import B_1_to_m
from proveit.linear_algebra import TensorProd
from proveit.logic import Equals, Forall, Iff
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_compressed_inputAm, circuit_expanded_inputBm
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [A, B_1_to_m], instance_expr = Iff(QcircuitEquiv(circuit_compressed_inputAm, circuit_expanded_inputBm), Equals(A, TensorProd(B_1_to_m))))
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_{1}, B_{2}, \ldots, B_{m}}~\left(\left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{A} & { /^{m} } \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{B_{1}} & \qw \\
\qin{B_{2}} & \qw \\
\qin{\vdots} & \qw \\
\qin{B_{m}} & \qw
} \end{array}\right)\right) \Leftrightarrow \left(A = \left(B_{1} {\otimes}  B_{2} {\otimes}  \ldots {\otimes}  B_{m}\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
4ExprTuple44, 24
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple44, 16
14Operationoperator: 18
operand: 22
15Operationoperator: 18
operand: 23
16Operationoperator: 20
operands: 21
17ExprTuple22
18Literal
19ExprTuple23
20Literal
21ExprTuple24
22ExprTuple25
23ExprTuple26
24ExprRangelambda_map: 27
start_index: 45
end_index: 46
25ExprRangelambda_map: 28
start_index: 45
end_index: 46
26ExprRangelambda_map: 29
start_index: 45
end_index: 46
27Lambdaparameter: 47
body: 37
28Lambdaparameter: 47
body: 30
29Lambdaparameter: 47
body: 31
30Operationoperator: 32
operands: 33
31Operationoperator: 38
operands: 34
32Literal
33NamedExprselement: 35
targets: 36
34NamedExprsstate: 37
35Operationoperator: 38
operands: 39
36Operationoperator: 40
operands: 41
37IndexedVarvariable: 42
index: 47
38Literal
39NamedExprsstate: 44
part: 47
40Literal
41ExprTuple45, 46
42Variable
43ExprTuple47
44Variable
45Literal
46Variable
47Variable