logo

Expression of type Lambda

from the theory of proveit.logic.booleans

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 A, Conditional, Lambda, P, PofA, Q, QofA
from proveit.logic import And, Boolean, Forall, QimplPofFalse, QimplPofTrue
In [2]:
# build up the expression from sub-expressions
expr = Lambda([P, Q], Conditional(Forall(instance_param_or_params = [A], instance_expr = PofA, domain = Boolean, condition = QofA), And(QimplPofTrue, QimplPofFalse)))
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\{\forall_{A \in \mathbb{B}~|~Q\left(A\right)}~P\left(A\right) \textrm{ if } Q\left(\top\right) \Rightarrow P\left(\top\right) ,  Q\left(\bot\right) \Rightarrow P\left(\bot\right)\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
1ExprTuple24, 32
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 21
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameter: 35
body: 11
9Operationoperator: 13
operands: 12
10Operationoperator: 13
operands: 14
11Conditionalvalue: 15
condition: 16
12ExprTuple17, 18
13Literal
14ExprTuple19, 20
15Operationoperator: 24
operand: 35
16Operationoperator: 21
operands: 22
17Operationoperator: 32
operand: 28
18Operationoperator: 24
operand: 28
19Operationoperator: 32
operand: 29
20Operationoperator: 24
operand: 29
21Literal
22ExprTuple26, 27
23ExprTuple28
24Variable
25ExprTuple29
26Operationoperator: 30
operands: 31
27Operationoperator: 32
operand: 35
28Literal
29Literal
30Literal
31ExprTuple35, 34
32Variable
33ExprTuple35
34Literal
35Variable