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, R, n
from proveit.logic import Forall, Implies, InSet
from proveit.logic.booleans.quantification import general_exists_Py_st_Qy, general_exists_Rz_st_Qz, general_forall_st_Qx__Px_implies_Rx
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, R], instance_expr = Implies(general_forall_st_Qx__Px_implies_Rx, Implies(general_exists_Py_st_Qy, general_exists_Rz_st_Qz).with_wrapping_at(2)).with_wrapping_at(2)), 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, R}~\left(\begin{array}{c} \begin{array}{l} \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 R\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \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] \Rightarrow  \\ \left[\exists_{z_{1}, z_{2}, \ldots, z_{n}~|~Q\left(z_{1}, z_{2}, \ldots, z_{n}\right)}~R\left(z_{1}, z_{2}, \ldots, z_{n}\right)\right] \end{array} \end{array}\right) \end{array} \end{array}\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: 52
body: 2
1ExprTuple52
2Conditionalvalue: 3
condition: 4
3Operationoperator: 15
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple52, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple40, 43, 42
11Operationoperator: 29
operands: 12
12ExprTuple13, 14
13Operationoperator: 15
operand: 18
14Operationoperator: 29
operands: 17
15Literal
16ExprTuple18
17ExprTuple19, 20
18Lambdaparameters: 39
body: 21
19Operationoperator: 23
operand: 27
20Operationoperator: 23
operand: 28
21Conditionalvalue: 25
condition: 26
22ExprTuple27
23Literal
24ExprTuple28
25Operationoperator: 29
operands: 30
26Operationoperator: 43
operands: 39
27Lambdaparameters: 41
body: 31
28Lambdaparameters: 44
body: 32
29Literal
30ExprTuple33, 34
31Conditionalvalue: 35
condition: 36
32Conditionalvalue: 37
condition: 38
33Operationoperator: 40
operands: 39
34Operationoperator: 42
operands: 39
35Operationoperator: 40
operands: 41
36Operationoperator: 43
operands: 41
37Operationoperator: 42
operands: 44
38Operationoperator: 43
operands: 44
39ExprTuple45
40Variable
41ExprTuple46
42Variable
43Variable
44ExprTuple47
45ExprRangelambda_map: 48
start_index: 51
end_index: 52
46ExprRangelambda_map: 49
start_index: 51
end_index: 52
47ExprRangelambda_map: 50
start_index: 51
end_index: 52
48Lambdaparameter: 60
body: 53
49Lambdaparameter: 60
body: 54
50Lambdaparameter: 60
body: 55
51Literal
52Variable
53IndexedVarvariable: 56
index: 60
54IndexedVarvariable: 57
index: 60
55IndexedVarvariable: 58
index: 60
56Variable
57Variable
58Variable
59ExprTuple60
60Variable