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, ket0
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(TensorProd(ket0, ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), 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(\lvert 0 \rangle {\otimes} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \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: 56
body: 5
4ExprTuple56
5Conditionalvalue: 6
condition: 7
6Operationoperator: 9
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple56, 13
11Operationoperator: 15
operands: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple19, 20
15Literal
16ExprTuple21, 22
17Literal
18ExprTuple33, 23
19Operationoperator: 24
operand: 33
20Operationoperator: 26
operands: 27
21Operationoperator: 29
operands: 28
22Operationoperator: 29
operands: 30
23Operationoperator: 31
operands: 32
24Literal
25ExprTuple33
26Literal
27ExprTuple34, 35
28ExprTuple36, 52
29Literal
30ExprTuple36, 37
31Literal
32ExprTuple37, 38
33Literal
34Operationoperator: 42
operands: 39
35Operationoperator: 40
operands: 41
36Literal
37Operationoperator: 42
operands: 43
38Operationoperator: 44
operand: 49
39ExprTuple46, 47
40Literal
41ExprTuple56, 48
42Literal
43ExprTuple52, 48
44Literal
45ExprTuple49
46Literal
47Operationoperator: 50
operands: 51
48Variable
49Literal
50Literal
51ExprTuple52, 53, 54, 55, 56
52Literal
53Literal
54Literal
55Literal
56Variable