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, j, k, n
from proveit.logic import Forall, InSet, NotEquals
from proveit.numbers import NaturalPos
from proveit.physics.quantum import NumKet
from proveit.physics.quantum.algebra import n_bit_interval
In [2]:
# build up the expression from sub-expressions
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [j, k], instance_expr = NotEquals(NumKet(j, n), NumKet(k, n)), domain = n_bit_interval, condition = NotEquals(j, k)), 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_{j, k \in \{0~\ldotp \ldotp~2^{n} - 1\}~|~j \neq k}~\left(\lvert j \rangle_{n} \neq \lvert k \rangle_{n}\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: 45
body: 2
1ExprTuple45
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 25
operands: 7
5Literal
6ExprTuple8
7ExprTuple45, 9
8Lambdaparameters: 28
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 27
operands: 13
12Operationoperator: 14
operands: 15
13ExprTuple16, 17
14Literal
15ExprTuple18, 19, 20
16Operationoperator: 22
operands: 21
17Operationoperator: 22
operands: 23
18Operationoperator: 25
operands: 24
19Operationoperator: 25
operands: 26
20Operationoperator: 27
operands: 28
21ExprTuple30, 45
22Literal
23ExprTuple31, 45
24ExprTuple30, 29
25Literal
26ExprTuple31, 29
27Literal
28ExprTuple30, 31
29Operationoperator: 32
operands: 33
30Variable
31Variable
32Literal
33ExprTuple34, 35
34Literal
35Operationoperator: 36
operands: 37
36Literal
37ExprTuple38, 39
38Operationoperator: 40
operands: 41
39Operationoperator: 42
operand: 46
40Literal
41ExprTuple44, 45
42Literal
43ExprTuple46
44Literal
45Variable
46Literal