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 Lambda, Q, R, f
from proveit.core_expr_types import Q__x_1_to_n, R__x_1_to_n, S_1_to_n, f__x_1_to_n, x_1_to_n
from proveit.logic import Forall, Implies, SetOfAll, SubsetEq
from proveit.logic.sets import general_comprehension_fyn
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x_1_to_n]
sub_expr2 = [S_1_to_n]
expr = Lambda([f, Q, R, S_1_to_n], Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Q__x_1_to_n, domains = sub_expr2, condition = R__x_1_to_n), SubsetEq(SetOfAll(instance_param_or_params = sub_expr1, instance_element = f__x_1_to_n, domains = sub_expr2, condition = R__x_1_to_n), general_comprehension_fyn).with_wrapping_at(2)).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(f, Q, R, S_{1}, S_{2}, \ldots, S_{n}\right) \mapsto \left(\begin{array}{c} \begin{array}{l} \left[\forall_{\left(x_{1} \in S_{1}\right), \left(x_{2} \in S_{2}\right), \ldots, \left(x_{n} \in S_{n}\right)~|~R\left(x_{1}, x_{2}, \ldots, x_{n}\right)}~Q\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left\{f\left(x_{1}, x_{2}, \ldots, x_{n}\right)~|~R\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right\}_{\left(x_{1} \in S_{1}\right), \left(x_{2} \in S_{2}\right), \ldots, \left(x_{n} \in S_{n}\right)} \subseteq  \\ \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)} \end{array} \end{array}\right) \end{array} \end{array}\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple30, 41, 38, 3
2Operationoperator: 4
operands: 5
3ExprRangelambda_map: 6
start_index: 52
end_index: 53
4Literal
5ExprTuple7, 8
6Lambdaparameter: 61
body: 55
7Operationoperator: 9
operand: 13
8Operationoperator: 11
operands: 12
9Literal
10ExprTuple13
11Literal
12ExprTuple14, 15
13Lambdaparameters: 39
body: 16
14Operationoperator: 18
operand: 21
15Operationoperator: 18
operand: 22
16Conditionalvalue: 20
condition: 26
17ExprTuple21
18Literal
19ExprTuple22
20Operationoperator: 41
operands: 39
21Lambdaparameters: 39
body: 23
22Lambdaparameters: 42
body: 24
23Conditionalvalue: 25
condition: 26
24Conditionalvalue: 27
condition: 28
25Operationoperator: 30
operands: 39
26Operationoperator: 31
operands: 29
27Operationoperator: 30
operands: 42
28Operationoperator: 31
operands: 32
29ExprTuple33, 34
30Variable
31Literal
32ExprTuple35, 36
33ExprRangelambda_map: 37
start_index: 52
end_index: 53
34Operationoperator: 38
operands: 39
35ExprRangelambda_map: 40
start_index: 52
end_index: 53
36Operationoperator: 41
operands: 42
37Lambdaparameter: 61
body: 43
38Variable
39ExprTuple44
40Lambdaparameter: 61
body: 45
41Variable
42ExprTuple46
43Operationoperator: 49
operands: 47
44ExprRangelambda_map: 48
start_index: 52
end_index: 53
45Operationoperator: 49
operands: 50
46ExprRangelambda_map: 51
start_index: 52
end_index: 53
47ExprTuple54, 55
48Lambdaparameter: 61
body: 54
49Literal
50ExprTuple56, 55
51Lambdaparameter: 61
body: 56
52Literal
53Variable
54IndexedVarvariable: 57
index: 61
55IndexedVarvariable: 58
index: 61
56IndexedVarvariable: 59
index: 61
57Variable
58Variable
59Variable
60ExprTuple61
61Variable