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 Conditional, k
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Exp, Mult, Neg, e, frac, i, one, pi, two
from proveit.physics.quantum.QPE import _m_domain, _phase, _two_pow_t
In [2]:
# build up the expression from sub-expressions
sub_expr1 = InSet(k, _m_domain)
expr = Forall(instance_param_or_params = [k], instance_expr = Equals(Conditional(Mult(Exp(e, Neg(frac(Mult(two, pi, i, k, Mult(_two_pow_t, _phase)), _two_pow_t))), Exp(e, Mult(two, pi, i, _phase, k))), sub_expr1), Conditional(one, sub_expr1)))
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_{k}~\left(\left\{\mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot \left(2^{t} \cdot \varphi\right)}{2^{t}}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\right.. = \left\{1 \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\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: 42
body: 5
4ExprTuple42
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Conditionalvalue: 10
condition: 11
9Conditionalvalue: 38
condition: 11
10Operationoperator: 44
operands: 12
11Operationoperator: 13
operands: 14
12ExprTuple15, 16
13Literal
14ExprTuple42, 17
15Operationoperator: 48
operands: 18
16Operationoperator: 48
operands: 19
17Operationoperator: 20
operands: 21
18ExprTuple23, 22
19ExprTuple23, 24
20Literal
21ExprTuple25, 26
22Operationoperator: 35
operand: 31
23Literal
24Operationoperator: 44
operands: 28
25Literal
26Operationoperator: 29
operands: 30
27ExprTuple31
28ExprTuple50, 40, 41, 47, 42
29Literal
30ExprTuple46, 32
31Operationoperator: 33
operands: 34
32Operationoperator: 35
operand: 38
33Literal
34ExprTuple37, 46
35Literal
36ExprTuple38
37Operationoperator: 44
operands: 39
38Literal
39ExprTuple50, 40, 41, 42, 43
40Literal
41Literal
42Variable
43Operationoperator: 44
operands: 45
44Literal
45ExprTuple46, 47
46Operationoperator: 48
operands: 49
47Literal
48Literal
49ExprTuple50, 51
50Literal
51Literal