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, f, g, k, l, m, n
from proveit.logic import Equals, Forall, Implies
from proveit.numbers import Integer, Interval, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
sub_expr2 = [l]
sub_expr3 = Interval(m, n)
expr = Forall(instance_param_or_params = [f, g], instance_expr = Forall(instance_param_or_params = [m, n], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(Function(f, sub_expr1), Function(g, sub_expr1)), domain = sub_expr3), Equals(Sum(index_or_indices = sub_expr2, summand = Function(f, sub_expr2), domain = sub_expr3), Sum(index_or_indices = sub_expr2, summand = Function(g, sub_expr2), domain = sub_expr3))), 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_{f, g}~\left[\forall_{m, n \in \mathbb{Z}}~\left(\left[\forall_{k \in \{m~\ldotp \ldotp~n\}}~\left(f\left(k\right) = g\left(k\right)\right)\right] \Rightarrow \left(\left(\sum_{l = m}^{n} f\left(l\right)\right) = \left(\sum_{l = m}^{n} g\left(l\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: 18
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple46, 47
4Operationoperator: 18
operand: 6
5ExprTuple6
6Lambdaparameters: 55
body: 7
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14, 15
12Literal
13ExprTuple16, 17
14Operationoperator: 18
operand: 23
15Operationoperator: 35
operands: 20
16Operationoperator: 49
operands: 21
17Operationoperator: 49
operands: 22
18Literal
19ExprTuple23
20ExprTuple24, 25
21ExprTuple56, 26
22ExprTuple57, 26
23Lambdaparameter: 51
body: 27
24Operationoperator: 29
operand: 33
25Operationoperator: 29
operand: 34
26Literal
27Conditionalvalue: 31
condition: 32
28ExprTuple33
29Literal
30ExprTuple34
31Operationoperator: 35
operands: 36
32Operationoperator: 49
operands: 37
33Lambdaparameter: 52
body: 38
34Lambdaparameter: 52
body: 39
35Literal
36ExprTuple40, 41
37ExprTuple51, 53
38Conditionalvalue: 42
condition: 44
39Conditionalvalue: 43
condition: 44
40Operationoperator: 46
operand: 51
41Operationoperator: 47
operand: 51
42Operationoperator: 46
operand: 52
43Operationoperator: 47
operand: 52
44Operationoperator: 49
operands: 50
45ExprTuple51
46Variable
47Variable
48ExprTuple52
49Literal
50ExprTuple52, 53
51Variable
52Variable
53Operationoperator: 54
operands: 55
54Literal
55ExprTuple56, 57
56Variable
57Variable