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, t
from proveit.linear_algebra import ScalarMult, VecSum
from proveit.logic import Equals, Forall
from proveit.numbers import Exp, Interval, Mult, NaturalPos, e, frac, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet
from proveit.physics.quantum.QPE import _phase, _psi_t_ket, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [t], instance_expr = Equals(_psi_t_ket, ScalarMult(frac(one, Exp(two, frac(t, two))), VecSum(index_or_indices = [k], summand = ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, t)), domain = Interval(zero, subtract(two_pow_t, one))))), domain = 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())
\forall_{t \in \mathbb{N}^+}~\left(\lvert \psi_{t} \rangle = \left(\frac{1}{2^{\frac{t}{2}}} \cdot \left(\sum_{k=0}^{2^{t} - 1} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t}\right)\right)\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
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
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 62
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 33
operands: 9
7Literal
8ExprTuple10, 11
9ExprTuple62, 12
10Operationoperator: 13
operand: 62
11Operationoperator: 31
operands: 15
12Literal
13Literal
14ExprTuple62
15ExprTuple16, 17
16Operationoperator: 29
operands: 18
17Operationoperator: 19
operand: 22
18ExprTuple63, 21
19Literal
20ExprTuple22
21Operationoperator: 57
operands: 23
22Lambdaparameter: 54
body: 25
23ExprTuple61, 26
24ExprTuple54
25Conditionalvalue: 27
condition: 28
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operands: 32
28Operationoperator: 33
operands: 34
29Literal
30ExprTuple62, 61
31Literal
32ExprTuple35, 36
33Literal
34ExprTuple54, 37
35Operationoperator: 57
operands: 38
36Operationoperator: 39
operands: 40
37Operationoperator: 41
operands: 42
38ExprTuple43, 44
39Literal
40ExprTuple54, 62
41Literal
42ExprTuple45, 46
43Literal
44Operationoperator: 47
operands: 48
45Literal
46Operationoperator: 49
operands: 50
47Literal
48ExprTuple61, 51, 52, 53, 54
49Literal
50ExprTuple55, 56
51Literal
52Literal
53Literal
54Variable
55Operationoperator: 57
operands: 58
56Operationoperator: 59
operand: 63
57Literal
58ExprTuple61, 62
59Literal
60ExprTuple63
61Literal
62Variable
63Literal