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 import l, m, n
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.numbers import Natural, NaturalPos
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 = [l, m, n], instance_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)), domains = [Natural, NaturalPos, 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_{l \in \mathbb{N}, m \in \mathbb{N}^+, n \in \mathbb{N}}~\left[\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)\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
3ExprTuple39, 47, 41
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13, 14
11Lambdaparameters: 32
body: 15
12Operationoperator: 18
operands: 16
13Operationoperator: 18
operands: 17
14Operationoperator: 18
operands: 19
15Conditionalvalue: 20
condition: 21
16ExprTuple39, 23
17ExprTuple47, 22
18Literal
19ExprTuple41, 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Literal
23Literal
24Literal
25ExprTuple28, 29
26Literal
27ExprTuple29, 30
28Operationoperator: 36
operands: 31
29Operationoperator: 36
operands: 32
30Literal
31ExprTuple34, 33, 35
32ExprTuple34, 42, 35
33Operationoperator: 36
operands: 37
34ExprRangelambda_map: 38
start_index: 46
end_index: 39
35ExprRangelambda_map: 40
start_index: 46
end_index: 41
36Literal
37ExprTuple42
38Lambdaparameter: 53
body: 43
39Variable
40Lambdaparameter: 53
body: 44
41Variable
42ExprRangelambda_map: 45
start_index: 46
end_index: 47
43IndexedVarvariable: 48
index: 53
44IndexedVarvariable: 49
index: 53
45Lambdaparameter: 53
body: 50
46Literal
47Variable
48Variable
49Variable
50IndexedVarvariable: 51
index: 53
51Variable
52ExprTuple53
53Variable