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 K, V, i, j, k, v
from proveit.linear_algebra import ScalarMult, VecSpaces, 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 = 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), domain = VecSpaces(K))
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 \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{v \in V}~\left(\left(\sum_{i=j}^{k} v\right) = \left(\left(\left(k - j\right) + 1\right) \cdot v\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: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 25
body: 4
3ExprTuple25
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple25, 12
11Lambdaparameter: 35
body: 14
12Operationoperator: 15
operand: 19
13ExprTuple35
14Conditionalvalue: 17
condition: 18
15Literal
16ExprTuple19
17Operationoperator: 20
operands: 21
18Operationoperator: 39
operands: 22
19Variable
20Literal
21ExprTuple23, 24
22ExprTuple35, 25
23Operationoperator: 26
operand: 30
24Operationoperator: 28
operands: 29
25Variable
26Literal
27ExprTuple30
28Literal
29ExprTuple31, 35
30Lambdaparameter: 43
body: 33
31Operationoperator: 41
operands: 34
32ExprTuple43
33Conditionalvalue: 35
condition: 36
34ExprTuple37, 38
35Variable
36Operationoperator: 39
operands: 40
37Operationoperator: 41
operands: 42
38Literal
39Literal
40ExprTuple43, 44
41Literal
42ExprTuple50, 45
43Variable
44Operationoperator: 46
operands: 47
45Operationoperator: 48
operand: 51
46Literal
47ExprTuple51, 50
48Literal
49ExprTuple51
50Variable
51Variable