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 a, b, f, fb, fx, x
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, Less, Sum, one, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Forall(instance_param_or_params = [f], instance_expr = Forall(instance_param_or_params = [a, b], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Add(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, subtract(b, one))), fb)), domain = Integer, condition = Less(a, b)))
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_{f}~\left[\forall_{a, b \in \mathbb{Z}~|~a < b}~\left(\left(\sum_{x = a}^{b} f\left(x\right)\right) = \left(\left(\sum_{x = a}^{b - 1} f\left(x\right)\right) + f\left(b\right)\right)\right)\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: 5
operand: 2
1ExprTuple2
2Lambdaparameter: 41
body: 4
3ExprTuple41
4Operationoperator: 5
operand: 7
5Literal
6ExprTuple7
7Lambdaparameters: 40
body: 8
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple17, 18, 19
15Operationoperator: 30
operand: 25
16Operationoperator: 51
operands: 21
17Operationoperator: 43
operands: 22
18Operationoperator: 43
operands: 23
19Operationoperator: 24
operands: 40
20ExprTuple25
21ExprTuple26, 27
22ExprTuple49, 28
23ExprTuple53, 28
24Literal
25Lambdaparameter: 45
body: 29
26Operationoperator: 30
operand: 34
27Operationoperator: 41
operand: 53
28Literal
29Conditionalvalue: 38
condition: 33
30Literal
31ExprTuple34
32ExprTuple53
33Operationoperator: 43
operands: 35
34Lambdaparameter: 45
body: 36
35ExprTuple45, 37
36Conditionalvalue: 38
condition: 39
37Operationoperator: 47
operands: 40
38Operationoperator: 41
operand: 45
39Operationoperator: 43
operands: 44
40ExprTuple49, 53
41Variable
42ExprTuple45
43Literal
44ExprTuple45, 46
45Variable
46Operationoperator: 47
operands: 48
47Literal
48ExprTuple49, 50
49Variable
50Operationoperator: 51
operands: 52
51Literal
52ExprTuple53, 54
53Variable
54Operationoperator: 55
operand: 57
55Literal
56ExprTuple57
57Literal