logo

Expression of type Forall

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, 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 = Forall(instance_param_or_params = [A, B], instance_expr = 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())
\forall_{A, B}~\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()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 16
operand: 2
1ExprTuple2
2Lambdaparameters: 22
body: 3
3Operationoperator: 16
operand: 5
4ExprTuple5
5Lambdaparameter: 36
body: 7
6ExprTuple36
7Conditionalvalue: 8
condition: 9
8Operationoperator: 28
operands: 10
9Operationoperator: 39
operands: 11
10ExprTuple12, 13
11ExprTuple36, 14
12Operationoperator: 39
operands: 15
13Operationoperator: 16
operand: 20
14Operationoperator: 18
operands: 22
15ExprTuple36, 19
16Literal
17ExprTuple20
18Literal
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