logo

Expression of type Lambda

from the theory of proveit.logic.sets.functions.injections

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, Lambda, a, b, f, fa, fb
from proveit.logic import And, Forall, Functions, InSet, Injections, NotEquals
In [2]:
# build up the expression from sub-expressions
expr = Lambda([A, B], Forall(instance_param_or_params = [f], instance_expr = And(InSet(f, Functions(A, B)), Forall(instance_param_or_params = [a, b], instance_expr = NotEquals(fa, fb), domain = A, condition = NotEquals(a, b))), domain = Injections(A, B)))
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())
\left(A, B\right) \mapsto \left[\forall_{f \in \left[A \xrightarrow[]{\text{1-to-1}} B\right]}~\left(\left(f \in \left[A \rightarrow B\right]\right) \land \left[\forall_{a, b \in A~|~a \neq b}~\left(f\left(a\right) \neq f\left(b\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
0Lambdaparameters: 20
body: 1
1Operationoperator: 14
operand: 3
2ExprTuple3
3Lambdaparameter: 34
body: 5
4ExprTuple34
5Conditionalvalue: 6
condition: 7
6Operationoperator: 26
operands: 8
7Operationoperator: 37
operands: 9
8ExprTuple10, 11
9ExprTuple34, 12
10Operationoperator: 37
operands: 13
11Operationoperator: 14
operand: 18
12Operationoperator: 16
operands: 20
13ExprTuple34, 17
14Literal
15ExprTuple18
16Literal
17Operationoperator: 19
operands: 20
18Lambdaparameters: 40
body: 21
19Literal
20ExprTuple41, 22
21Conditionalvalue: 23
condition: 24
22Variable
23Operationoperator: 39
operands: 25
24Operationoperator: 26
operands: 27
25ExprTuple28, 29
26Literal
27ExprTuple30, 31, 32
28Operationoperator: 34
operand: 42
29Operationoperator: 34
operand: 43
30Operationoperator: 37
operands: 36
31Operationoperator: 37
operands: 38
32Operationoperator: 39
operands: 40
33ExprTuple42
34Variable
35ExprTuple43
36ExprTuple42, 41
37Literal
38ExprTuple43, 41
39Literal
40ExprTuple42, 43
41Variable
42Variable
43Variable