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, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, i, m, n
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 And, Equals, Forall, Implies, InClass, InSet
from proveit.numbers import Natural, NaturalPos, 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 = ExprTuple(Lambda([i, m, n], Conditional(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)), And(InSet(i, NaturalPos), InSet(m, 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(i, m, n\right) \mapsto \left\{\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) \textrm{ if } i \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
2ExprTuple43, 51, 56
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12, 13
10Lambdaparameters: 14
body: 15
11Operationoperator: 18
operands: 16
12Operationoperator: 18
operands: 17
13Operationoperator: 18
operands: 19
14ExprTuple47, 40, 49
15Operationoperator: 20
operands: 21
16ExprTuple43, 22
17ExprTuple51, 23
18Literal
19ExprTuple56, 23
20Literal
21ExprTuple24, 25
22Literal
23Literal
24Operationoperator: 26
operands: 27
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple31, 30
28Literal
29ExprTuple31, 32
30Literal
31Operationoperator: 44
operands: 33
32Operationoperator: 37
operands: 34
33ExprTuple47, 35, 49
34ExprTuple36
35Operationoperator: 37
operands: 38
36ExprRangelambda_map: 39
start_index: 55
end_index: 43
37Literal
38ExprTuple40
39Lambdaparameter: 58
body: 41
40ExprRangelambda_map: 42
start_index: 55
end_index: 43
41Operationoperator: 44
operands: 45
42Lambdaparameter: 63
body: 46
43Variable
44Literal
45ExprTuple47, 48, 49
46IndexedVarvariable: 52
index: 63
47ExprRangelambda_map: 50
start_index: 55
end_index: 51
48IndexedVarvariable: 52
index: 58
49ExprRangelambda_map: 54
start_index: 55
end_index: 56
50Lambdaparameter: 63
body: 57
51Variable
52Variable
53ExprTuple58
54Lambdaparameter: 63
body: 59
55Literal
56Variable
57IndexedVarvariable: 60
index: 63
58Variable
59IndexedVarvariable: 61
index: 63
60Variable
61Variable
62ExprTuple63
63Variable