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 Conditional, ExprTuple, Lambda, l, m, n
from proveit.core_expr_types import A_1_to_l, B_1_to_m, C_1_to_n
from proveit.logic import And, Equals, Forall, InClass, InSet
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_l, B_1_to_m, C_1_to_n)
expr = ExprTuple(Lambda([l, m, n], Conditional(Forall(instance_param_or_params = [A_1_to_l, B_1_to_m, C_1_to_n], instance_expr = Equals(Qmult(A_1_to_l, Qmult(B_1_to_m), C_1_to_n), sub_expr1).with_wrapping_at(2), condition = InClass(sub_expr1, QmultCodomain)), And(InSet(l, Natural), InSet(m, NaturalPos), 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(l, m, n\right) \mapsto \left\{\forall_{A_{1}, A_{2}, \ldots, A_{l}, B_{1}, B_{2}, \ldots, B_{m}, C_{1}, C_{2}, \ldots, C_{n}~|~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\thinspace B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{m}\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(B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{m}\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 B_{1} \thinspace  B_{2} \thinspace  \ldots \thinspace  B_{m}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \end{array} \end{array}\right) \textrm{ if } l \in \mathbb{N} ,  m \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
2ExprTuple38, 46, 40
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12, 13
10Lambdaparameters: 31
body: 14
11Operationoperator: 17
operands: 15
12Operationoperator: 17
operands: 16
13Operationoperator: 17
operands: 18
14Conditionalvalue: 19
condition: 20
15ExprTuple38, 22
16ExprTuple46, 21
17Literal
18ExprTuple40, 22
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operands: 26
21Literal
22Literal
23Literal
24ExprTuple27, 28
25Literal
26ExprTuple28, 29
27Operationoperator: 35
operands: 30
28Operationoperator: 35
operands: 31
29Literal
30ExprTuple33, 32, 34
31ExprTuple33, 41, 34
32Operationoperator: 35
operands: 36
33ExprRangelambda_map: 37
start_index: 45
end_index: 38
34ExprRangelambda_map: 39
start_index: 45
end_index: 40
35Literal
36ExprTuple41
37Lambdaparameter: 52
body: 42
38Variable
39Lambdaparameter: 52
body: 43
40Variable
41ExprRangelambda_map: 44
start_index: 45
end_index: 46
42IndexedVarvariable: 47
index: 52
43IndexedVarvariable: 48
index: 52
44Lambdaparameter: 52
body: 49
45Literal
46Variable
47Variable
48Variable
49IndexedVarvariable: 50
index: 52
50Variable
51ExprTuple52
52Variable