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, Equals, 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 = Equals(InSet(f, Injections(A, B)), And(InSet(f, Functions(A, B)), Forall(instance_param_or_params = [a, b], instance_expr = NotEquals(fa, fb), domain = A, condition = NotEquals(a, b)))).with_wrapping_at(2)))
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}~\left(\begin{array}{c} \begin{array}{l} \left(f \in \left[A \xrightarrow[]{\text{1-to-1}} B\right]\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) \end{array} \end{array}\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: 22
body: 1
1Operationoperator: 17
operand: 3
2ExprTuple3
3Lambdaparameter: 36
body: 5
4ExprTuple36
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Operationoperator: 39
operands: 10
9Operationoperator: 28
operands: 11
10ExprTuple36, 12
11ExprTuple13, 14
12Operationoperator: 15
operands: 22
13Operationoperator: 39
operands: 16
14Operationoperator: 17
operand: 20
15Literal
16ExprTuple36, 19
17Literal
18ExprTuple20
19Operationoperator: 21
operands: 22
20Lambdaparameters: 42
body: 23
21Literal
22ExprTuple43, 24
23Conditionalvalue: 25
condition: 26
24Variable
25Operationoperator: 41
operands: 27
26Operationoperator: 28
operands: 29
27ExprTuple30, 31
28Literal
29ExprTuple32, 33, 34
30Operationoperator: 36
operand: 44
31Operationoperator: 36
operand: 45
32Operationoperator: 39
operands: 38
33Operationoperator: 39
operands: 40
34Operationoperator: 41
operands: 42
35ExprTuple44
36Variable
37ExprTuple45
38ExprTuple44, 43
39Literal
40ExprTuple45, 43
41Literal
42ExprTuple44, 45
43Variable
44Variable
45Variable