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, i, vb, vi
from proveit.linear_algebra import VecAdd, VecSum
from proveit.logic import Equals, Forall
from proveit.numbers import Integer, Interval, Less, one, subtract
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [i]
expr = Forall(instance_param_or_params = [a, b], instance_expr = Equals(VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(a, b)), VecAdd(VecSum(index_or_indices = sub_expr1, summand = vi, domain = Interval(a, subtract(b, one))), vb)), domain = Integer, condition = Less(a, b))
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 \in \mathbb{Z}~|~a < b}~\left(\left(\sum_{i=a}^{b} v\left(i\right)\right) = \left(\left(\sum_{i=a}^{b - 1} v\left(i\right)\right) + v\left(b\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: 37
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple13, 14, 15
11Operationoperator: 27
operand: 22
12Operationoperator: 17
operands: 18
13Operationoperator: 40
operands: 19
14Operationoperator: 40
operands: 20
15Operationoperator: 21
operands: 37
16ExprTuple22
17Literal
18ExprTuple23, 24
19ExprTuple46, 25
20ExprTuple50, 25
21Literal
22Lambdaparameter: 42
body: 26
23Operationoperator: 27
operand: 31
24Operationoperator: 38
operand: 50
25Literal
26Conditionalvalue: 35
condition: 30
27Literal
28ExprTuple31
29ExprTuple50
30Operationoperator: 40
operands: 32
31Lambdaparameter: 42
body: 33
32ExprTuple42, 34
33Conditionalvalue: 35
condition: 36
34Operationoperator: 44
operands: 37
35Operationoperator: 38
operand: 42
36Operationoperator: 40
operands: 41
37ExprTuple46, 50
38Variable
39ExprTuple42
40Literal
41ExprTuple42, 43
42Variable
43Operationoperator: 44
operands: 45
44Literal
45ExprTuple46, 47
46Variable
47Operationoperator: 48
operands: 49
48Literal
49ExprTuple50, 51
50Variable
51Operationoperator: 52
operand: 54
52Literal
53ExprTuple54
54Literal