logo

Expression of type Lambda

from the theory of proveit.logic.booleans.conjunction

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 C, Conditional, Lambda, l, m, n
from proveit.core_expr_types import A_1_to_l, B_1_to_m, D_1_to_n
from proveit.logic import And, Boolean, Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda([l, m, n], Conditional(Forall(instance_param_or_params = [A_1_to_l, B_1_to_m, C, D_1_to_n], instance_expr = Equals(And(A_1_to_l, B_1_to_m, C, D_1_to_n), And(A_1_to_l, C, B_1_to_m, D_1_to_n)).with_wrapping_at(2), domain = Boolean), And(InSet(l, Natural), InSet(m, Natural), InSet(n, 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(l, m, n\right) \mapsto \left\{\forall_{A_{1}, A_{2}, \ldots, A_{l}, B_{1}, B_{2}, \ldots, B_{m}, C, D_{1}, D_{2}, \ldots, D_{n} \in \mathbb{B}}~\left(\begin{array}{c} \begin{array}{l} \left(A_{1} \land  A_{2} \land  \ldots \land  A_{l}\land B_{1} \land  B_{2} \land  \ldots \land  B_{m} \land C\land D_{1} \land  D_{2} \land  \ldots \land  D_{n}\right) =  \\ \left(A_{1} \land  A_{2} \land  \ldots \land  A_{l} \land C\land B_{1} \land  B_{2} \land  \ldots \land  B_{m}\land D_{1} \land  D_{2} \land  \ldots \land  D_{n}\right) \end{array} \end{array}\right) \textrm{ if } l \in \mathbb{N} ,  m \in \mathbb{N} ,  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
0Lambdaparameters: 1
body: 2
1ExprTuple43, 45, 48
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 29
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10, 11
8Lambdaparameters: 28
body: 12
9Operationoperator: 51
operands: 13
10Operationoperator: 51
operands: 14
11Operationoperator: 51
operands: 15
12Conditionalvalue: 16
condition: 17
13ExprTuple43, 18
14ExprTuple45, 18
15ExprTuple48, 18
16Operationoperator: 19
operands: 20
17Operationoperator: 29
operands: 21
18Literal
19Literal
20ExprTuple22, 23
21ExprTuple24, 25, 26, 27
22Operationoperator: 29
operands: 28
23Operationoperator: 29
operands: 30
24ExprRangelambda_map: 31
start_index: 47
end_index: 43
25ExprRangelambda_map: 32
start_index: 47
end_index: 45
26Operationoperator: 51
operands: 33
27ExprRangelambda_map: 34
start_index: 47
end_index: 48
28ExprTuple35, 36, 40, 37
29Literal
30ExprTuple35, 40, 36, 37
31Lambdaparameter: 61
body: 38
32Lambdaparameter: 61
body: 39
33ExprTuple40, 56
34Lambdaparameter: 61
body: 41
35ExprRangelambda_map: 42
start_index: 47
end_index: 43
36ExprRangelambda_map: 44
start_index: 47
end_index: 45
37ExprRangelambda_map: 46
start_index: 47
end_index: 48
38Operationoperator: 51
operands: 49
39Operationoperator: 51
operands: 50
40Variable
41Operationoperator: 51
operands: 52
42Lambdaparameter: 61
body: 53
43Variable
44Lambdaparameter: 61
body: 54
45Variable
46Lambdaparameter: 61
body: 55
47Literal
48Variable
49ExprTuple53, 56
50ExprTuple54, 56
51Literal
52ExprTuple55, 56
53IndexedVarvariable: 57
index: 61
54IndexedVarvariable: 58
index: 61
55IndexedVarvariable: 59
index: 61
56Literal
57Variable
58Variable
59Variable
60ExprTuple61
61Variable