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 Lambda, P, Q, R
from proveit.logic import Implies
from proveit.logic.booleans.quantification import general_exists_Py_st_Qy, general_exists_Rz_st_Qz, general_forall_st_Qx__Px_implies_Rx
In [2]:
# build up the expression from sub-expressions
expr = Lambda([P, Q, R], 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))
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(P, Q, R\right) \mapsto \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)
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
1ExprTuple31, 34, 33
2Operationoperator: 20
operands: 3
3ExprTuple4, 5
4Operationoperator: 6
operand: 9
5Operationoperator: 20
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 30
body: 12
10Operationoperator: 14
operand: 18
11Operationoperator: 14
operand: 19
12Conditionalvalue: 16
condition: 17
13ExprTuple18
14Literal
15ExprTuple19
16Operationoperator: 20
operands: 21
17Operationoperator: 34
operands: 30
18Lambdaparameters: 32
body: 22
19Lambdaparameters: 35
body: 23
20Literal
21ExprTuple24, 25
22Conditionalvalue: 26
condition: 27
23Conditionalvalue: 28
condition: 29
24Operationoperator: 31
operands: 30
25Operationoperator: 33
operands: 30
26Operationoperator: 31
operands: 32
27Operationoperator: 34
operands: 32
28Operationoperator: 33
operands: 35
29Operationoperator: 34
operands: 35
30ExprTuple36
31Variable
32ExprTuple37
33Variable
34Variable
35ExprTuple38
36ExprRangelambda_map: 39
start_index: 42
end_index: 43
37ExprRangelambda_map: 40
start_index: 42
end_index: 43
38ExprRangelambda_map: 41
start_index: 42
end_index: 43
39Lambdaparameter: 51
body: 44
40Lambdaparameter: 51
body: 45
41Lambdaparameter: 51
body: 46
42Literal
43Variable
44IndexedVarvariable: 47
index: 51
45IndexedVarvariable: 48
index: 51
46IndexedVarvariable: 49
index: 51
47Variable
48Variable
49Variable
50ExprTuple51
51Variable