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 K, Lambda, V, alpha, beta, x
from proveit.linear_algebra import ScalarMult, VecSpaces
from proveit.logic import Equals, Forall
In [2]:
# build up the expression from sub-expressions
expr = Lambda(K, Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [x], instance_expr = Forall(instance_param_or_params = [alpha, beta], instance_expr = Equals(ScalarMult(alpha, ScalarMult(beta, x)), ScalarMult(ScalarMult(alpha, beta), x)), domain = K), domain = V), domain = 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())
K \mapsto \left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{x \in V}~\left[\forall_{\alpha, \beta \in K}~\left(\left(\alpha \cdot \left(\beta \cdot x\right)\right) = \left(\left(\alpha \cdot \beta\right) \cdot x\right)\right)\right]\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: 42
body: 1
1Operationoperator: 19
operand: 3
2ExprTuple3
3Lambdaparameter: 23
body: 5
4ExprTuple23
5Conditionalvalue: 6
condition: 7
6Operationoperator: 19
operand: 11
7Operationoperator: 9
operands: 10
8ExprTuple11
9Literal
10ExprTuple23, 12
11Lambdaparameter: 46
body: 14
12Operationoperator: 15
operand: 42
13ExprTuple46
14Conditionalvalue: 17
condition: 18
15Literal
16ExprTuple42
17Operationoperator: 19
operand: 22
18Operationoperator: 38
operands: 21
19Literal
20ExprTuple22
21ExprTuple46, 23
22Lambdaparameters: 45
body: 24
23Variable
24Conditionalvalue: 25
condition: 26
25Operationoperator: 27
operands: 28
26Operationoperator: 29
operands: 30
27Literal
28ExprTuple31, 32
29Literal
30ExprTuple33, 34
31Operationoperator: 44
operands: 35
32Operationoperator: 44
operands: 36
33Operationoperator: 38
operands: 37
34Operationoperator: 38
operands: 39
35ExprTuple47, 40
36ExprTuple41, 46
37ExprTuple47, 42
38Literal
39ExprTuple48, 42
40Operationoperator: 44
operands: 43
41Operationoperator: 44
operands: 45
42Variable
43ExprTuple48, 46
44Literal
45ExprTuple47, 48
46Variable
47Variable
48Variable