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, alpha, l, n
from proveit.core_expr_types import A_1_to_l, C_1_to_n
from proveit.linear_algebra import ScalarMult
from proveit.logic import Equals, Forall, InClass
from proveit.numbers import Complex, Natural
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [alpha, l, n], instance_expr = Forall(instance_param_or_params = [A_1_to_l, B, C_1_to_n], instance_expr = Equals(Qmult(A_1_to_l, ScalarMult(alpha, B), C_1_to_n), Qmult(A_1_to_l, alpha, B, C_1_to_n)).with_wrapping_at(2), condition = InClass(Qmult(A_1_to_l, B, C_1_to_n), QmultCodomain)), domains = [Complex, 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_{\alpha \in \mathbb{C}, l \in \mathbb{N}, n \in \mathbb{N}}~\left[\forall_{A_{1}, A_{2}, \ldots, A_{l}, B, C_{1}, C_{2}, \ldots, C_{n}~|~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l} \thinspace B\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(\alpha \cdot B\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 \alpha \thinspace B\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
3ExprTuple46, 42, 45
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13, 14
11Lambdaparameters: 35
body: 15
12Operationoperator: 18
operands: 16
13Operationoperator: 18
operands: 17
14Operationoperator: 18
operands: 19
15Conditionalvalue: 20
condition: 21
16ExprTuple46, 22
17ExprTuple42, 23
18Literal
19ExprTuple45, 23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Literal
23Literal
24Literal
25ExprTuple28, 29
26Literal
27ExprTuple30, 31
28Operationoperator: 34
operands: 32
29Operationoperator: 34
operands: 33
30Operationoperator: 34
operands: 35
31Literal
32ExprTuple37, 36, 38
33ExprTuple37, 46, 47, 38
34Literal
35ExprTuple37, 47, 38
36Operationoperator: 39
operands: 40
37ExprRangelambda_map: 41
start_index: 44
end_index: 42
38ExprRangelambda_map: 43
start_index: 44
end_index: 45
39Literal
40ExprTuple46, 47
41Lambdaparameter: 53
body: 48
42Variable
43Lambdaparameter: 53
body: 49
44Literal
45Variable
46Variable
47Variable
48IndexedVarvariable: 50
index: 53
49IndexedVarvariable: 51
index: 53
50Variable
51Variable
52ExprTuple53
53Variable