logo

Expression of type LessEq

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, l
from proveit.numbers import Add, Exp, Interval, LessEq, Mult, Sum, four, frac, one, subtract, two
from proveit.physics.quantum.QPE import _two_pow__t_minus_one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = frac(one, two)
sub_expr2 = Mult(frac(one, four), frac(one, Exp(e, two)))
expr = LessEq(Add(Mult(sub_expr1, Sum(index_or_indices = [l], summand = frac(one, Exp(l, two)), domain = Interval(Add(e, one), subtract(_two_pow__t_minus_one, one)))), sub_expr2), Add(Mult(sub_expr1, frac(one, e)), sub_expr2))
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())
\left(\left(\frac{1}{2} \cdot \left(\sum_{l = e + 1}^{2^{t - 1} - 1} \frac{1}{l^{2}}\right)\right) + \left(\frac{1}{4} \cdot \frac{1}{e^{2}}\right)\right) \leq \left(\left(\frac{1}{2} \cdot \frac{1}{e}\right) + \left(\frac{1}{4} \cdot \frac{1}{e^{2}}\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 53
operands: 5
4Operationoperator: 53
operands: 6
5ExprTuple7, 9
6ExprTuple8, 9
7Operationoperator: 12
operands: 10
8Operationoperator: 12
operands: 11
9Operationoperator: 12
operands: 13
10ExprTuple15, 14
11ExprTuple15, 16
12Literal
13ExprTuple17, 18
14Operationoperator: 19
operand: 25
15Operationoperator: 33
operands: 21
16Operationoperator: 33
operands: 22
17Operationoperator: 33
operands: 23
18Operationoperator: 33
operands: 24
19Literal
20ExprTuple25
21ExprTuple59, 51
22ExprTuple59, 47
23ExprTuple59, 26
24ExprTuple59, 27
25Lambdaparameter: 42
body: 29
26Literal
27Operationoperator: 49
operands: 30
28ExprTuple42
29Conditionalvalue: 31
condition: 32
30ExprTuple47, 51
31Operationoperator: 33
operands: 34
32Operationoperator: 35
operands: 36
33Literal
34ExprTuple59, 37
35Literal
36ExprTuple42, 38
37Operationoperator: 49
operands: 39
38Operationoperator: 40
operands: 41
39ExprTuple42, 51
40Literal
41ExprTuple43, 44
42Variable
43Operationoperator: 53
operands: 45
44Operationoperator: 53
operands: 46
45ExprTuple47, 59
46ExprTuple48, 56
47Variable
48Operationoperator: 49
operands: 50
49Literal
50ExprTuple51, 52
51Literal
52Operationoperator: 53
operands: 54
53Literal
54ExprTuple55, 56
55Literal
56Operationoperator: 57
operand: 59
57Literal
58ExprTuple59
59Literal