logo

Expression of type Lambda

from the theory of proveit.logic.booleans.disjunction

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 A, Conditional, ExprRange, IndexedVar, Lambda, Variable, m
from proveit.core_expr_types import A_1_to_m
from proveit.logic import And, Boolean, Forall, InSet, Or
from proveit.numbers import Add, NaturalPos, one, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = IndexedVar(A, sub_expr1)
sub_expr3 = Add(m, one)
expr = Lambda(m, Conditional(Forall(instance_param_or_params = [ExprRange(sub_expr1, sub_expr2, one, Add(m, two))], instance_expr = InSet(Or(ExprRange(sub_expr1, sub_expr2, one, sub_expr3)), Boolean), condition = ExprRange(sub_expr1, InSet(sub_expr2, Boolean), one, sub_expr3)), And(InSet(m, NaturalPos), Forall(instance_param_or_params = [A_1_to_m], instance_expr = InSet(Or(A_1_to_m), Boolean), domain = Boolean))))
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())
m \mapsto \left\{\forall_{A_{1}, A_{2}, \ldots, A_{m + 2}~|~\left(A_{1} \in \mathbb{B}\right), \left(A_{2} \in \mathbb{B}\right), \ldots, \left(A_{m + 1} \in \mathbb{B}\right)}~\left(\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m + 1}\right) \in \mathbb{B}\right) \textrm{ if } m \in \mathbb{N}^+ ,  \forall_{A_{1}, A_{2}, \ldots, A_{m} \in \mathbb{B}}~\left(\left(A_{1} \lor  A_{2} \lor  \ldots \lor  A_{m}\right) \in \mathbb{B}\right)\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: 13
operand: 7
4Operationoperator: 32
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 10
body: 11
8Operationoperator: 48
operands: 12
9Operationoperator: 13
operand: 19
10ExprTuple15
11Conditionalvalue: 16
condition: 17
12ExprTuple47, 18
13Literal
14ExprTuple19
15ExprRangelambda_map: 45
start_index: 46
end_index: 20
16Operationoperator: 48
operands: 21
17Operationoperator: 32
operands: 22
18Literal
19Lambdaparameters: 39
body: 23
20Operationoperator: 41
operands: 24
21ExprTuple25, 51
22ExprTuple26
23Conditionalvalue: 27
condition: 28
24ExprTuple47, 29
25Operationoperator: 38
operands: 30
26ExprRangelambda_map: 40
start_index: 46
end_index: 37
27Operationoperator: 48
operands: 31
28Operationoperator: 32
operands: 33
29Literal
30ExprTuple34
31ExprTuple35, 51
32Literal
33ExprTuple36
34ExprRangelambda_map: 45
start_index: 46
end_index: 37
35Operationoperator: 38
operands: 39
36ExprRangelambda_map: 40
start_index: 46
end_index: 47
37Operationoperator: 41
operands: 42
38Literal
39ExprTuple43
40Lambdaparameter: 54
body: 44
41Literal
42ExprTuple47, 46
43ExprRangelambda_map: 45
start_index: 46
end_index: 47
44Operationoperator: 48
operands: 49
45Lambdaparameter: 54
body: 50
46Literal
47Variable
48Literal
49ExprTuple50, 51
50IndexedVarvariable: 52
index: 54
51Literal
52Variable
53ExprTuple54
54Variable