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, U, alpha, n
from proveit.linear_algebra import Norm
from proveit.logic import CartExp, Equals, Forall, InSet
from proveit.numbers import Complex, RealNonNeg
from proveit.physics.quantum import Qmult, var_ket_psi
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(alpha, Conditional(Forall(instance_param_or_params = [var_ket_psi], instance_expr = Equals(Norm(Qmult(U, var_ket_psi)), alpha), domain = CartExp(Complex, n), condition = Equals(Norm(var_ket_psi), alpha)), InSet(alpha, RealNonNeg))))
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(\alpha \mapsto \left\{\forall_{\lvert \psi \rangle \in \mathbb{C}^{n}~|~\left \|\lvert \psi \rangle\right \| = \alpha}~\left(\left \|U \thinspace \lvert \psi \rangle\right \| = \alpha\right) \textrm{ if } \alpha \in \mathbb{R}^{\ge 0}\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
1Lambdaparameter: 28
body: 3
2ExprTuple28
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 21
operands: 8
6Literal
7ExprTuple9
8ExprTuple28, 10
9Lambdaparameter: 38
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 23
operands: 14
13Operationoperator: 15
operands: 16
14ExprTuple17, 28
15Literal
16ExprTuple18, 19
17Operationoperator: 33
operand: 25
18Operationoperator: 21
operands: 22
19Operationoperator: 23
operands: 24
20ExprTuple25
21Literal
22ExprTuple38, 26
23Literal
24ExprTuple27, 28
25Operationoperator: 29
operands: 30
26Operationoperator: 31
operands: 32
27Operationoperator: 33
operand: 38
28Variable
29Literal
30ExprTuple35, 38
31Literal
32ExprTuple36, 37
33Literal
34ExprTuple38
35Variable
36Literal
37Variable
38Variable