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, Conditional, ExprTuple, 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 = ExprTuple(Lambda(f, Conditional(And(InSet(f, Functions(A, B)), Forall(instance_param_or_params = [a, b], instance_expr = NotEquals(fa, fb), domain = A, condition = NotEquals(a, b))), InSet(f, 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(f \mapsto \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] \textrm{ if } f \in \left[A \xrightarrow[]{\text{1-to-1}} B\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
1Lambdaparameter: 32
body: 3
2ExprTuple32
3Conditionalvalue: 4
condition: 5
4Operationoperator: 24
operands: 6
5Operationoperator: 35
operands: 7
6ExprTuple8, 9
7ExprTuple32, 10
8Operationoperator: 35
operands: 11
9Operationoperator: 12
operand: 16
10Operationoperator: 14
operands: 18
11ExprTuple32, 15
12Literal
13ExprTuple16
14Literal
15Operationoperator: 17
operands: 18
16Lambdaparameters: 38
body: 19
17Literal
18ExprTuple39, 20
19Conditionalvalue: 21
condition: 22
20Variable
21Operationoperator: 37
operands: 23
22Operationoperator: 24
operands: 25
23ExprTuple26, 27
24Literal
25ExprTuple28, 29, 30
26Operationoperator: 32
operand: 40
27Operationoperator: 32
operand: 41
28Operationoperator: 35
operands: 34
29Operationoperator: 35
operands: 36
30Operationoperator: 37
operands: 38
31ExprTuple40
32Variable
33ExprTuple41
34ExprTuple40, 39
35Literal
36ExprTuple41, 39
37Literal
38ExprTuple40, 41
39Variable
40Variable
41Variable