logo

Expression of type Lambda

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

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, Q, n
from proveit.core_expr_types import P__y_1_to_n, Q__y_1_to_n, y_1_to_n
from proveit.logic import Forall, InSet
from proveit.logic.booleans.quantification import general_exists_Px_st_Qx
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Lambda(n, Conditional(Forall(instance_param_or_params = [P, Q], instance_expr = Forall(instance_param_or_params = [y_1_to_n], instance_expr = general_exists_Px_st_Qx, conditions = [P__y_1_to_n, Q__y_1_to_n])), InSet(n, NaturalPos)))
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_{P, Q}~\left[\forall_{y_{1}, y_{2}, \ldots, y_{n}~|~P\left(y_{1}, y_{2}, \ldots, y_{n}\right), Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~\left[\exists_{x_{1}, x_{2}, \ldots, x_{n}~|~Q\left(x_{1}, x_{2}, \ldots, x_{n}\right)}~P\left(x_{1}, x_{2}, \ldots, x_{n}\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: 38
body: 2
1ExprTuple38
2Conditionalvalue: 3
condition: 4
3Operationoperator: 12
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple38, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple30, 31
11Operationoperator: 12
operand: 14
12Literal
13ExprTuple14
14Lambdaparameters: 26
body: 15
15Conditionalvalue: 16
condition: 17
16Operationoperator: 18
operand: 22
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22
20Literal
21ExprTuple23, 24
22Lambdaparameters: 32
body: 25
23Operationoperator: 30
operands: 26
24Operationoperator: 31
operands: 26
25Conditionalvalue: 27
condition: 28
26ExprTuple29
27Operationoperator: 30
operands: 32
28Operationoperator: 31
operands: 32
29ExprRangelambda_map: 33
start_index: 37
end_index: 38
30Variable
31Variable
32ExprTuple34
33Lambdaparameter: 43
body: 35
34ExprRangelambda_map: 36
start_index: 37
end_index: 38
35IndexedVarvariable: 39
index: 43
36Lambdaparameter: 43
body: 40
37Literal
38Variable
39Variable
40IndexedVarvariable: 41
index: 43
41Variable
42ExprTuple43
43Variable