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 Q, f, j, m, n
from proveit.core_expr_types import A_1_to_m, C_1_to_n, Q__b_1_to_j, b_1_to_j, f__b_1_to_j
from proveit.linear_algebra import VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import Equals, Forall, Implies, 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_m, vec_summation_b1toj_fQ, C_1_to_n)
expr = Forall(instance_param_or_params = [j, m, n], instance_expr = Forall(instance_param_or_params = [A_1_to_m, C_1_to_n, f, Q], instance_expr = Implies(InClass(sub_expr1, QmultCodomain), Equals(sub_expr1, VecSum(index_or_indices = [b_1_to_j], summand = Qmult(A_1_to_m, f__b_1_to_j, C_1_to_n), condition = Q__b_1_to_j)).with_wrapping_at(1)).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_{j \in \mathbb{N}^+, m \in \mathbb{N}, n \in \mathbb{N}}~\left[\forall_{A_{1}, A_{2}, \ldots, A_{m}, C_{1}, C_{2}, \ldots, C_{n}, f, Q}~\left(\begin{array}{c} \begin{array}{l} \left(\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\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[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\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
3ExprTuple63, 52, 56
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
15ExprTuple47, 49, 53, 50
16Operationoperator: 21
operands: 22
17ExprTuple63, 23
18ExprTuple52, 24
19Literal
20ExprTuple56, 24
21Literal
22ExprTuple25, 26
23Literal
24Literal
25Operationoperator: 27
operands: 28
26Operationoperator: 29
operands: 30
27Literal
28ExprTuple32, 31
29Literal
30ExprTuple32, 33
31Literal
32Operationoperator: 44
operands: 34
33Operationoperator: 38
operand: 37
34ExprTuple47, 36, 49
35ExprTuple37
36Operationoperator: 38
operand: 41
37Lambdaparameters: 54
body: 40
38Literal
39ExprTuple41
40Conditionalvalue: 42
condition: 46
41Lambdaparameters: 54
body: 43
42Operationoperator: 44
operands: 45
43Conditionalvalue: 48
condition: 46
44Literal
45ExprTuple47, 48, 49
46Operationoperator: 50
operands: 54
47ExprRangelambda_map: 51
start_index: 62
end_index: 52
48Operationoperator: 53
operands: 54
49ExprRangelambda_map: 55
start_index: 62
end_index: 56
50Variable
51Lambdaparameter: 68
body: 57
52Variable
53Variable
54ExprTuple58
55Lambdaparameter: 68
body: 59
56Variable
57IndexedVarvariable: 60
index: 68
58ExprRangelambda_map: 61
start_index: 62
end_index: 63
59IndexedVarvariable: 64
index: 68
60Variable
61Lambdaparameter: 68
body: 65
62Literal
63Variable
64Variable
65IndexedVarvariable: 66
index: 68
66Variable
67ExprTuple68
68Variable