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, Integer, Interval, LessEq, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [j, k], instance_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)), domain = Integer, condition = LessEq(j, 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_{j, k \in \mathbb{Z}~|~j \leq k}~\left[\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]\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: 21
operand: 2
1ExprTuple2
2Lambdaparameters: 61
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 21
operand: 9
5Operationoperator: 7
operands: 8
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameter: 39
body: 14
10Operationoperator: 53
operands: 15
11Operationoperator: 53
operands: 16
12Operationoperator: 17
operands: 61
13ExprTuple39
14Conditionalvalue: 18
condition: 19
15ExprTuple65, 20
16ExprTuple64, 20
17Literal
18Operationoperator: 21
operand: 25
19Operationoperator: 23
operands: 24
20Literal
21Literal
22ExprTuple25
23Literal
24ExprTuple39, 26
25Lambdaparameter: 49
body: 28
26Operationoperator: 29
operand: 33
27ExprTuple49
28Conditionalvalue: 31
condition: 32
29Literal
30ExprTuple33
31Operationoperator: 34
operands: 35
32Operationoperator: 53
operands: 36
33Variable
34Literal
35ExprTuple37, 38
36ExprTuple49, 39
37Operationoperator: 40
operand: 44
38Operationoperator: 42
operands: 43
39Variable
40Literal
41ExprTuple44
42Literal
43ExprTuple45, 49
44Lambdaparameter: 57
body: 47
45Operationoperator: 55
operands: 48
46ExprTuple57
47Conditionalvalue: 49
condition: 50
48ExprTuple51, 52
49Variable
50Operationoperator: 53
operands: 54
51Operationoperator: 55
operands: 56
52Literal
53Literal
54ExprTuple57, 58
55Literal
56ExprTuple64, 59
57Variable
58Operationoperator: 60
operands: 61
59Operationoperator: 62
operand: 65
60Literal
61ExprTuple65, 64
62Literal
63ExprTuple65
64Variable
65Variable