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 Equals, Forall, InClass
from proveit.numbers import Add, Interval, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Lambda(V, Conditional(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), InClass(V, 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())
V \mapsto \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) \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\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: 23
body: 2
1ExprTuple23
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple23, 10
9Lambdaparameter: 33
body: 12
10Operationoperator: 13
operand: 17
11ExprTuple33
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple17
15Operationoperator: 18
operands: 19
16Operationoperator: 37
operands: 20
17Variable
18Literal
19ExprTuple21, 22
20ExprTuple33, 23
21Operationoperator: 24
operand: 28
22Operationoperator: 26
operands: 27
23Variable
24Literal
25ExprTuple28
26Literal
27ExprTuple29, 33
28Lambdaparameter: 41
body: 31
29Operationoperator: 39
operands: 32
30ExprTuple41
31Conditionalvalue: 33
condition: 34
32ExprTuple35, 36
33Variable
34Operationoperator: 37
operands: 38
35Operationoperator: 39
operands: 40
36Literal
37Literal
38ExprTuple41, 42
39Literal
40ExprTuple48, 43
41Variable
42Operationoperator: 44
operands: 45
43Operationoperator: 46
operand: 49
44Literal
45ExprTuple49, 48
46Literal
47ExprTuple49
48Variable
49Variable