logo

Expression of type Lambda

from the theory of proveit.logic.sets.enumeration

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, c, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, d_1_to_k
from proveit.logic import And, Equals, Forall, InSet, Set
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, j, k], Conditional(Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c, d_1_to_k], instance_expr = Equals(Set(a_1_to_i, b_1_to_j, c, d_1_to_k), Set(a_1_to_i, c, b_1_to_j, d_1_to_k))), And(InSet(i, Natural), InSet(j, Natural), InSet(k, Natural))))
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(i, j, k\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}, c, d_{1}, d_{2}, \ldots, d_{k}}~\left(\left\{a_{1}, a_{2}, \ldots, a_{i},b_{1}, b_{2}, \ldots, b_{j}, c,d_{1}, d_{2}, \ldots, d_{k}\right\} = \left\{a_{1}, a_{2}, \ldots, a_{i}, c,b_{1}, b_{2}, \ldots, b_{j},d_{1}, d_{2}, \ldots, d_{k}\right\}\right) \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  k \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
0Lambdaparameters: 1
body: 2
1ExprTuple31, 33, 36
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameters: 23
body: 13
10Operationoperator: 16
operands: 14
11Operationoperator: 16
operands: 15
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operands: 19
14ExprTuple31, 20
15ExprTuple33, 20
16Literal
17ExprTuple36, 20
18Literal
19ExprTuple21, 22
20Literal
21Operationoperator: 24
operands: 23
22Operationoperator: 24
operands: 25
23ExprTuple26, 28, 27, 29
24Literal
25ExprTuple26, 27, 28, 29
26ExprRangelambda_map: 30
start_index: 35
end_index: 31
27Variable
28ExprRangelambda_map: 32
start_index: 35
end_index: 33
29ExprRangelambda_map: 34
start_index: 35
end_index: 36
30Lambdaparameter: 44
body: 37
31Variable
32Lambdaparameter: 44
body: 38
33Variable
34Lambdaparameter: 44
body: 39
35Literal
36Variable
37IndexedVarvariable: 40
index: 44
38IndexedVarvariable: 41
index: 44
39IndexedVarvariable: 42
index: 44
40Variable
41Variable
42Variable
43ExprTuple44
44Variable