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, c, fx, x
from proveit.logic import And, Equals, Forall
from proveit.numbers import Add, Integer, Interval, LessEq, Sum, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Forall(instance_param_or_params = [a, b, c], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, c)), Add(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(Add(b, one), c)))), domain = Integer, condition = And(LessEq(a, b), LessEq(b, c)).with_total_ordering_style())
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_{a, b, c \in \mathbb{Z}~|~a \leq b \leq c}~\left(\left(\sum_{x = a}^{c} f\left(x\right)\right) = \left(\left(\sum_{x = a}^{b} f\left(x\right)\right) + \left(\sum_{x = b + 1}^{c} f\left(x\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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple58, 63, 60
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 22
operands: 10
8Literal
9ExprTuple11, 12
10ExprTuple13, 14, 15, 16
11Operationoperator: 32
operand: 24
12Operationoperator: 61
operands: 18
13Operationoperator: 50
operands: 19
14Operationoperator: 50
operands: 20
15Operationoperator: 50
operands: 21
16Operationoperator: 22
operands: 23
17ExprTuple24
18ExprTuple25, 26
19ExprTuple58, 27
20ExprTuple63, 27
21ExprTuple60, 27
22Literal
23ExprTuple28, 29
24Lambdaparameter: 53
body: 30
25Operationoperator: 32
operand: 37
26Operationoperator: 32
operand: 38
27Literal
28Operationoperator: 34
operands: 55
29Operationoperator: 34
operands: 35
30Conditionalvalue: 44
condition: 36
31ExprTuple37
32Literal
33ExprTuple38
34Literal
35ExprTuple63, 60
36Operationoperator: 50
operands: 39
37Lambdaparameter: 53
body: 40
38Lambdaparameter: 53
body: 41
39ExprTuple53, 42
40Conditionalvalue: 44
condition: 43
41Conditionalvalue: 44
condition: 45
42Operationoperator: 56
operands: 46
43Operationoperator: 50
operands: 47
44Operationoperator: 48
operand: 53
45Operationoperator: 50
operands: 51
46ExprTuple58, 60
47ExprTuple53, 52
48Variable
49ExprTuple53
50Literal
51ExprTuple53, 54
52Operationoperator: 56
operands: 55
53Variable
54Operationoperator: 56
operands: 57
55ExprTuple58, 63
56Literal
57ExprTuple59, 60
58Variable
59Operationoperator: 61
operands: 62
60Variable
61Literal
62ExprTuple63, 64
63Variable
64Literal