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