logo

Expression of type Lambda

from the theory of proveit.logic.sets.intersection

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, n, x
from proveit.core_expr_types import Q__y_1_to_n, R__y_1_to_n, S_1_to_n, y_1_to_n
from proveit.logic import Equals, Exists, Forall, InSet
from proveit.logic.sets import general_intersectall_Ryn
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [y_1_to_n]
sub_expr2 = [S_1_to_n]
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [S_1_to_n, Q, R, x], instance_expr = Equals(InSet(x, general_intersectall_Ryn), Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(x, R__y_1_to_n), domains = sub_expr2, condition = Q__y_1_to_n)).with_wrapping_at(1), condition = Exists(instance_param_or_params = sub_expr1, instance_expr = Q__y_1_to_n, domains = sub_expr2)), 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, R, x~|~\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(\begin{array}{c} \begin{array}{l} \left(x \in \left[\bigcap_{\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)}~R\left(y_{1}, y_{2}, \ldots, y_{n}\right)\right]\right) \\  = \left[\forall_{\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 \in R\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: 54
body: 2
1ExprTuple54
2Conditionalvalue: 3
condition: 4
3Operationoperator: 23
operand: 7
4Operationoperator: 50
operands: 6
5ExprTuple7
6ExprTuple54, 8
7Lambdaparameters: 9
body: 10
8Literal
9ExprTuple11, 46, 42, 38
10Conditionalvalue: 12
condition: 13
11ExprRangelambda_map: 14
start_index: 53
end_index: 54
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operand: 21
14Lambdaparameter: 60
body: 55
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple21
19Operationoperator: 50
operands: 22
20Operationoperator: 23
operand: 27
21Lambdaparameters: 47
body: 25
22ExprTuple38, 26
23Literal
24ExprTuple27
25Conditionalvalue: 44
condition: 28
26Operationoperator: 29
operand: 33
27Lambdaparameters: 47
body: 31
28Operationoperator: 40
operands: 32
29Literal
30ExprTuple33
31Conditionalvalue: 34
condition: 37
32ExprTuple43
33Lambdaparameters: 47
body: 35
34Operationoperator: 50
operands: 36
35Conditionalvalue: 39
condition: 37
36ExprTuple38, 39
37Operationoperator: 40
operands: 41
38Variable
39Operationoperator: 42
operands: 47
40Literal
41ExprTuple43, 44
42Variable
43ExprRangelambda_map: 45
start_index: 53
end_index: 54
44Operationoperator: 46
operands: 47
45Lambdaparameter: 60
body: 48
46Variable
47ExprTuple49
48Operationoperator: 50
operands: 51
49ExprRangelambda_map: 52
start_index: 53
end_index: 54
50Literal
51ExprTuple56, 55
52Lambdaparameter: 60
body: 56
53Literal
54Variable
55IndexedVarvariable: 57
index: 60
56IndexedVarvariable: 58
index: 60
57Variable
58Variable
59ExprTuple60
60Variable