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, Unitary
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(U, Conditional(Forall(instance_param_or_params = [alpha], instance_expr = 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)), domain = RealNonNeg), InSet(U, Unitary(n)))))
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(U \mapsto \left\{\forall_{\alpha \in \mathbb{R}^{\ge 0}}~\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)\right] \textrm{ if } U \in \textrm{U}\left(n\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
1Lambdaparameter: 45
body: 3
2ExprTuple45
3Conditionalvalue: 4
condition: 5
4Operationoperator: 16
operand: 8
5Operationoperator: 31
operands: 7
6ExprTuple8
7ExprTuple45, 9
8Lambdaparameter: 38
body: 11
9Operationoperator: 12
operand: 47
10ExprTuple38
11Conditionalvalue: 14
condition: 15
12Literal
13ExprTuple47
14Operationoperator: 16
operand: 19
15Operationoperator: 31
operands: 18
16Literal
17ExprTuple19
18ExprTuple38, 20
19Lambdaparameter: 48
body: 21
20Literal
21Conditionalvalue: 22
condition: 23
22Operationoperator: 33
operands: 24
23Operationoperator: 25
operands: 26
24ExprTuple27, 38
25Literal
26ExprTuple28, 29
27Operationoperator: 43
operand: 35
28Operationoperator: 31
operands: 32
29Operationoperator: 33
operands: 34
30ExprTuple35
31Literal
32ExprTuple48, 36
33Literal
34ExprTuple37, 38
35Operationoperator: 39
operands: 40
36Operationoperator: 41
operands: 42
37Operationoperator: 43
operand: 48
38Variable
39Literal
40ExprTuple45, 48
41Literal
42ExprTuple46, 47
43Literal
44ExprTuple48
45Variable
46Literal
47Variable
48Variable