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 ScalarMult, VecAdd
from proveit.logic import CartExp, Forall, InSet
from proveit.numbers import Add, Complex, Exp, Interval, Mult, Neg, e, frac, i, one, pi, sqrt, two, zero
from proveit.physics.quantum import ket0, ket1
from proveit.physics.quantum.QPE import _phase
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Forall(instance_param_or_params = [sub_expr1], instance_expr = InSet(ScalarMult(frac(one, sqrt(two)), VecAdd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, Exp(two, Neg(sub_expr1)), _phase)), ket1))), CartExp(Complex, Exp(two, one))), domain = Interval(Add(Neg(t), two), 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 + 2~\ldotp \ldotp~0\}}~\left(\left(\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot 2^{-{_{-}a}} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)\right) \in \mathbb{C}^{2^{1}}\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: 63
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 8
operands: 7
6Operationoperator: 8
operands: 9
7ExprTuple10, 11
8Literal
9ExprTuple63, 12
10Operationoperator: 35
operands: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13ExprTuple18, 19
14Literal
15ExprTuple20, 21
16Literal
17ExprTuple22, 39
18Operationoperator: 43
operands: 23
19Operationoperator: 24
operands: 25
20Literal
21Operationoperator: 57
operands: 26
22Operationoperator: 27
operands: 28
23ExprTuple50, 29
24Literal
25ExprTuple30, 31
26ExprTuple59, 50
27Literal
28ExprTuple32, 59
29Operationoperator: 57
operands: 33
30Operationoperator: 46
operand: 39
31Operationoperator: 35
operands: 36
32Operationoperator: 61
operand: 42
33ExprTuple59, 38
34ExprTuple39
35Literal
36ExprTuple40, 41
37ExprTuple42
38Operationoperator: 43
operands: 44
39Literal
40Operationoperator: 57
operands: 45
41Operationoperator: 46
operand: 50
42Variable
43Literal
44ExprTuple50, 59
45ExprTuple48, 49
46Literal
47ExprTuple50
48Literal
49Operationoperator: 51
operands: 52
50Literal
51Literal
52ExprTuple59, 53, 54, 55, 56
53Literal
54Literal
55Operationoperator: 57
operands: 58
56Literal
57Literal
58ExprTuple59, 60
59Literal
60Operationoperator: 61
operand: 63
61Literal
62ExprTuple63
63Variable