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(TensorProd(ket1, 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 1 \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: 55
body: 5
4ExprTuple55
5Conditionalvalue: 6
condition: 7
6Operationoperator: 9
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple55, 13
11Operationoperator: 15
operands: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple19, 20
15Literal
16ExprTuple21, 22
17Literal
18ExprTuple23, 24
19Operationoperator: 25
operand: 48
20Operationoperator: 26
operands: 27
21Operationoperator: 29
operands: 28
22Operationoperator: 29
operands: 30
23Literal
24Operationoperator: 31
operands: 32
25Literal
26Literal
27ExprTuple33, 34
28ExprTuple35, 51
29Literal
30ExprTuple35, 36
31Literal
32ExprTuple36, 37
33Operationoperator: 41
operands: 38
34Operationoperator: 39
operands: 40
35Literal
36Operationoperator: 41
operands: 42
37Operationoperator: 43
operand: 48
38ExprTuple45, 46
39Literal
40ExprTuple55, 47
41Literal
42ExprTuple51, 47
43Literal
44ExprTuple48
45Literal
46Operationoperator: 49
operands: 50
47Variable
48Literal
49Literal
50ExprTuple51, 52, 53, 54, 55
51Literal
52Literal
53Literal
54Literal
55Variable