logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(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(\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]\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 23
body: 2
2Operationoperator: 18
operand: 4
3ExprTuple4
4Lambdaparameter: 37
body: 6
5ExprTuple37
6Operationoperator: 7
operands: 8
7Literal
8ExprTuple9, 10
9Operationoperator: 40
operands: 11
10Operationoperator: 29
operands: 12
11ExprTuple37, 13
12ExprTuple14, 15
13Operationoperator: 16
operands: 23
14Operationoperator: 40
operands: 17
15Operationoperator: 18
operand: 21
16Literal
17ExprTuple37, 20
18Literal
19ExprTuple21
20Operationoperator: 22
operands: 23
21Lambdaparameters: 43
body: 24
22Literal
23ExprTuple44, 25
24Conditionalvalue: 26
condition: 27
25Variable
26Operationoperator: 42
operands: 28
27Operationoperator: 29
operands: 30
28ExprTuple31, 32
29Literal
30ExprTuple33, 34, 35
31Operationoperator: 37
operand: 45
32Operationoperator: 37
operand: 46
33Operationoperator: 40
operands: 39
34Operationoperator: 40
operands: 41
35Operationoperator: 42
operands: 43
36ExprTuple45
37Variable
38ExprTuple46
39ExprTuple45, 44
40Literal
41ExprTuple46, 44
42Literal
43ExprTuple45, 46
44Variable
45Variable
46Variable