logo

Expression of type Lambda

from the theory of proveit.logic.booleans.quantification.universality

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, m, n
from proveit.logic import And, Forall, Implies, InSet
from proveit.logic.booleans.quantification import general_bundled_forall_Pxy_if_Qx, general_nested_forall_Pxy_if_Qx
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Lambda([m, n], Conditional(Forall(instance_param_or_params = [P, Q, R], instance_expr = Implies(general_nested_forall_Pxy_if_Qx, general_bundled_forall_Pxy_if_Qx).with_wrapping_at(1)), And(InSet(m, NaturalPos), 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())
\left(m, n\right) \mapsto \left\{\forall_{P, Q, R}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{x_{1}, x_{2}, \ldots, x_{m}~|~Q\left(x_{1}, x_{2}, \ldots, x_{m}\right)}~\left[\forall_{y_{1}, y_{2}, \ldots, y_{n}~|~R\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)}~P\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)\right]\right] \\  \Rightarrow \left[\forall_{x_{1}, x_{2}, \ldots, x_{m}, y_{1}, y_{2}, \ldots, y_{n}~|~Q\left(x_{1}, x_{2}, \ldots, x_{m}\right), R\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)}~P\left(x_{1}, x_{2}, \ldots, x_{m},y_{1}, y_{2}, \ldots, y_{n}\right)\right] \end{array} \end{array}\right) \textrm{ if } m \in \mathbb{N}^+ ,  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
0Lambdaparameters: 1
body: 2
1ExprTuple46, 49
2Conditionalvalue: 3
condition: 4
3Operationoperator: 28
operand: 7
4Operationoperator: 30
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameters: 10
body: 11
8Operationoperator: 13
operands: 12
9Operationoperator: 13
operands: 14
10ExprTuple40, 36, 41
11Operationoperator: 15
operands: 16
12ExprTuple46, 17
13Literal
14ExprTuple49, 17
15Literal
16ExprTuple18, 19
17Literal
18Operationoperator: 28
operand: 22
19Operationoperator: 28
operand: 23
20ExprTuple22
21ExprTuple23
22Lambdaparameters: 37
body: 24
23Lambdaparameters: 42
body: 25
24Conditionalvalue: 26
condition: 33
25Conditionalvalue: 38
condition: 27
26Operationoperator: 28
operand: 32
27Operationoperator: 30
operands: 31
28Literal
29ExprTuple32
30Literal
31ExprTuple33, 39
32Lambdaparameters: 34
body: 35
33Operationoperator: 36
operands: 37
34ExprTuple44
35Conditionalvalue: 38
condition: 39
36Variable
37ExprTuple43
38Operationoperator: 40
operands: 42
39Operationoperator: 41
operands: 42
40Variable
41Variable
42ExprTuple43, 44
43ExprRangelambda_map: 45
start_index: 48
end_index: 46
44ExprRangelambda_map: 47
start_index: 48
end_index: 49
45Lambdaparameter: 55
body: 50
46Variable
47Lambdaparameter: 55
body: 51
48Literal
49Variable
50IndexedVarvariable: 52
index: 55
51IndexedVarvariable: 53
index: 55
52Variable
53Variable
54ExprTuple55
55Variable