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 Conditional, Lambda, 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 Forall, Implies, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda(n, Conditional(Implies(Forall(instance_param_or_params = [x_1_to_n], instance_expr = P__x_1_to_n), Forall(instance_param_or_params = [x_1_to_np1], instance_expr = P__x_1_to_np1)).with_wrapping_at(2), 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\{\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} \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: 31
body: 2
1ExprTuple31
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 10
7Literal
8ExprTuple31, 11
9Operationoperator: 13
operand: 15
10Operationoperator: 13
operand: 16
11Literal
12ExprTuple15
13Literal
14ExprTuple16
15Lambdaparameters: 19
body: 17
16Lambdaparameters: 21
body: 18
17Operationoperator: 20
operands: 19
18Operationoperator: 20
operands: 21
19ExprTuple22
20Variable
21ExprTuple23
22ExprRangelambda_map: 24
start_index: 32
end_index: 31
23ExprRangelambda_map: 24
start_index: 32
end_index: 25
24Lambdaparameter: 33
body: 26
25Operationoperator: 27
operands: 28
26IndexedVarvariable: 29
index: 33
27Literal
28ExprTuple31, 32
29Variable
30ExprTuple33
31Variable
32Literal
33Variable