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, t
from proveit.linear_algebra import ScalarMult, TensorProd
from proveit.logic import CartExp, Forall, InSet
from proveit.numbers import Complex, Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet, QubitSpace, ket1
from proveit.physics.quantum.QPE import _phase, 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)), TensorProd(ket1, NumKet(k, t))), TensorProd(QubitSpace, CartExp(Complex, two_pow_t))), 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 \left(\lvert 1 \rangle {\otimes} \lvert k \rangle_{t}\right)\right) \in \left(\mathbb{C}^{2} {\otimes} \mathbb{C}^{2^{t}}\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: 52
body: 5
4ExprTuple52
5Conditionalvalue: 6
condition: 7
6Operationoperator: 9
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple52, 13
11Operationoperator: 14
operands: 15
12Operationoperator: 26
operands: 16
13Operationoperator: 17
operands: 18
14Literal
15ExprTuple19, 20
16ExprTuple21, 22
17Literal
18ExprTuple23, 24
19Operationoperator: 45
operands: 25
20Operationoperator: 26
operands: 27
21Operationoperator: 29
operands: 28
22Operationoperator: 29
operands: 30
23Literal
24Operationoperator: 31
operands: 32
25ExprTuple33, 34
26Literal
27ExprTuple35, 36
28ExprTuple37, 53
29Literal
30ExprTuple37, 38
31Literal
32ExprTuple38, 39
33Literal
34Operationoperator: 40
operands: 41
35Operationoperator: 42
operand: 55
36Operationoperator: 43
operands: 44
37Literal
38Operationoperator: 45
operands: 46
39Operationoperator: 47
operand: 55
40Literal
41ExprTuple53, 49, 50, 51, 52
42Literal
43Literal
44ExprTuple52, 54
45Literal
46ExprTuple53, 54
47Literal
48ExprTuple55
49Literal
50Literal
51Literal
52Variable
53Literal
54Variable
55Literal