logo

Expression of type Lambda

from the theory of proveit.logic.sets.functions

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 A, B, Conditional, Lambda, f, fx, x
from proveit.logic import Forall, Functions, InSet
In [2]:
# build up the expression from sub-expressions
expr = Lambda(f, Conditional(InSet(f, Functions(A, B)), Forall(instance_param_or_params = [x], instance_expr = InSet(fx, B), domain = A)))
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())
f \mapsto \left\{f \in \left[A \rightarrow B\right] \textrm{ if } \forall_{x \in A}~\left(f\left(x\right) \in B\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: 21
body: 2
1ExprTuple21
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operands: 5
4Operationoperator: 6
operand: 9
5ExprTuple21, 8
6Literal
7ExprTuple9
8Operationoperator: 10
operands: 11
9Lambdaparameter: 23
body: 12
10Literal
11ExprTuple20, 19
12Conditionalvalue: 13
condition: 14
13Operationoperator: 16
operands: 15
14Operationoperator: 16
operands: 17
15ExprTuple18, 19
16Literal
17ExprTuple23, 20
18Operationoperator: 21
operand: 23
19Variable
20Variable
21Variable
22ExprTuple23
23Variable