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 B, ExprRange, IndexedVar, Variable, i, m, n
from proveit.core_expr_types import A_1_to_m, B_1_to_i, C_1_to_n
from proveit.linear_algebra import VecAdd
from proveit.logic import Equals, Forall, Implies, InClass
from proveit.numbers import Natural, NaturalPos, one
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = Qmult(A_1_to_m, VecAdd(B_1_to_i), C_1_to_n)
expr = Forall(instance_param_or_params = [i, m, n], instance_expr = Forall(instance_param_or_params = [A_1_to_m, B_1_to_i, C_1_to_n], instance_expr = Implies(InClass(sub_expr2, QmultCodomain), Equals(sub_expr2, VecAdd(ExprRange(sub_expr1, Qmult(A_1_to_m, IndexedVar(B, sub_expr1), C_1_to_n), one, i))).with_wrapping_at(2)).with_wrapping_at(2)), domains = [NaturalPos, Natural, 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_{i \in \mathbb{N}^+, m \in \mathbb{N}, n \in \mathbb{N}}~\left[\forall_{A_{1}, A_{2}, \ldots, A_{m}, B_{1}, B_{2}, \ldots, B_{i}, C_{1}, C_{2}, \ldots, C_{n}}~\left(\begin{array}{c} \begin{array}{l} \left(\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace \left(B_{1} +  B_{2} +  \ldots +  B_{i}\right)\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace \left(B_{1} +  B_{2} +  \ldots +  B_{i}\right)\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) =  \\ \left(\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace B_{1}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) +  \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace B_{2}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) +  \ldots +  \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace B_{i}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right)\right) \end{array} \end{array}\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
3ExprTuple44, 52, 57
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13, 14
11Lambdaparameters: 15
body: 16
12Operationoperator: 19
operands: 17
13Operationoperator: 19
operands: 18
14Operationoperator: 19
operands: 20
15ExprTuple48, 41, 50
16Operationoperator: 21
operands: 22
17ExprTuple44, 23
18ExprTuple52, 24
19Literal
20ExprTuple57, 24
21Literal
22ExprTuple25, 26
23Literal
24Literal
25Operationoperator: 27
operands: 28
26Operationoperator: 29
operands: 30
27Literal
28ExprTuple32, 31
29Literal
30ExprTuple32, 33
31Literal
32Operationoperator: 45
operands: 34
33Operationoperator: 38
operands: 35
34ExprTuple48, 36, 50
35ExprTuple37
36Operationoperator: 38
operands: 39
37ExprRangelambda_map: 40
start_index: 56
end_index: 44
38Literal
39ExprTuple41
40Lambdaparameter: 59
body: 42
41ExprRangelambda_map: 43
start_index: 56
end_index: 44
42Operationoperator: 45
operands: 46
43Lambdaparameter: 64
body: 47
44Variable
45Literal
46ExprTuple48, 49, 50
47IndexedVarvariable: 53
index: 64
48ExprRangelambda_map: 51
start_index: 56
end_index: 52
49IndexedVarvariable: 53
index: 59
50ExprRangelambda_map: 55
start_index: 56
end_index: 57
51Lambdaparameter: 64
body: 58
52Variable
53Variable
54ExprTuple59
55Lambdaparameter: 64
body: 60
56Literal
57Variable
58IndexedVarvariable: 61
index: 64
59Variable
60IndexedVarvariable: 62
index: 64
61Variable
62Variable
63ExprTuple64
64Variable