logo

Expression of type Forall

from the theory of proveit.physics.quantum.algebra

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 import A_1_to_l, B_1_to_m, C_1_to_n
from proveit.logic import Equals, Forall, InClass
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Qmult(A_1_to_l, B_1_to_m, C_1_to_n)
expr = Forall(instance_param_or_params = [A_1_to_l, B_1_to_m, C_1_to_n], instance_expr = Equals(Qmult(A_1_to_l, Qmult(B_1_to_m), C_1_to_n), sub_expr1).with_wrapping_at(2), condition = InClass(sub_expr1, QmultCodomain))
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_{1}, A_{2}, \ldots, A_{l}, B_{1}, B_{2}, \ldots, B_{m}, C_{1}, C_{2}, \ldots, C_{n}~|~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\thinspace B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{m}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}}~\left(\begin{array}{c} \begin{array}{l} \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l} \thinspace \left(B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{m}\right)\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) =  \\ \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\thinspace B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{m}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \end{array} \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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 15
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple12, 13
11Operationoperator: 19
operands: 14
12Operationoperator: 19
operands: 15
13Literal
14ExprTuple17, 16, 18
15ExprTuple17, 25, 18
16Operationoperator: 19
operands: 20
17ExprRangelambda_map: 21
start_index: 29
end_index: 22
18ExprRangelambda_map: 23
start_index: 29
end_index: 24
19Literal
20ExprTuple25
21Lambdaparameter: 36
body: 26
22Variable
23Lambdaparameter: 36
body: 27
24Variable
25ExprRangelambda_map: 28
start_index: 29
end_index: 30
26IndexedVarvariable: 31
index: 36
27IndexedVarvariable: 32
index: 36
28Lambdaparameter: 36
body: 33
29Literal
30Variable
31Variable
32Variable
33IndexedVarvariable: 34
index: 36
34Variable
35ExprTuple36
36Variable