logo

Expression of type Forall

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 Equals, Forall
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 = 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())
\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)
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: 71
body: 5
4ExprTuple71
5Conditionalvalue: 6
condition: 7
6Operationoperator: 18
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple13, 14
11Operationoperator: 27
operand: 20
12Operationoperator: 29
operands: 16
13Operationoperator: 51
operands: 17
14Operationoperator: 18
operands: 19
15ExprTuple20
16ExprTuple21, 35
17ExprTuple71, 22
18Literal
19ExprTuple23, 24
20Lambdaparameter: 57
body: 25
21Operationoperator: 69
operands: 26
22Literal
23Operationoperator: 27
operand: 33
24Operationoperator: 29
operands: 30
25Conditionalvalue: 44
condition: 31
26ExprTuple72, 32
27Literal
28ExprTuple33
29Literal
30ExprTuple34, 35
31Operationoperator: 51
operands: 36
32Operationoperator: 54
operand: 43
33Lambdaparameter: 57
body: 39
34Operationoperator: 69
operands: 40
35Operationoperator: 69
operands: 41
36ExprTuple57, 42
37ExprTuple43
38ExprTuple57
39Conditionalvalue: 44
condition: 45
40ExprTuple72, 46
41ExprTuple72, 47
42Operationoperator: 61
operands: 48
43Operationoperator: 63
operands: 49
44Operationoperator: 63
operands: 50
45Operationoperator: 51
operands: 52
46Operationoperator: 54
operand: 59
47Operationoperator: 54
operand: 67
48ExprTuple66, 68
49ExprTuple67, 56
50ExprTuple67, 57
51Literal
52ExprTuple57, 58
53ExprTuple59
54Literal
55ExprTuple67
56Operationoperator: 69
operands: 60
57Variable
58Operationoperator: 61
operands: 62
59Operationoperator: 63
operands: 64
60ExprTuple71, 65
61Literal
62ExprTuple66, 71
63Literal
64ExprTuple67, 68
65Literal
66Literal
67Variable
68Operationoperator: 69
operands: 70
69Literal
70ExprTuple71, 72
71Variable
72Literal