logo

Expression of type ExprTuple

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, Conditional, ExprTuple, Lambda, 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 And, Equals, Forall, InClass, InSet
from proveit.numbers import Complex, Natural
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([alpha, l, n], Conditional(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)), And(InSet(alpha, Complex), InSet(l, Natural), InSet(n, 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())
\left(\left(\alpha, l, n\right) \mapsto \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) \textrm{ if } \alpha \in \mathbb{C} ,  l \in \mathbb{N} ,  n \in \mathbb{N}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple45, 41, 44
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12, 13
10Lambdaparameters: 34
body: 14
11Operationoperator: 17
operands: 15
12Operationoperator: 17
operands: 16
13Operationoperator: 17
operands: 18
14Conditionalvalue: 19
condition: 20
15ExprTuple45, 21
16ExprTuple41, 22
17Literal
18ExprTuple44, 22
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operands: 26
21Literal
22Literal
23Literal
24ExprTuple27, 28
25Literal
26ExprTuple29, 30
27Operationoperator: 33
operands: 31
28Operationoperator: 33
operands: 32
29Operationoperator: 33
operands: 34
30Literal
31ExprTuple36, 35, 37
32ExprTuple36, 45, 46, 37
33Literal
34ExprTuple36, 46, 37
35Operationoperator: 38
operands: 39
36ExprRangelambda_map: 40
start_index: 43
end_index: 41
37ExprRangelambda_map: 42
start_index: 43
end_index: 44
38Literal
39ExprTuple45, 46
40Lambdaparameter: 52
body: 47
41Variable
42Lambdaparameter: 52
body: 48
43Literal
44Variable
45Variable
46Variable
47IndexedVarvariable: 49
index: 52
48IndexedVarvariable: 50
index: 52
49Variable
50Variable
51ExprTuple52
52Variable