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.linear_algebra import ScalarMult
from proveit.logic import CartExp, Forall, InSet
from proveit.numbers import Complex, Exp, Mult, e, i, pi, two
from proveit.physics.quantum import NumKet
from proveit.physics.quantum.QPE import _m_domain, _phase, _t, _two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [k], instance_expr = InSet(ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, _t)), CartExp(Complex, _two_pow_t)), domain = _m_domain)
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 \lvert k \rangle_{t}\right) \in \mathbb{C}^{2^{t}}\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: 43
body: 5
4ExprTuple43
5Conditionalvalue: 6
condition: 7
6Operationoperator: 9
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple43, 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operands: 19
14Literal
15ExprTuple20, 21
16Literal
17ExprTuple22, 32
18Literal
19ExprTuple23, 24
20Operationoperator: 36
operands: 25
21Operationoperator: 26
operands: 27
22Literal
23Literal
24Operationoperator: 28
operands: 29
25ExprTuple30, 31
26Literal
27ExprTuple43, 45
28Literal
29ExprTuple32, 33
30Literal
31Operationoperator: 34
operands: 35
32Operationoperator: 36
operands: 37
33Operationoperator: 38
operand: 46
34Literal
35ExprTuple44, 40, 41, 42, 43
36Literal
37ExprTuple44, 45
38Literal
39ExprTuple46
40Literal
41Literal
42Literal
43Variable
44Literal
45Literal
46Literal