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, j, k, n
from proveit.logic import And, Equals, InSet
from proveit.numbers import Exp, Interval, Mult, e, frac, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumBra, NumKet, Qmult
from proveit.physics.quantum.QFT import FourierTransform
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(k, n), FourierTransform(n), NumKet(j, n)), Qmult(frac(one, Exp(two, frac(n, two))), Exp(e, frac(Mult(two, pi, i, j, k), sub_expr1)))), And(InSet(j, sub_expr2), InSet(k, 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 k \rvert \thinspace {\mathrm {FT}}_{n} \thinspace \lvert j \rangle_{n}\right) = \left(\frac{1}{2^{\frac{n}{2}}} \thinspace \mathsf{e}^{\frac{2 \cdot \pi \cdot \mathsf{i} \cdot j \cdot k}{2^{n}}}\right) \textrm{ if } j \in \{0~\ldotp \ldotp~2^{n} - 1\} ,  k \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: 12
operands: 11
8Operationoperator: 12
operands: 13
9Operationoperator: 15
operands: 14
10Operationoperator: 15
operands: 16
11ExprTuple17, 18, 19
12Literal
13ExprTuple20, 21
14ExprTuple56, 22
15Literal
16ExprTuple57, 22
17Operationoperator: 23
operands: 24
18Operationoperator: 25
operand: 59
19Operationoperator: 27
operands: 28
20Operationoperator: 46
operands: 29
21Operationoperator: 50
operands: 30
22Operationoperator: 31
operands: 32
23Literal
24ExprTuple57, 59
25Literal
26ExprTuple59
27Literal
28ExprTuple56, 59
29ExprTuple60, 33
30ExprTuple34, 35
31Literal
32ExprTuple36, 37
33Operationoperator: 50
operands: 38
34Literal
35Operationoperator: 46
operands: 39
36Literal
37Operationoperator: 40
operands: 41
38ExprTuple58, 42
39ExprTuple43, 44
40Literal
41ExprTuple44, 45
42Operationoperator: 46
operands: 47
43Operationoperator: 48
operands: 49
44Operationoperator: 50
operands: 51
45Operationoperator: 52
operand: 60
46Literal
47ExprTuple59, 58
48Literal
49ExprTuple58, 54, 55, 56, 57
50Literal
51ExprTuple58, 59
52Literal
53ExprTuple60
54Literal
55Literal
56Variable
57Variable
58Literal
59Variable
60Literal