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, n
from proveit.core_expr_types import x_1_to_n
from proveit.linear_algebra import VecAdd, VecSpaces
from proveit.logic import Forall, InSet
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [K], instance_expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [x_1_to_n], instance_expr = InSet(VecAdd(x_1_to_n), V), domain = V), domain = VecSpaces(K))), InSet(n, NaturalPos)))
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())
n \mapsto \left\{\forall_{K}~\left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{x_{1}, x_{2}, \ldots, x_{n} \in V}~\left(\left(x_{1} +  x_{2} +  \ldots +  x_{n}\right) \in V\right)\right]\right] \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 40
body: 2
1ExprTuple40
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operand: 7
4Operationoperator: 41
operands: 6
5ExprTuple7
6ExprTuple40, 8
7Lambdaparameter: 27
body: 9
8Literal
9Operationoperator: 16
operand: 11
10ExprTuple11
11Lambdaparameter: 44
body: 13
12ExprTuple44
13Conditionalvalue: 14
condition: 15
14Operationoperator: 16
operand: 20
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20
18Literal
19ExprTuple44, 21
20Lambdaparameters: 34
body: 22
21Operationoperator: 23
operand: 27
22Conditionalvalue: 25
condition: 26
23Literal
24ExprTuple27
25Operationoperator: 41
operands: 28
26Operationoperator: 29
operands: 30
27Variable
28ExprTuple31, 44
29Literal
30ExprTuple32
31Operationoperator: 33
operands: 34
32ExprRangelambda_map: 35
start_index: 39
end_index: 40
33Literal
34ExprTuple36
35Lambdaparameter: 47
body: 37
36ExprRangelambda_map: 38
start_index: 39
end_index: 40
37Operationoperator: 41
operands: 42
38Lambdaparameter: 47
body: 43
39Literal
40Variable
41Literal
42ExprTuple43, 44
43IndexedVarvariable: 45
index: 47
44Variable
45Variable
46ExprTuple47
47Variable