logo

Expression of type Lambda

from the theory of proveit.logic.sets.unification

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_unionall_Ryn
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, R, x], instance_expr = Equals(InSet(x, general_unionall_Ryn), Exists(instance_param_or_params = [y_1_to_n], instance_expr = InSet(x, R__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, R, x}~\left(\begin{array}{c} \begin{array}{l} \left(x \in \left[\bigcup_{\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[\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 \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: 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: 13
operands: 14
12ExprRangelambda_map: 15
start_index: 46
end_index: 47
13Literal
14ExprTuple16, 17
15Lambdaparameter: 53
body: 48
16Operationoperator: 43
operands: 18
17Operationoperator: 19
operand: 22
18ExprTuple31, 21
19Literal
20ExprTuple22
21Operationoperator: 23
operand: 26
22Lambdaparameters: 40
body: 25
23Literal
24ExprTuple26
25Conditionalvalue: 27
condition: 30
26Lambdaparameters: 40
body: 28
27Operationoperator: 43
operands: 29
28Conditionalvalue: 32
condition: 30
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