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
from proveit.logic import Equals, Forall, InSet
In [2]:
# build up the expression from sub-expressions
expr = Lambda(x, Conditional(Forall(instance_param_or_params = [alpha, beta], instance_expr = Equals(ScalarMult(alpha, ScalarMult(beta, x)), ScalarMult(ScalarMult(alpha, beta), x)), domain = K), InSet(x, 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())
x \mapsto \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) \textrm{ if } x \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: 32
body: 2
1ExprTuple32
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 24
operands: 7
5Literal
6ExprTuple8
7ExprTuple32, 9
8Lambdaparameters: 31
body: 10
9Variable
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17, 18
15Literal
16ExprTuple19, 20
17Operationoperator: 30
operands: 21
18Operationoperator: 30
operands: 22
19Operationoperator: 24
operands: 23
20Operationoperator: 24
operands: 25
21ExprTuple33, 26
22ExprTuple27, 32
23ExprTuple33, 28
24Literal
25ExprTuple34, 28
26Operationoperator: 30
operands: 29
27Operationoperator: 30
operands: 31
28Variable
29ExprTuple34, 32
30Literal
31ExprTuple33, 34
32Variable
33Variable
34Variable