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, j, k, x
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Exp, Integer, Interval, LessEq, Sum, frac, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [j, k], instance_expr = Equals(Sum(index_or_indices = [i], summand = Exp(x, i), domain = Interval(j, k)), frac(subtract(Exp(x, j), Exp(x, Add(k, one))), subtract(one, x))), domain = Integer, condition = LessEq(j, k))
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_{j, k \in \mathbb{Z}~|~j \leq k}~\left(\left(\sum_{i = j}^{k} x^{i}\right) = \frac{x^{j} - x^{k + 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
3Lambdaparameters: 47
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple13, 14, 15
11Operationoperator: 16
operand: 23
12Operationoperator: 18
operands: 19
13Operationoperator: 37
operands: 20
14Operationoperator: 37
operands: 21
15Operationoperator: 22
operands: 47
16Literal
17ExprTuple23
18Literal
19ExprTuple24, 25
20ExprTuple50, 26
21ExprTuple55, 26
22Literal
23Lambdaparameter: 43
body: 28
24Operationoperator: 53
operands: 29
25Operationoperator: 53
operands: 30
26Literal
27ExprTuple43
28Conditionalvalue: 31
condition: 32
29ExprTuple33, 34
30ExprTuple56, 35
31Operationoperator: 48
operands: 36
32Operationoperator: 37
operands: 38
33Operationoperator: 48
operands: 39
34Operationoperator: 41
operand: 45
35Operationoperator: 41
operand: 51
36ExprTuple51, 43
37Literal
38ExprTuple43, 44
39ExprTuple51, 50
40ExprTuple45
41Literal
42ExprTuple51
43Variable
44Operationoperator: 46
operands: 47
45Operationoperator: 48
operands: 49
46Literal
47ExprTuple50, 55
48Literal
49ExprTuple51, 52
50Variable
51Variable
52Operationoperator: 53
operands: 54
53Literal
54ExprTuple55, 56
55Variable
56Literal