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, fa, fx, x
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, Less, Sum, one
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(fa, Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(Add(a, one), b)))), 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(f\left(a\right) + \left(\sum_{x = a + 1}^{b} f\left(x\right)\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: 31
operand: 25
16Operationoperator: 51
operands: 21
17Operationoperator: 43
operands: 22
18Operationoperator: 43
operands: 23
19Operationoperator: 24
operands: 40
20ExprTuple25
21ExprTuple26, 27
22ExprTuple53, 28
23ExprTuple50, 28
24Literal
25Lambdaparameter: 45
body: 29
26Operationoperator: 41
operand: 53
27Operationoperator: 31
operand: 34
28Literal
29Conditionalvalue: 38
condition: 33
30ExprTuple53
31Literal
32ExprTuple34
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
40ExprTuple53, 50
41Variable
42ExprTuple45
43Literal
44ExprTuple45, 46
45Variable
46Operationoperator: 47
operands: 48
47Literal
48ExprTuple49, 50
49Operationoperator: 51
operands: 52
50Variable
51Literal
52ExprTuple53, 54
53Variable
54Literal