logo

Expression of type Forall

from the theory of proveit.linear_algebra.addition

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, i, vi
from proveit.linear_algebra import VecAdd, VecSum
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Integer, Interval, Less, LessEq, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
expr = Forall(instance_param_or_params = [a, b, c], instance_expr = Equals(VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(a, c)), VecAdd(VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(a, b)), VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(Add(b, one), c)))), domain = Integer, conditions = [LessEq(a, b), Less(b, 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_{a, b, c \in \mathbb{Z}~|~a \leq b, b < c}~\left(\left(\sum_{i=a}^{c} v\left(i\right)\right) = \left(\left(\sum_{i=a}^{b} v\left(i\right)\right) + \left(\sum_{i=b + 1}^{c} v\left(i\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: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15, 16, 17, 18
12Operationoperator: 34
operand: 28
13Operationoperator: 20
operands: 21
14Operationoperator: 50
operands: 22
15Operationoperator: 50
operands: 23
16Operationoperator: 50
operands: 24
17Operationoperator: 25
operands: 55
18Operationoperator: 26
operands: 27
19ExprTuple28
20Literal
21ExprTuple29, 30
22ExprTuple58, 31
23ExprTuple63, 31
24ExprTuple60, 31
25Literal
26Literal
27ExprTuple63, 60
28Lambdaparameter: 53
body: 32
29Operationoperator: 34
operand: 37
30Operationoperator: 34
operand: 38
31Literal
32Conditionalvalue: 44
condition: 36
33ExprTuple37
34Literal
35ExprTuple38
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