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 V, i, j, k, v
from proveit.linear_algebra import ScalarMult, VecSum
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Interval, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [v], instance_expr = Equals(VecSum(index_or_indices = [i], summand = v, domain = Interval(j, k)), ScalarMult(Add(subtract(k, j), one), v)), domain = V)
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_{v \in V}~\left(\left(\sum_{i=j}^{k} v\right) = \left(\left(\left(k - j\right) + 1\right) \cdot v\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: 23
body: 5
4ExprTuple23
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 27
operands: 10
8Literal
9ExprTuple11, 12
10ExprTuple23, 13
11Operationoperator: 14
operand: 18
12Operationoperator: 16
operands: 17
13Variable
14Literal
15ExprTuple18
16Literal
17ExprTuple19, 23
18Lambdaparameter: 31
body: 21
19Operationoperator: 29
operands: 22
20ExprTuple31
21Conditionalvalue: 23
condition: 24
22ExprTuple25, 26
23Variable
24Operationoperator: 27
operands: 28
25Operationoperator: 29
operands: 30
26Literal
27Literal
28ExprTuple31, 32
29Literal
30ExprTuple38, 33
31Variable
32Operationoperator: 34
operands: 35
33Operationoperator: 36
operand: 39
34Literal
35ExprTuple39, 38
36Literal
37ExprTuple39
38Variable
39Variable