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 = [K], instance_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_{K}~\left[\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]\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: 24
operand: 2
1ExprTuple2
2Lambdaparameter: 36
body: 3
3Operationoperator: 24
operand: 5
4ExprTuple5
5Lambdaparameters: 64
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 24
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple13, 14, 15
12Lambdaparameter: 42
body: 17
13Operationoperator: 56
operands: 18
14Operationoperator: 56
operands: 19
15Operationoperator: 20
operands: 64
16ExprTuple42
17Conditionalvalue: 21
condition: 22
18ExprTuple68, 23
19ExprTuple67, 23
20Literal
21Operationoperator: 24
operand: 28
22Operationoperator: 26
operands: 27
23Literal
24Literal
25ExprTuple28
26Literal
27ExprTuple42, 29
28Lambdaparameter: 52
body: 31
29Operationoperator: 32
operand: 36
30ExprTuple52
31Conditionalvalue: 34
condition: 35
32Literal
33ExprTuple36
34Operationoperator: 37
operands: 38
35Operationoperator: 56
operands: 39
36Variable
37Literal
38ExprTuple40, 41
39ExprTuple52, 42
40Operationoperator: 43
operand: 47
41Operationoperator: 45
operands: 46
42Variable
43Literal
44ExprTuple47
45Literal
46ExprTuple48, 52
47Lambdaparameter: 60
body: 50
48Operationoperator: 58
operands: 51
49ExprTuple60
50Conditionalvalue: 52
condition: 53
51ExprTuple54, 55
52Variable
53Operationoperator: 56
operands: 57
54Operationoperator: 58
operands: 59
55Literal
56Literal
57ExprTuple60, 61
58Literal
59ExprTuple67, 62
60Variable
61Operationoperator: 63
operands: 64
62Operationoperator: 65
operand: 68
63Literal
64ExprTuple68, 67
65Literal
66ExprTuple68
67Variable
68Variable