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, R, f, n
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, InSet, SetOfAll, SubsetEq
from proveit.logic.sets import general_comprehension_fyn
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x_1_to_n]
sub_expr2 = [S_1_to_n]
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [f, Q, R, S_1_to_n], instance_expr = 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)), 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_{f, Q, R, S_{1}, S_{2}, \ldots, S_{n}}~\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) \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: 61
body: 2
1ExprTuple61
2Conditionalvalue: 3
condition: 4
3Operationoperator: 17
operand: 7
4Operationoperator: 57
operands: 6
5ExprTuple7
6ExprTuple61, 8
7Lambdaparameters: 9
body: 10
8Literal
9ExprTuple38, 49, 46, 11
10Operationoperator: 12
operands: 13
11ExprRangelambda_map: 14
start_index: 60
end_index: 61
12Literal
13ExprTuple15, 16
14Lambdaparameter: 69
body: 63
15Operationoperator: 17
operand: 21
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21
19Literal
20ExprTuple22, 23
21Lambdaparameters: 47
body: 24
22Operationoperator: 26
operand: 29
23Operationoperator: 26
operand: 30
24Conditionalvalue: 28
condition: 34
25ExprTuple29
26Literal
27ExprTuple30
28Operationoperator: 49
operands: 47
29Lambdaparameters: 47
body: 31
30Lambdaparameters: 50
body: 32
31Conditionalvalue: 33
condition: 34
32Conditionalvalue: 35
condition: 36
33Operationoperator: 38
operands: 47
34Operationoperator: 39
operands: 37
35Operationoperator: 38
operands: 50
36Operationoperator: 39
operands: 40
37ExprTuple41, 42
38Variable
39Literal
40ExprTuple43, 44
41ExprRangelambda_map: 45
start_index: 60
end_index: 61
42Operationoperator: 46
operands: 47
43ExprRangelambda_map: 48
start_index: 60
end_index: 61
44Operationoperator: 49
operands: 50
45Lambdaparameter: 69
body: 51
46Variable
47ExprTuple52
48Lambdaparameter: 69
body: 53
49Variable
50ExprTuple54
51Operationoperator: 57
operands: 55
52ExprRangelambda_map: 56
start_index: 60
end_index: 61
53Operationoperator: 57
operands: 58
54ExprRangelambda_map: 59
start_index: 60
end_index: 61
55ExprTuple62, 63
56Lambdaparameter: 69
body: 62
57Literal
58ExprTuple64, 63
59Lambdaparameter: 69
body: 64
60Literal
61Variable
62IndexedVarvariable: 65
index: 69
63IndexedVarvariable: 66
index: 69
64IndexedVarvariable: 67
index: 69
65Variable
66Variable
67Variable
68ExprTuple69
69Variable