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, m
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Exp, Mult, Neg, e, frac, i, 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 = Exp(e, Mult(two, pi, i, _phase, k))
sub_expr2 = Exp(e, Neg(frac(Mult(two, pi, i, k, m), _two_pow_t)))
sub_expr3 = InSet(k, _m_domain)
expr = Forall(instance_param_or_params = [k], instance_expr = Equals(Conditional(Mult(sub_expr1, sub_expr2), sub_expr3), Conditional(Mult(sub_expr2, sub_expr1), sub_expr3)))
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}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{2^{t}}} \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\right.. = \left\{\mathsf{e}^{-\frac{2 \cdot \pi \cdot \mathsf{i} \cdot k \cdot m}{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..\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: 49
body: 5
4ExprTuple49
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Conditionalvalue: 10
condition: 12
9Conditionalvalue: 11
condition: 12
10Operationoperator: 43
operands: 13
11Operationoperator: 43
operands: 14
12Operationoperator: 15
operands: 16
13ExprTuple18, 17
14ExprTuple17, 18
15Literal
16ExprTuple49, 19
17Operationoperator: 45
operands: 20
18Operationoperator: 45
operands: 21
19Operationoperator: 22
operands: 23
20ExprTuple25, 24
21ExprTuple25, 26
22Literal
23ExprTuple27, 28
24Operationoperator: 38
operand: 33
25Literal
26Operationoperator: 43
operands: 30
27Literal
28Operationoperator: 31
operands: 32
29ExprTuple33
30ExprTuple51, 47, 48, 34, 49
31Literal
32ExprTuple41, 35
33Operationoperator: 36
operands: 37
34Literal
35Operationoperator: 38
operand: 42
36Literal
37ExprTuple40, 41
38Literal
39ExprTuple42
40Operationoperator: 43
operands: 44
41Operationoperator: 45
operands: 46
42Literal
43Literal
44ExprTuple51, 47, 48, 49, 50
45Literal
46ExprTuple51, 52
47Literal
48Literal
49Variable
50Variable
51Literal
52Literal