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
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 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 = [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))
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_{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)
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
4ExprTuple31, 24, 33
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple15, 14
12Literal
13ExprTuple15, 16
14Literal
15Operationoperator: 28
operands: 17
16Operationoperator: 21
operands: 18
17ExprTuple31, 19, 33
18ExprTuple20
19Operationoperator: 21
operands: 22
20ExprRangelambda_map: 23
start_index: 39
end_index: 27
21Literal
22ExprTuple24
23Lambdaparameter: 42
body: 25
24ExprRangelambda_map: 26
start_index: 39
end_index: 27
25Operationoperator: 28
operands: 29
26Lambdaparameter: 47
body: 30
27Variable
28Literal
29ExprTuple31, 32, 33
30IndexedVarvariable: 36
index: 47
31ExprRangelambda_map: 34
start_index: 39
end_index: 35
32IndexedVarvariable: 36
index: 42
33ExprRangelambda_map: 38
start_index: 39
end_index: 40
34Lambdaparameter: 47
body: 41
35Variable
36Variable
37ExprTuple42
38Lambdaparameter: 47
body: 43
39Literal
40Variable
41IndexedVarvariable: 44
index: 47
42Variable
43IndexedVarvariable: 45
index: 47
44Variable
45Variable
46ExprTuple47
47Variable