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
from proveit.logic import Implies, Not
from proveit.logic.booleans.quantification import general_exists_notPx_st_Qx, general_forall_Py_if_Qy
In [2]:
# build up the expression from sub-expressions
expr = Lambda([P, Q], Implies(general_exists_notPx_st_Qx, Not(general_forall_Py_if_Qy)).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\right) \mapsto \left(\begin{array}{c} \begin{array}{l} \left[\exists_{x_{1}, x_{2}, \ldots, x_{n}~|~Q\left(x_{1}, x_{2}, \ldots, x_{n}\right)}~(\lnot P\left(x_{1}, x_{2}, \ldots, x_{n}\right))\right] \Rightarrow  \\ (\lnot \left[\forall_{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]) \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
1ExprTuple25, 26
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 7
operand: 10
6Operationoperator: 18
operand: 11
7Literal
8ExprTuple10
9ExprTuple11
10Lambdaparameters: 24
body: 12
11Operationoperator: 13
operand: 17
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple17
15Operationoperator: 18
operand: 21
16Operationoperator: 26
operands: 24
17Lambdaparameters: 27
body: 20
18Literal
19ExprTuple21
20Conditionalvalue: 22
condition: 23
21Operationoperator: 25
operands: 24
22Operationoperator: 25
operands: 27
23Operationoperator: 26
operands: 27
24ExprTuple28
25Variable
26Variable
27ExprTuple29
28ExprRangelambda_map: 30
start_index: 32
end_index: 33
29ExprRangelambda_map: 31
start_index: 32
end_index: 33
30Lambdaparameter: 39
body: 34
31Lambdaparameter: 39
body: 35
32Literal
33Variable
34IndexedVarvariable: 36
index: 39
35IndexedVarvariable: 37
index: 39
36Variable
37Variable
38ExprTuple39
39Variable