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, i, j, k, x
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_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, x, b_1_to_j, c_1_to_k], instance_expr = Equals(Set(a_1_to_i, x, b_1_to_j, x, c_1_to_k), Set(a_1_to_i, b_1_to_j, x, c_1_to_k)).with_wrapping_at(2)), 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}, x, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k}}~\left(\begin{array}{c} \begin{array}{l} \left\{a_{1}, a_{2}, \ldots, a_{i}, x,b_{1}, b_{2}, \ldots, b_{j}, x,c_{1}, c_{2}, \ldots, c_{k}\right\} =  \\ \left\{a_{1}, a_{2}, \ldots, a_{i},b_{1}, b_{2}, \ldots, b_{j}, x,c_{1}, c_{2}, \ldots, c_{k}\right\} \end{array} \end{array}\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
1ExprTuple32, 34, 37
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple10, 11, 12
9Lambdaparameters: 13
body: 14
10Operationoperator: 17
operands: 15
11Operationoperator: 17
operands: 16
12Operationoperator: 17
operands: 18
13ExprTuple27, 29, 28, 30
14Operationoperator: 19
operands: 20
15ExprTuple32, 21
16ExprTuple34, 21
17Literal
18ExprTuple37, 21
19Literal
20ExprTuple22, 23
21Literal
22Operationoperator: 25
operands: 24
23Operationoperator: 25
operands: 26
24ExprTuple27, 29, 28, 29, 30
25Literal
26ExprTuple27, 28, 29, 30
27ExprRangelambda_map: 31
start_index: 36
end_index: 32
28ExprRangelambda_map: 33
start_index: 36
end_index: 34
29Variable
30ExprRangelambda_map: 35
start_index: 36
end_index: 37
31Lambdaparameter: 45
body: 38
32Variable
33Lambdaparameter: 45
body: 39
34Variable
35Lambdaparameter: 45
body: 40
36Literal
37Variable
38IndexedVarvariable: 41
index: 45
39IndexedVarvariable: 42
index: 45
40IndexedVarvariable: 43
index: 45
41Variable
42Variable
43Variable
44ExprTuple45
45Variable