logo

Expression of type Lambda

from the theory of proveit.linear_algebra.scalar_multiplication

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 a_1_to_n, x_1_to_n
from proveit.linear_algebra import VecSpaces, lin_comb_axn
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 = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [x_1_to_n], instance_expr = InSet(lin_comb_axn, V), domain = V), domain = K), 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_{a_{1}, a_{2}, \ldots, a_{n} \in K}~\left[\forall_{x_{1}, x_{2}, \ldots, x_{n} \in V}~\left(\left(\left(a_{1} \cdot x_{1}\right) +  \left(a_{2} \cdot x_{2}\right) +  \ldots +  \left(a_{n} \cdot x_{n}\right)\right) \in V\right)\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: 56
body: 2
1ExprTuple56
2Conditionalvalue: 3
condition: 4
3Operationoperator: 29
operand: 7
4Operationoperator: 57
operands: 6
5ExprTuple7
6ExprTuple56, 8
7Lambdaparameter: 48
body: 9
8Literal
9Operationoperator: 29
operand: 11
10ExprTuple11
11Lambdaparameter: 60
body: 13
12ExprTuple60
13Conditionalvalue: 14
condition: 15
14Operationoperator: 29
operand: 19
15Operationoperator: 17
operands: 18
16ExprTuple19
17Literal
18ExprTuple60, 20
19Lambdaparameters: 21
body: 22
20Operationoperator: 23
operand: 48
21ExprTuple25
22Conditionalvalue: 26
condition: 27
23Literal
24ExprTuple48
25ExprRangelambda_map: 28
start_index: 55
end_index: 56
26Operationoperator: 29
operand: 32
27Operationoperator: 43
operands: 31
28Lambdaparameter: 68
body: 63
29Literal
30ExprTuple32
31ExprTuple33
32Lambdaparameters: 34
body: 35
33ExprRangelambda_map: 36
start_index: 55
end_index: 56
34ExprTuple37
35Conditionalvalue: 38
condition: 39
36Lambdaparameter: 68
body: 40
37ExprRangelambda_map: 41
start_index: 55
end_index: 56
38Operationoperator: 57
operands: 42
39Operationoperator: 43
operands: 44
40Operationoperator: 57
operands: 45
41Lambdaparameter: 68
body: 64
42ExprTuple46, 60
43Literal
44ExprTuple47
45ExprTuple63, 48
46Operationoperator: 49
operands: 50
47ExprRangelambda_map: 51
start_index: 55
end_index: 56
48Variable
49Literal
50ExprTuple52
51Lambdaparameter: 68
body: 53
52ExprRangelambda_map: 54
start_index: 55
end_index: 56
53Operationoperator: 57
operands: 58
54Lambdaparameter: 68
body: 59
55Literal
56Variable
57Literal
58ExprTuple64, 60
59Operationoperator: 61
operands: 62
60Variable
61Literal
62ExprTuple63, 64
63IndexedVarvariable: 65
index: 68
64IndexedVarvariable: 66
index: 68
65Variable
66Variable
67ExprTuple68
68Variable