logo

Expression of type And

from the theory of proveit.numbers.summation

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 i, m, x
from proveit.logic import And, Equals, Forall, TRUE
from proveit.numbers import Add, Exp, Interval, Natural, Sum, frac, one, subtract, two, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
sub_expr2 = Exp(x, i)
sub_expr3 = Add(m, one)
sub_expr4 = subtract(one, x)
expr = And(TRUE, Forall(instance_param_or_params = [m], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = Interval(zero, sub_expr3)), frac(subtract(one, Exp(x, Add(m, two))), sub_expr4)), domain = Natural, condition = Equals(Sum(index_or_indices = sub_expr1, summand = sub_expr2, domain = Interval(zero, m)), frac(subtract(one, Exp(x, sub_expr3)), sub_expr4))))
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())
\top \land \left[\forall_{m \in \mathbb{N}~|~\left(\sum_{i = 0}^{m} x^{i}\right) = \frac{1 - x^{m + 1}}{1 - x}}~\left(\left(\sum_{i = 0}^{m + 1} x^{i}\right) = \frac{1 - x^{m + 2}}{1 - x}\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',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 12
operands: 1
1ExprTuple2, 3
2Literal
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameter: 74
body: 8
7ExprTuple74
8Conditionalvalue: 9
condition: 10
9Operationoperator: 21
operands: 11
10Operationoperator: 12
operands: 13
11ExprTuple14, 15
12Literal
13ExprTuple16, 17
14Operationoperator: 30
operand: 23
15Operationoperator: 32
operands: 19
16Operationoperator: 54
operands: 20
17Operationoperator: 21
operands: 22
18ExprTuple23
19ExprTuple24, 38
20ExprTuple74, 25
21Literal
22ExprTuple26, 27
23Lambdaparameter: 60
body: 28
24Operationoperator: 72
operands: 29
25Literal
26Operationoperator: 30
operand: 36
27Operationoperator: 32
operands: 33
28Conditionalvalue: 47
condition: 34
29ExprTuple75, 35
30Literal
31ExprTuple36
32Literal
33ExprTuple37, 38
34Operationoperator: 54
operands: 39
35Operationoperator: 57
operand: 46
36Lambdaparameter: 60
body: 42
37Operationoperator: 72
operands: 43
38Operationoperator: 72
operands: 44
39ExprTuple60, 45
40ExprTuple46
41ExprTuple60
42Conditionalvalue: 47
condition: 48
43ExprTuple75, 49
44ExprTuple75, 50
45Operationoperator: 64
operands: 51
46Operationoperator: 66
operands: 52
47Operationoperator: 66
operands: 53
48Operationoperator: 54
operands: 55
49Operationoperator: 57
operand: 62
50Operationoperator: 57
operand: 70
51ExprTuple69, 71
52ExprTuple70, 59
53ExprTuple70, 60
54Literal
55ExprTuple60, 61
56ExprTuple62
57Literal
58ExprTuple70
59Operationoperator: 72
operands: 63
60Variable
61Operationoperator: 64
operands: 65
62Operationoperator: 66
operands: 67
63ExprTuple74, 68
64Literal
65ExprTuple69, 74
66Literal
67ExprTuple70, 71
68Literal
69Literal
70Variable
71Operationoperator: 72
operands: 73
72Literal
73ExprTuple74, 75
74Variable
75Literal