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, P, Px, Q, Qx, n, x
from proveit.core_expr_types import Qk_implies_Pk_a1_to_an, a_1_to_n
from proveit.logic import Forall, InSet, Set
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [P, Q], instance_expr = Forall(instance_param_or_params = [x], instance_expr = Px, domain = Set(a_1_to_n), condition = Qx), condition = Qk_implies_Pk_a1_to_an)), 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, Q~|~\left(Q\left(a_{1}\right) \Rightarrow P\left(a_{1}\right)\right), \left(Q\left(a_{2}\right) \Rightarrow P\left(a_{2}\right)\right), \ldots, \left(Q\left(a_{n}\right) \Rightarrow P\left(a_{n}\right)\right)}~\left[\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}~|~Q\left(x\right)}~P\left(x\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: 47
body: 2
1ExprTuple47
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operand: 7
4Operationoperator: 34
operands: 6
5ExprTuple7
6ExprTuple47, 8
7Lambdaparameters: 43
body: 9
8Literal
9Operationoperator: 16
operand: 11
10ExprTuple11
11Lambdaparameters: 12
body: 13
12ExprTuple38, 37
13Conditionalvalue: 14
condition: 15
14Operationoperator: 16
operand: 19
15Operationoperator: 26
operands: 18
16Literal
17ExprTuple19
18ExprTuple20
19Lambdaparameter: 41
body: 21
20ExprRangelambda_map: 22
start_index: 46
end_index: 47
21Conditionalvalue: 23
condition: 24
22Lambdaparameter: 51
body: 25
23Operationoperator: 38
operand: 41
24Operationoperator: 26
operands: 27
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple30, 31
28Literal
29ExprTuple32, 33
30Operationoperator: 34
operands: 35
31Operationoperator: 37
operand: 41
32Operationoperator: 37
operand: 48
33Operationoperator: 38
operand: 48
34Literal
35ExprTuple41, 40
36ExprTuple41
37Variable
38Variable
39ExprTuple48
40Operationoperator: 42
operands: 43
41Variable
42Literal
43ExprTuple44
44ExprRangelambda_map: 45
start_index: 46
end_index: 47
45Lambdaparameter: 51
body: 48
46Literal
47Variable
48IndexedVarvariable: 49
index: 51
49Variable
50ExprTuple51
51Variable