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 A, B, Conditional, ExprTuple, Lambda, X, Y
from proveit.linear_algebra import HilbertSpaces, Hspace, LinMap
from proveit.logic import And, InClass, InSet, Set
from proveit.numbers import Complex
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = LinMap(Hspace, X)
expr = ExprTuple(Lambda([Hspace, X, Y], Conditional(InSet([Qmult(A), Qmult(B)], Set([sub_expr1, Hspace], [X, LinMap(Hspace, Complex)], [LinMap(X, Y), sub_expr1], [Complex, QmultCodomain], [QmultCodomain, Complex])), And(InClass(Hspace, HilbertSpaces), InClass(X, HilbertSpaces), InClass(Y, HilbertSpaces)))))
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(\mathcal{H}, X, Y\right) \mapsto \left\{\left(\left[A\right], \left[B\right]\right) \in \left\{\left(\mathcal{L}\left(\mathcal{H}, X\right), \mathcal{H}\right), \left(X, \mathcal{L}\left(\mathcal{H}, \mathbb{C}\right)\right), \left(\mathcal{L}\left(X, Y\right), \mathcal{L}\left(\mathcal{H}, X\right)\right), \left(\mathbb{C}, \mathcal{Q^*}\right), \left(\mathcal{Q^*}, \mathbb{C}\right)\right\} \textrm{ if } \mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  X \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  Y \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}\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
2ExprTuple44, 45, 43
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14
10ExprTuple15, 16
11Operationoperator: 17
operands: 18
12Operationoperator: 21
operands: 19
13Operationoperator: 21
operands: 20
14Operationoperator: 21
operands: 22
15Operationoperator: 24
operand: 32
16Operationoperator: 24
operand: 33
17Literal
18ExprTuple26, 27, 28, 29, 30
19ExprTuple44, 31
20ExprTuple45, 31
21Literal
22ExprTuple43, 31
23ExprTuple32
24Literal
25ExprTuple33
26ExprTuple36, 44
27ExprTuple45, 34
28ExprTuple35, 36
29ExprTuple42, 37
30ExprTuple37, 42
31Literal
32Variable
33Variable
34Operationoperator: 40
operands: 38
35Operationoperator: 40
operands: 39
36Operationoperator: 40
operands: 41
37Literal
38ExprTuple44, 42
39ExprTuple45, 43
40Literal
41ExprTuple44, 45
42Literal
43Variable
44Variable
45Variable