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 Function, a, b, c, f, fx, x
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, Sum, subtract
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, b)), Sum(index_or_indices = sub_expr1, summand = Function(f, [subtract(x, c)]), domain = Interval(Add(a, c), Add(b, c)))), domain = Integer)
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}}~\left(\left(\sum_{x = a}^{b} f\left(x\right)\right) = \left(\sum_{x = a + c}^{b + c} f\left(x - c\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
4ExprTuple54, 55, 56
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15, 16
12Operationoperator: 18
operand: 23
13Operationoperator: 18
operand: 24
14Operationoperator: 36
operands: 20
15Operationoperator: 36
operands: 21
16Operationoperator: 36
operands: 22
17ExprTuple23
18Literal
19ExprTuple24
20ExprTuple54, 25
21ExprTuple55, 25
22ExprTuple56, 25
23Lambdaparameter: 45
body: 26
24Lambdaparameter: 45
body: 27
25Literal
26Conditionalvalue: 28
condition: 29
27Conditionalvalue: 30
condition: 31
28Operationoperator: 34
operand: 45
29Operationoperator: 36
operands: 33
30Operationoperator: 34
operand: 39
31Operationoperator: 36
operands: 37
32ExprTuple45
33ExprTuple45, 38
34Variable
35ExprTuple39
36Literal
37ExprTuple45, 40
38Operationoperator: 43
operands: 41
39Operationoperator: 52
operands: 42
40Operationoperator: 43
operands: 44
41ExprTuple54, 55
42ExprTuple45, 46
43Literal
44ExprTuple47, 48
45Variable
46Operationoperator: 49
operand: 56
47Operationoperator: 52
operands: 51
48Operationoperator: 52
operands: 53
49Literal
50ExprTuple56
51ExprTuple54, 56
52Literal
53ExprTuple55, 56
54Variable
55Variable
56Variable