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, Lambda, V, i, j, k, v
from proveit.linear_algebra import ScalarMult, VecSum
from proveit.logic import Equals, InSet
from proveit.numbers import Add, Interval, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Lambda(v, Conditional(Equals(VecSum(index_or_indices = [i], summand = v, domain = Interval(j, k)), ScalarMult(Add(subtract(k, j), one), v)), InSet(v, V)))
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\{\left(\sum_{i=j}^{k} v\right) = \left(\left(\left(k - j\right) + 1\right) \cdot v\right) \textrm{ if } v \in V\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 20
body: 2
1ExprTuple20
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 24
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple20, 10
8Operationoperator: 11
operand: 15
9Operationoperator: 13
operands: 14
10Variable
11Literal
12ExprTuple15
13Literal
14ExprTuple16, 20
15Lambdaparameter: 28
body: 18
16Operationoperator: 26
operands: 19
17ExprTuple28
18Conditionalvalue: 20
condition: 21
19ExprTuple22, 23
20Variable
21Operationoperator: 24
operands: 25
22Operationoperator: 26
operands: 27
23Literal
24Literal
25ExprTuple28, 29
26Literal
27ExprTuple35, 30
28Variable
29Operationoperator: 31
operands: 32
30Operationoperator: 33
operand: 36
31Literal
32ExprTuple36, 35
33Literal
34ExprTuple36
35Variable
36Variable