logo

Expression of type Lambda

from the theory of proveit.logic.sets.comprehension

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 Conditional, Lambda, Q, f, n, x
from proveit.core_expr_types import Q__y_1_to_n, S_1_to_n, f__y_1_to_n, y_1_to_n
from proveit.logic import Equals, Exists, Forall, InSet
from proveit.logic.sets import general_comprehension_fyn
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [S_1_to_n, Q, f, x], instance_expr = Equals(InSet(x, general_comprehension_fyn), Exists(instance_param_or_params = [y_1_to_n], instance_expr = Equals(x, f__y_1_to_n), domains = [S_1_to_n], condition = Q__y_1_to_n)).with_wrapping_at(1)), InSet(n, NaturalPos)))
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())
n \mapsto \left\{\forall_{S_{1}, S_{2}, \ldots, S_{n}, Q, f, x}~\left(\begin{array}{c} \begin{array}{l} \left(x \in \left\{f\left(y_{1}, y_{2}, \ldots, y_{n}\right)~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)\right\}_{\left(y_{1} \in S_{1}\right), \left(y_{2} \in S_{2}\right), \ldots, \left(y_{n} \in S_{n}\right)}\right) \\  = \left[\exists_{\left(y_{1} \in S_{1}\right), \left(y_{2} \in S_{2}\right), \ldots, \left(y_{n} \in S_{n}\right)~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~\left(x = f\left(y_{1}, y_{2}, \ldots, y_{n}\right)\right)\right] \end{array} \end{array}\right) \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 47
body: 2
1ExprTuple47
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 43
operands: 7
5Literal
6ExprTuple8
7ExprTuple47, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple12, 39, 35, 31
11Operationoperator: 28
operands: 13
12ExprRangelambda_map: 14
start_index: 46
end_index: 47
13ExprTuple15, 16
14Lambdaparameter: 53
body: 48
15Operationoperator: 43
operands: 17
16Operationoperator: 18
operand: 21
17ExprTuple31, 20
18Literal
19ExprTuple21
20Operationoperator: 22
operand: 25
21Lambdaparameters: 40
body: 24
22Literal
23ExprTuple25
24Conditionalvalue: 26
condition: 30
25Lambdaparameters: 40
body: 27
26Operationoperator: 28
operands: 29
27Conditionalvalue: 32
condition: 30
28Literal
29ExprTuple31, 32
30Operationoperator: 33
operands: 34
31Variable
32Operationoperator: 35
operands: 40
33Literal
34ExprTuple36, 37
35Variable
36ExprRangelambda_map: 38
start_index: 46
end_index: 47
37Operationoperator: 39
operands: 40
38Lambdaparameter: 53
body: 41
39Variable
40ExprTuple42
41Operationoperator: 43
operands: 44
42ExprRangelambda_map: 45
start_index: 46
end_index: 47
43Literal
44ExprTuple49, 48
45Lambdaparameter: 53
body: 49
46Literal
47Variable
48IndexedVarvariable: 50
index: 53
49IndexedVarvariable: 51
index: 53
50Variable
51Variable
52ExprTuple53
53Variable