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 = [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_{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)
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: 14
operand: 2
1ExprTuple2
2Lambdaparameters: 51
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13
10Operationoperator: 14
operand: 19
11Operationoperator: 31
operands: 16
12Operationoperator: 45
operands: 17
13Operationoperator: 45
operands: 18
14Literal
15ExprTuple19
16ExprTuple20, 21
17ExprTuple52, 22
18ExprTuple53, 22
19Lambdaparameter: 47
body: 23
20Operationoperator: 25
operand: 29
21Operationoperator: 25
operand: 30
22Literal
23Conditionalvalue: 27
condition: 28
24ExprTuple29
25Literal
26ExprTuple30
27Operationoperator: 31
operands: 32
28Operationoperator: 45
operands: 33
29Lambdaparameter: 48
body: 34
30Lambdaparameter: 48
body: 35
31Literal
32ExprTuple36, 37
33ExprTuple47, 49
34Conditionalvalue: 38
condition: 40
35Conditionalvalue: 39
condition: 40
36Operationoperator: 42
operand: 47
37Operationoperator: 43
operand: 47
38Operationoperator: 42
operand: 48
39Operationoperator: 43
operand: 48
40Operationoperator: 45
operands: 46
41ExprTuple47
42Variable
43Variable
44ExprTuple48
45Literal
46ExprTuple48, 49
47Variable
48Variable
49Operationoperator: 50
operands: 51
50Literal
51ExprTuple52, 53
52Variable
53Variable