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, alpha, beta, x
from proveit.linear_algebra import ScalarMult, VecSpaces
from proveit.logic import Equals, Forall, InClass
In [2]:
# build up the expression from sub-expressions
expr = Lambda(V, Conditional(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), 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_{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] \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: 20
body: 2
1ExprTuple20
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple20, 9
8Lambdaparameter: 43
body: 11
9Operationoperator: 12
operand: 39
10ExprTuple43
11Conditionalvalue: 14
condition: 15
12Literal
13ExprTuple39
14Operationoperator: 16
operand: 19
15Operationoperator: 35
operands: 18
16Literal
17ExprTuple19
18ExprTuple43, 20
19Lambdaparameters: 42
body: 21
20Variable
21Conditionalvalue: 22
condition: 23
22Operationoperator: 24
operands: 25
23Operationoperator: 26
operands: 27
24Literal
25ExprTuple28, 29
26Literal
27ExprTuple30, 31
28Operationoperator: 41
operands: 32
29Operationoperator: 41
operands: 33
30Operationoperator: 35
operands: 34
31Operationoperator: 35
operands: 36
32ExprTuple44, 37
33ExprTuple38, 43
34ExprTuple44, 39
35Literal
36ExprTuple45, 39
37Operationoperator: 41
operands: 40
38Operationoperator: 41
operands: 42
39Variable
40ExprTuple45, 43
41Literal
42ExprTuple44, 45
43Variable
44Variable
45Variable