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, ExprRange, Function, IndexedVar, Lambda, P, Px, Variable, a, n, x
from proveit.core_expr_types import a_1_to_n
from proveit.logic import Equals, FALSE, Forall, InSet, Or, Set
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [P], instance_expr = Equals(Or(ExprRange(sub_expr1, Equals(Function(P, [IndexedVar(a, sub_expr1)]), FALSE), one, n)), Equals(Forall(instance_param_or_params = [x], instance_expr = Px, domain = Set(a_1_to_n)), FALSE)))), 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())
n \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{n}}~\left[\forall_{P}~\left(\left(\left(P\left(a_{1}\right) = \bot\right) \lor  \left(P\left(a_{2}\right) = \bot\right) \lor  \ldots \lor  \left(P\left(a_{n}\right) = \bot\right)\right) = \left(\left[\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}}~P\left(x\right)\right] = \bot\right)\right)\right] \textrm{ if } 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
0Lambdaparameter: 46
body: 2
1ExprTuple46
2Conditionalvalue: 3
condition: 4
3Operationoperator: 23
operand: 7
4Operationoperator: 37
operands: 6
5ExprTuple7
6ExprTuple46, 8
7Lambdaparameters: 42
body: 9
8Literal
9Operationoperator: 23
operand: 11
10ExprTuple11
11Lambdaparameter: 35
body: 13
12ExprTuple35
13Operationoperator: 27
operands: 14
14ExprTuple15, 16
15Operationoperator: 17
operands: 18
16Operationoperator: 27
operands: 19
17Literal
18ExprTuple20
19ExprTuple21, 31
20ExprRangelambda_map: 22
start_index: 45
end_index: 46
21Operationoperator: 23
operand: 26
22Lambdaparameter: 50
body: 25
23Literal
24ExprTuple26
25Operationoperator: 27
operands: 28
26Lambdaparameter: 39
body: 29
27Literal
28ExprTuple30, 31
29Conditionalvalue: 32
condition: 33
30Operationoperator: 35
operand: 47
31Literal
32Operationoperator: 35
operand: 39
33Operationoperator: 37
operands: 38
34ExprTuple47
35Variable
36ExprTuple39
37Literal
38ExprTuple39, 40
39Variable
40Operationoperator: 41
operands: 42
41Literal
42ExprTuple43
43ExprRangelambda_map: 44
start_index: 45
end_index: 46
44Lambdaparameter: 50
body: 47
45Literal
46Variable
47IndexedVarvariable: 48
index: 50
48Variable
49ExprTuple50
50Variable