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 ExprTuple, Lambda, X
from proveit.linear_algebra import Hspace
from proveit.logic import Forall, InClass, InSet
from proveit.physics.quantum import Qmult, QmultCodomain, bra_varphi, ket_varphi, var_ket_psi, varphi
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([Hspace, X], Forall(instance_param_or_params = [var_ket_psi], instance_expr = Forall(instance_param_or_params = [varphi], instance_expr = InClass(Qmult(var_ket_psi, bra_varphi), QmultCodomain), condition = InSet(ket_varphi, X)), domain = Hspace)))
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\right) \mapsto \left[\forall_{\lvert \psi \rangle \in \mathcal{H}}~\left[\forall_{\varphi~|~\lvert \varphi \rangle \in X}~\left(\left(\lvert \psi \rangle \thinspace \langle \varphi \rvert\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\right)\right]\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
2ExprTuple14, 25
3Operationoperator: 10
operand: 5
4ExprTuple5
5Lambdaparameter: 29
body: 7
6ExprTuple29
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operand: 13
9Operationoperator: 20
operands: 12
10Literal
11ExprTuple13
12ExprTuple29, 14
13Lambdaparameter: 33
body: 15
14Variable
15Conditionalvalue: 16
condition: 17
16Operationoperator: 18
operands: 19
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22, 23
20Literal
21ExprTuple24, 25
22Operationoperator: 26
operands: 27
23Literal
24Operationoperator: 28
operand: 33
25Variable
26Literal
27ExprTuple29, 30
28Literal
29Variable
30Operationoperator: 31
operand: 33
31Literal
32ExprTuple33
33Variable