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 Conditional, K, Lambda, V, i, j, k, v
from proveit.linear_algebra import ScalarMult, VecSpaces, VecSum
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Integer, Interval, LessEq, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Lambda([j, k], Conditional(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)), And(InSet(j, Integer), InSet(k, Integer), 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())
\left(j, k\right) \mapsto \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] \textrm{ if } j \in \mathbb{Z} ,  k \in \mathbb{Z} ,  j \leq k\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 59
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 19
operand: 7
3Operationoperator: 5
operands: 6
4ExprTuple7
5Literal
6ExprTuple8, 9, 10
7Lambdaparameter: 37
body: 12
8Operationoperator: 51
operands: 13
9Operationoperator: 51
operands: 14
10Operationoperator: 15
operands: 59
11ExprTuple37
12Conditionalvalue: 16
condition: 17
13ExprTuple63, 18
14ExprTuple62, 18
15Literal
16Operationoperator: 19
operand: 23
17Operationoperator: 21
operands: 22
18Literal
19Literal
20ExprTuple23
21Literal
22ExprTuple37, 24
23Lambdaparameter: 47
body: 26
24Operationoperator: 27
operand: 31
25ExprTuple47
26Conditionalvalue: 29
condition: 30
27Literal
28ExprTuple31
29Operationoperator: 32
operands: 33
30Operationoperator: 51
operands: 34
31Variable
32Literal
33ExprTuple35, 36
34ExprTuple47, 37
35Operationoperator: 38
operand: 42
36Operationoperator: 40
operands: 41
37Variable
38Literal
39ExprTuple42
40Literal
41ExprTuple43, 47
42Lambdaparameter: 55
body: 45
43Operationoperator: 53
operands: 46
44ExprTuple55
45Conditionalvalue: 47
condition: 48
46ExprTuple49, 50
47Variable
48Operationoperator: 51
operands: 52
49Operationoperator: 53
operands: 54
50Literal
51Literal
52ExprTuple55, 56
53Literal
54ExprTuple62, 57
55Variable
56Operationoperator: 58
operands: 59
57Operationoperator: 60
operand: 63
58Literal
59ExprTuple63, 62
60Literal
61ExprTuple63
62Variable
63Variable