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, n, x
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Exp, Interval, Natural, Sum, frac, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [n], instance_expr = Equals(Sum(index_or_indices = [i], summand = Exp(x, i), domain = Interval(zero, n)), frac(subtract(one, Exp(x, Add(n, one))), subtract(one, x))), domain = Natural)
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_{n \in \mathbb{N}}~\left(\left(\sum_{i = 0}^{n} x^{i}\right) = \frac{1 - x^{n + 1}}{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: 47
body: 5
4ExprTuple47
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 30
operands: 10
8Literal
9ExprTuple11, 12
10ExprTuple47, 13
11Operationoperator: 14
operand: 18
12Operationoperator: 16
operands: 17
13Literal
14Literal
15ExprTuple18
16Literal
17ExprTuple19, 20
18Lambdaparameter: 35
body: 22
19Operationoperator: 45
operands: 23
20Operationoperator: 45
operands: 24
21ExprTuple35
22Conditionalvalue: 25
condition: 26
23ExprTuple48, 27
24ExprTuple48, 28
25Operationoperator: 40
operands: 29
26Operationoperator: 30
operands: 31
27Operationoperator: 33
operand: 37
28Operationoperator: 33
operand: 43
29ExprTuple43, 35
30Literal
31ExprTuple35, 36
32ExprTuple37
33Literal
34ExprTuple43
35Variable
36Operationoperator: 38
operands: 39
37Operationoperator: 40
operands: 41
38Literal
39ExprTuple42, 47
40Literal
41ExprTuple43, 44
42Literal
43Variable
44Operationoperator: 45
operands: 46
45Literal
46ExprTuple47, 48
47Variable
48Literal