logo

Expression of type Lambda

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, Lambda, 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 = Lambda(K, 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())
K \mapsto \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()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 34
body: 1
1Operationoperator: 22
operand: 3
2ExprTuple3
3Lambdaparameters: 62
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 22
operand: 10
6Operationoperator: 8
operands: 9
7ExprTuple10
8Literal
9ExprTuple11, 12, 13
10Lambdaparameter: 40
body: 15
11Operationoperator: 54
operands: 16
12Operationoperator: 54
operands: 17
13Operationoperator: 18
operands: 62
14ExprTuple40
15Conditionalvalue: 19
condition: 20
16ExprTuple66, 21
17ExprTuple65, 21
18Literal
19Operationoperator: 22
operand: 26
20Operationoperator: 24
operands: 25
21Literal
22Literal
23ExprTuple26
24Literal
25ExprTuple40, 27
26Lambdaparameter: 50
body: 29
27Operationoperator: 30
operand: 34
28ExprTuple50
29Conditionalvalue: 32
condition: 33
30Literal
31ExprTuple34
32Operationoperator: 35
operands: 36
33Operationoperator: 54
operands: 37
34Variable
35Literal
36ExprTuple38, 39
37ExprTuple50, 40
38Operationoperator: 41
operand: 45
39Operationoperator: 43
operands: 44
40Variable
41Literal
42ExprTuple45
43Literal
44ExprTuple46, 50
45Lambdaparameter: 58
body: 48
46Operationoperator: 56
operands: 49
47ExprTuple58
48Conditionalvalue: 50
condition: 51
49ExprTuple52, 53
50Variable
51Operationoperator: 54
operands: 55
52Operationoperator: 56
operands: 57
53Literal
54Literal
55ExprTuple58, 59
56Literal
57ExprTuple65, 60
58Variable
59Operationoperator: 61
operands: 62
60Operationoperator: 63
operand: 66
61Literal
62ExprTuple66, 65
63Literal
64ExprTuple66
65Variable
66Variable