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, alpha, n
from proveit.core_expr_types import P__x_1_to_n, Q__x_1_to_n, x_1_to_n
from proveit.logic import And, Boolean, Forall, Implies, InSet
from proveit.logic.booleans.quantification import general_exists_Py_st_Qy
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Lambda([n, alpha], Conditional(Forall(instance_param_or_params = [P, Q], instance_expr = Implies(And(general_exists_Py_st_Qy, Forall(instance_param_or_params = [x_1_to_n], instance_expr = Implies(P__x_1_to_n, alpha), condition = Q__x_1_to_n)), alpha)), And(InSet(n, NaturalPos), InSet(alpha, Boolean))))
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())
\left(n, \alpha\right) \mapsto \left\{\forall_{P, Q}~\left(\left(\left[\exists_{y_{1}, y_{2}, \ldots, y_{n}~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~P\left(y_{1}, y_{2}, \ldots, y_{n}\right)\right] \land \left[\forall_{x_{1}, x_{2}, \ldots, x_{n}~|~Q\left(x_{1}, x_{2}, \ldots, x_{n}\right)}~\left(P\left(x_{1}, x_{2}, \ldots, x_{n}\right) \Rightarrow \alpha\right)\right]\right) \Rightarrow \alpha\right) \textrm{ if } n \in \mathbb{N}^+ ,  \alpha \in \mathbb{B}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple50, 41
2Conditionalvalue: 3
condition: 4
3Operationoperator: 25
operand: 7
4Operationoperator: 19
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 10
body: 11
8Operationoperator: 13
operands: 12
9Operationoperator: 13
operands: 14
10ExprTuple43, 38
11Operationoperator: 36
operands: 15
12ExprTuple50, 16
13Literal
14ExprTuple41, 17
15ExprTuple18, 41
16Literal
17Literal
18Operationoperator: 19
operands: 20
19Literal
20ExprTuple21, 22
21Operationoperator: 23
operand: 27
22Operationoperator: 25
operand: 28
23Literal
24ExprTuple27
25Literal
26ExprTuple28
27Lambdaparameters: 35
body: 29
28Lambdaparameters: 44
body: 30
29Conditionalvalue: 31
condition: 32
30Conditionalvalue: 33
condition: 34
31Operationoperator: 43
operands: 35
32Operationoperator: 38
operands: 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 44
35ExprTuple39
36Literal
37ExprTuple40, 41
38Variable
39ExprRangelambda_map: 42
start_index: 49
end_index: 50
40Operationoperator: 43
operands: 44
41Variable
42Lambdaparameter: 54
body: 45
43Variable
44ExprTuple46
45IndexedVarvariable: 47
index: 54
46ExprRangelambda_map: 48
start_index: 49
end_index: 50
47Variable
48Lambdaparameter: 54
body: 51
49Literal
50Variable
51IndexedVarvariable: 52
index: 54
52Variable
53ExprTuple54
54Variable