logo

Expression of type Lambda

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, Lambda, U, n
from proveit.linear_algebra import Unitary
from proveit.logic import CartExp, Forall, InSet
from proveit.numbers import Complex, NaturalPos
from proveit.physics.quantum import Qmult, var_ket_psi
In [2]:
# build up the expression from sub-expressions
sub_expr1 = CartExp(Complex, n)
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [U], instance_expr = Forall(instance_param_or_params = [var_ket_psi], instance_expr = InSet(Qmult(U, var_ket_psi), sub_expr1), domain = sub_expr1), 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())
n \mapsto \left\{\forall_{U \in \textrm{U}\left(n\right)}~\left[\forall_{\lvert \psi \rangle \in \mathbb{C}^{n}}~\left(\left(U \thinspace \lvert \psi \rangle\right) \in \mathbb{C}^{n}\right)\right] \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 35
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 12
operand: 6
3Operationoperator: 24
operands: 5
4ExprTuple6
5ExprTuple35, 7
6Lambdaparameter: 32
body: 9
7Literal
8ExprTuple32
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operand: 15
11Operationoperator: 24
operands: 14
12Literal
13ExprTuple15
14ExprTuple32, 16
15Lambdaparameter: 33
body: 18
16Operationoperator: 19
operand: 35
17ExprTuple33
18Conditionalvalue: 21
condition: 22
19Literal
20ExprTuple35
21Operationoperator: 24
operands: 23
22Operationoperator: 24
operands: 25
23ExprTuple26, 27
24Literal
25ExprTuple33, 27
26Operationoperator: 28
operands: 29
27Operationoperator: 30
operands: 31
28Literal
29ExprTuple32, 33
30Literal
31ExprTuple34, 35
32Variable
33Variable
34Literal
35Variable