logo

Expression of type Conditional

from the theory of proveit.physics.quantum.QFT

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, k, l, n
from proveit.logic import And, Equals, InSet
from proveit.numbers import Exp, Interval, Mult, Neg, e, frac, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumBra, NumKet, Qmult
from proveit.physics.quantum.QFT import InverseFourierTransform
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Exp(two, n)
sub_expr2 = Interval(zero, subtract(sub_expr1, one))
expr = Conditional(Equals(Qmult(NumBra(l, n), InverseFourierTransform(n), NumKet(k, n)), Mult(frac(one, Exp(two, frac(n, two))), Exp(e, frac(Neg(Mult(two, pi, i, k, l)), sub_expr1)))), And(InSet(k, sub_expr2), InSet(l, sub_expr2)))
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\{\left({_{n}}\langle l \rvert \thinspace {\mathrm {FT}}^{\dag}_{n} \thinspace \lvert k \rangle_{n}\right) = \left(\frac{1}{2^{\frac{n}{2}}} \cdot \mathsf{e}^{\frac{-\left(2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot l\right)}{2^{n}}}\right) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{n} - 1\} ,  l \in \{0~\ldotp \ldotp~2^{n} - 1\}\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9, 10
7Operationoperator: 11
operands: 12
8Operationoperator: 56
operands: 13
9Operationoperator: 15
operands: 14
10Operationoperator: 15
operands: 16
11Literal
12ExprTuple17, 18, 19
13ExprTuple20, 21
14ExprTuple61, 22
15Literal
16ExprTuple62, 22
17Operationoperator: 23
operands: 24
18Operationoperator: 25
operand: 54
19Operationoperator: 27
operands: 28
20Operationoperator: 46
operands: 29
21Operationoperator: 49
operands: 30
22Operationoperator: 31
operands: 32
23Literal
24ExprTuple62, 54
25Literal
26ExprTuple54
27Literal
28ExprTuple61, 54
29ExprTuple55, 33
30ExprTuple34, 35
31Literal
32ExprTuple36, 37
33Operationoperator: 49
operands: 38
34Literal
35Operationoperator: 46
operands: 39
36Literal
37Operationoperator: 40
operands: 41
38ExprTuple58, 42
39ExprTuple43, 44
40Literal
41ExprTuple44, 45
42Operationoperator: 46
operands: 47
43Operationoperator: 51
operand: 53
44Operationoperator: 49
operands: 50
45Operationoperator: 51
operand: 55
46Literal
47ExprTuple54, 58
48ExprTuple53
49Literal
50ExprTuple58, 54
51Literal
52ExprTuple55
53Operationoperator: 56
operands: 57
54Variable
55Literal
56Literal
57ExprTuple58, 59, 60, 61, 62
58Literal
59Literal
60Literal
61Variable
62Variable