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 Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum.QPE import _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, Mult(two, pi, i, _phase, two_pow_t))
expr = Forall(instance_param_or_params = [k], instance_expr = Equals(Mult(sub_expr1, sub_expr2), Mult(sub_expr2, sub_expr1)), domain = Interval(zero, subtract(two_pow_t, one)))
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 \in \{0~\ldotp \ldotp~2^{t} - 1\}}~\left(\left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}}\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot 2^{t}} \cdot \mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k}\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: 40
body: 5
4ExprTuple40
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple40, 14
12Operationoperator: 32
operands: 15
13Operationoperator: 32
operands: 16
14Operationoperator: 17
operands: 18
15ExprTuple20, 19
16ExprTuple19, 20
17Literal
18ExprTuple21, 22
19Operationoperator: 42
operands: 23
20Operationoperator: 42
operands: 24
21Literal
22Operationoperator: 25
operands: 26
23ExprTuple28, 27
24ExprTuple28, 29
25Literal
26ExprTuple36, 30
27Operationoperator: 32
operands: 31
28Literal
29Operationoperator: 32
operands: 33
30Operationoperator: 34
operand: 41
31ExprTuple44, 37, 38, 39, 36
32Literal
33ExprTuple44, 37, 38, 39, 40
34Literal
35ExprTuple41
36Operationoperator: 42
operands: 43
37Literal
38Literal
39Literal
40Variable
41Literal
42Literal
43ExprTuple44, 45
44Literal
45Variable