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 eps
from proveit.logic import Equals, Forall
from proveit.numbers import Add, LessEq, ModAbs, NaturalPos, Neg
from proveit.physics.quantum.QPE import Psuccess, b_, m_, two_pow_t
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Forall([eps], Equals(Psuccess(eps), Prob(LessEq(ModAbs(Add(m_, Neg(b_)), two_pow_t), eps), m_)), domain = NaturalPos)
Out[2]:
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(expr.latex())
\forall_{\varepsilon \in \mathbb{N}^+}~\left(P_{\rm success}(\varepsilon) = Pr_{m}[\left|m - b\right|_{\textup{mod}\thinspace 2^{t}} \leq \varepsilon]\right)
In [5]:
expr.style_options()
Out[5]:
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
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
expr.expr_info()
Out[6]:
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 22
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple22, 13
11Operationoperator: 14
operand: 22
12Operationoperator: 16
operands: 17
13Literal
14Literal
15ExprTuple22
16Literal
17ExprTuple18, 31
18Operationoperator: 19
operands: 20
19Literal
20ExprTuple21, 22
21Operationoperator: 23
operands: 24
22Variable
23Literal
24ExprTuple25, 26
25Operationoperator: 27
operands: 28
26Operationoperator: 29
operands: 30
27Literal
28ExprTuple31, 32
29Literal
30ExprTuple33, 34
31Literal
32Operationoperator: 35
operand: 37
33Literal
34Literal
35Literal
36ExprTuple37
37Literal