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 Variable, t
from proveit.linear_algebra import MatrixExp, MatrixMult, ScalarMult
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Exp, Interval, Mult, Neg, e, i, one, pi, two, zero
from proveit.physics.quantum.QPE import _U, _ket_u, _phase
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = Exp(two, Neg(sub_expr1))
expr = Forall(instance_param_or_params = [sub_expr1], instance_expr = Equals(MatrixMult(MatrixExp(_U, sub_expr2), _ket_u), ScalarMult(Exp(e, Mult(two, pi, i, Mult(sub_expr2, _phase))), _ket_u)), domain = Interval(Add(Neg(t), one), zero))
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_{{_{-}a} \in \{-t + 1~\ldotp \ldotp~0\}}~\left(\left(U^{2^{-{_{-}a}}} \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \left(2^{-{_{-}a}} \cdot \varphi\right)} \cdot \lvert u \rangle\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: 51
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple51, 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operands: 19
14Literal
15ExprTuple20, 22
16Literal
17ExprTuple21, 22
18Literal
19ExprTuple23, 24
20Operationoperator: 25
operands: 26
21Operationoperator: 45
operands: 27
22Literal
23Operationoperator: 28
operands: 29
24Literal
25Literal
26ExprTuple30, 43
27ExprTuple31, 32
28Literal
29ExprTuple33, 34
30Literal
31Literal
32Operationoperator: 41
operands: 35
33Operationoperator: 49
operand: 40
34Literal
35ExprTuple47, 37, 38, 39
36ExprTuple40
37Literal
38Literal
39Operationoperator: 41
operands: 42
40Variable
41Literal
42ExprTuple43, 44
43Operationoperator: 45
operands: 46
44Literal
45Literal
46ExprTuple47, 48
47Literal
48Operationoperator: 49
operand: 51
49Literal
50ExprTuple51
51Variable