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, alpha, b, c, k
from proveit.core_expr_types import alpha_k
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Interval, Sum, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [k]
expr = Forall(instance_param_or_params = [alpha], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = alpha_k, domain = Interval(a, c)), Add(Sum(index_or_indices = sub_expr1, summand = alpha_k, domain = Interval(a, b)), Sum(index_or_indices = sub_expr1, summand = alpha_k, domain = Interval(Add(b, one), c)))))
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_{\alpha}~\left(\left(\sum_{k = a}^{c} \alpha_{k}\right) = \left(\left(\sum_{k = a}^{b} \alpha_{k}\right) + \left(\sum_{k = b + 1}^{c} \alpha_{k}\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
3Lambdaparameter: 31
body: 5
4ExprTuple31
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Operationoperator: 17
operand: 12
9Operationoperator: 44
operands: 11
10ExprTuple12
11ExprTuple13, 14
12Lambdaparameter: 36
body: 15
13Operationoperator: 17
operand: 20
14Operationoperator: 17
operand: 21
15Conditionalvalue: 27
condition: 19
16ExprTuple20
17Literal
18ExprTuple21
19Operationoperator: 33
operands: 22
20Lambdaparameter: 36
body: 23
21Lambdaparameter: 36
body: 24
22ExprTuple36, 25
23Conditionalvalue: 27
condition: 26
24Conditionalvalue: 27
condition: 28
25Operationoperator: 39
operands: 29
26Operationoperator: 33
operands: 30
27IndexedVarvariable: 31
index: 36
28Operationoperator: 33
operands: 34
29ExprTuple41, 43
30ExprTuple36, 35
31Variable
32ExprTuple36
33Literal
34ExprTuple36, 37
35Operationoperator: 39
operands: 38
36Variable
37Operationoperator: 39
operands: 40
38ExprTuple41, 46
39Literal
40ExprTuple42, 43
41Variable
42Operationoperator: 44
operands: 45
43Variable
44Literal
45ExprTuple46, 47
46Variable
47Literal