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, NaturalPos, RealNonNeg
from proveit.physics.quantum import Qmult, var_ket_psi
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [U], instance_expr = 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), domain = Unitary(n)), InSet(n, NaturalPos))))
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(n \mapsto \left\{\forall_{U \in \textrm{U}\left(n\right)}~\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]\right] \textrm{ if } n \in \mathbb{N}^+\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: 54
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 23
operand: 7
4Operationoperator: 38
operands: 6
5ExprTuple7
6ExprTuple54, 8
7Lambdaparameter: 52
body: 10
8Literal
9ExprTuple52
10Conditionalvalue: 11
condition: 12
11Operationoperator: 23
operand: 15
12Operationoperator: 38
operands: 14
13ExprTuple15
14ExprTuple52, 16
15Lambdaparameter: 45
body: 18
16Operationoperator: 19
operand: 54
17ExprTuple45
18Conditionalvalue: 21
condition: 22
19Literal
20ExprTuple54
21Operationoperator: 23
operand: 26
22Operationoperator: 38
operands: 25
23Literal
24ExprTuple26
25ExprTuple45, 27
26Lambdaparameter: 55
body: 28
27Literal
28Conditionalvalue: 29
condition: 30
29Operationoperator: 40
operands: 31
30Operationoperator: 32
operands: 33
31ExprTuple34, 45
32Literal
33ExprTuple35, 36
34Operationoperator: 50
operand: 42
35Operationoperator: 38
operands: 39
36Operationoperator: 40
operands: 41
37ExprTuple42
38Literal
39ExprTuple55, 43
40Literal
41ExprTuple44, 45
42Operationoperator: 46
operands: 47
43Operationoperator: 48
operands: 49
44Operationoperator: 50
operand: 55
45Variable
46Literal
47ExprTuple52, 55
48Literal
49ExprTuple53, 54
50Literal
51ExprTuple55
52Variable
53Literal
54Variable
55Variable