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
from proveit.linear_algebra import HilbertSpaces, TensorProd
from proveit.logic import And, Forall, InClass, InSet
from proveit.physics.quantum import Qmult, var_ket_psi, var_ket_varphi
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [A, B]
expr = ExprTuple(Lambda(sub_expr1, Conditional(Forall(instance_param_or_params = [var_ket_psi, var_ket_varphi], instance_expr = InSet(Qmult(var_ket_psi, var_ket_varphi), TensorProd(A, B)), domains = sub_expr1), And(InClass(A, HilbertSpaces), InClass(B, 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(A, B\right) \mapsto \left\{\forall_{\lvert \psi \rangle \in A, \lvert \varphi \rangle \in B}~\left(\left(\lvert \psi \rangle \thinspace \lvert \varphi \rangle\right) \in \left(A {\otimes} B\right)\right) \textrm{ if } A \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces} ,  B \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: 28
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 19
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 26
body: 11
9Operationoperator: 13
operands: 12
10Operationoperator: 13
operands: 14
11Conditionalvalue: 15
condition: 16
12ExprTuple33, 17
13Literal
14ExprTuple35, 17
15Operationoperator: 30
operands: 18
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 24
21Operationoperator: 25
operands: 26
22Operationoperator: 27
operands: 28
23Operationoperator: 30
operands: 29
24Operationoperator: 30
operands: 31
25Literal
26ExprTuple32, 34
27Literal
28ExprTuple33, 35
29ExprTuple32, 33
30Literal
31ExprTuple34, 35
32Variable
33Variable
34Variable
35Variable