logo

Expression of type Forall

from the theory of proveit.physics.quantum.QPE

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 k
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Exp, Interval, Mult, Neg, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import p_k, phase_, t_
In [2]:
# build up the expression from sub-expressions
expr = Forall([k], Equals(p_k, Mult(frac(one, sqrt(two)), Add(ket0, Mult(Exp(e, Mult(two, pi, i, phase_, Exp(two, k))), ket1)))), domain = Interval(zero, Add(t_, Neg(one))))
Out[2]:
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(expr.latex())
\forall_{k \in \{0~\ldotp \ldotp~t - 1\}}~\left(p_{k} = \left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{k}} \cdot \lvert 1 \rangle\right)\right)\right)\right)
In [5]:
expr.style_options()
Out[5]:
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
expr.expr_info()
Out[6]:
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 57
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple57, 13
11Operationoperator: 14
operands: 15
12Operationoperator: 48
operands: 16
13Operationoperator: 17
operands: 18
14Literal
15ExprTuple19, 57
16ExprTuple20, 21
17Literal
18ExprTuple37, 22
19Literal
20Operationoperator: 40
operands: 23
21Operationoperator: 25
operands: 24
22Operationoperator: 25
operands: 26
23ExprTuple47, 27
24ExprTuple28, 29
25Literal
26ExprTuple30, 31
27Operationoperator: 54
operands: 32
28Operationoperator: 43
operand: 37
29Operationoperator: 48
operands: 34
30Literal
31Operationoperator: 35
operand: 47
32ExprTuple56, 36
33ExprTuple37
34ExprTuple38, 39
35Literal
36Operationoperator: 40
operands: 41
37Literal
38Operationoperator: 54
operands: 42
39Operationoperator: 43
operand: 47
40Literal
41ExprTuple47, 56
42ExprTuple45, 46
43Literal
44ExprTuple47
45Literal
46Operationoperator: 48
operands: 49
47Literal
48Literal
49ExprTuple56, 50, 51, 52, 53
50Literal
51Literal
52Literal
53Operationoperator: 54
operands: 55
54Literal
55ExprTuple56, 57
56Literal
57Variable