logo

Expression of type Lambda

from the theory of proveit.logic.booleans.quantification.universality

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 Function, Lambda, P, n
from proveit.core_expr_types import P__x_1_to_n, P__x_1_to_np1, x_1_to_n, x_1_to_np1
from proveit.logic import And, Forall, Implies
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [n]
sub_expr2 = Forall(instance_param_or_params = [x_1_to_n], instance_expr = P__x_1_to_n)
expr = Lambda(P, Implies(And(Function(P, []), Forall(instance_param_or_params = sub_expr1, instance_expr = Implies(sub_expr2, Forall(instance_param_or_params = [x_1_to_np1], instance_expr = P__x_1_to_np1)).with_wrapping_at(2), domain = Natural)), Forall(instance_param_or_params = sub_expr1, instance_expr = sub_expr2, domain = Natural)).with_wrapping_at(1))
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())
P \mapsto \left(\begin{array}{c} \begin{array}{l} \left(P\left(\right) \land \left[\forall_{n \in \mathbb{N}}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{x_{1}, x_{2}, \ldots, x_{n}}~P\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right] \Rightarrow  \\ \left[\forall_{x_{1}, x_{2}, \ldots, x_{n + 1}}~P\left(x_{1}, x_{2}, \ldots, x_{n + 1}\right)\right] \end{array} \end{array}\right)\right]\right) \\  \Rightarrow \left[\forall_{n \in \mathbb{N}}~\left[\forall_{x_{1}, x_{2}, \ldots, x_{n}}~P\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right]\right] \end{array} \end{array}\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 35
body: 2
1ExprTuple35
2Operationoperator: 20
operands: 3
3ExprTuple4, 5
4Operationoperator: 6
operands: 7
5Operationoperator: 28
operand: 11
6Literal
7ExprTuple9, 10
8ExprTuple11
9Operationoperator: 35
operands: 12
10Operationoperator: 28
operand: 15
11Lambdaparameter: 46
body: 14
12ExprTuple
13ExprTuple15
14Conditionalvalue: 24
condition: 19
15Lambdaparameter: 46
body: 17
16ExprTuple46
17Conditionalvalue: 18
condition: 19
18Operationoperator: 20
operands: 21
19Operationoperator: 22
operands: 23
20Literal
21ExprTuple24, 25
22Literal
23ExprTuple46, 26
24Operationoperator: 28
operand: 30
25Operationoperator: 28
operand: 31
26Literal
27ExprTuple30
28Literal
29ExprTuple31
30Lambdaparameters: 34
body: 32
31Lambdaparameters: 36
body: 33
32Operationoperator: 35
operands: 34
33Operationoperator: 35
operands: 36
34ExprTuple37
35Variable
36ExprTuple38
37ExprRangelambda_map: 39
start_index: 47
end_index: 46
38ExprRangelambda_map: 39
start_index: 47
end_index: 40
39Lambdaparameter: 48
body: 41
40Operationoperator: 42
operands: 43
41IndexedVarvariable: 44
index: 48
42Literal
43ExprTuple46, 47
44Variable
45ExprTuple48
46Variable
47Literal
48Variable