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 e
from proveit.logic import Forall
from proveit.numbers import Add, Exp, LessEq, Mult, four, frac, one, two
from proveit.physics.quantum.QPE import Pfail, _e_domain
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [e], instance_expr = LessEq(Pfail(e), Add(frac(one, Mult(two, e)), frac(one, Mult(four, Exp(e, two))))), domain = _e_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_{e \in \{1~\ldotp \ldotp~2^{t - 1} - 2\}}~\left(\left[P_{\rm fail}\right]\left(e\right) \leq \left(\frac{1}{2 \cdot e} + \frac{1}{4 \cdot e^{2}}\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: 42
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple42, 13
11Operationoperator: 14
operand: 42
12Operationoperator: 40
operands: 16
13Operationoperator: 17
operands: 18
14Literal
15ExprTuple42
16ExprTuple19, 20
17Literal
18ExprTuple48, 21
19Operationoperator: 23
operands: 22
20Operationoperator: 23
operands: 24
21Operationoperator: 40
operands: 25
22ExprTuple48, 26
23Literal
24ExprTuple48, 27
25ExprTuple28, 29
26Operationoperator: 31
operands: 30
27Operationoperator: 31
operands: 32
28Operationoperator: 38
operands: 33
29Operationoperator: 46
operand: 43
30ExprTuple43, 42
31Literal
32ExprTuple35, 36
33ExprTuple43, 37
34ExprTuple43
35Literal
36Operationoperator: 38
operands: 39
37Operationoperator: 40
operands: 41
38Literal
39ExprTuple42, 43
40Literal
41ExprTuple44, 45
42Variable
43Literal
44Literal
45Operationoperator: 46
operand: 48
46Literal
47ExprTuple48
48Literal