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 A, B, Conditional, Lambda, P, Q, n
from proveit.logic import Forall, Implies, InSet, SubsetEq
from proveit.logic.booleans.quantification import general_exists_in_A_Px_st_Qx, general_exists_in_B_Py_st_Qy
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, A, B], instance_expr = Implies(general_exists_in_A_Px_st_Qx, general_exists_in_B_Py_st_Qy).with_wrapping_at(2), condition = SubsetEq(A, B)), 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, A, B~|~A \subseteq B}~\left(\begin{array}{c} \begin{array}{l} \left[\exists_{x_{1}, x_{2}, \ldots, x_{n} \in A~|~Q\left(x_{1}, x_{2}, \ldots, x_{n}\right)}~P\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right] \Rightarrow  \\ \left[\exists_{y_{1}, y_{2}, \ldots, y_{n} \in B~|~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) \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: 54
body: 2
1ExprTuple54
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 50
operands: 7
5Literal
6ExprTuple8
7ExprTuple54, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple32, 42, 55, 57
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple55, 57
18Operationoperator: 21
operand: 23
19Operationoperator: 21
operand: 24
20ExprTuple23
21Literal
22ExprTuple24
23Lambdaparameters: 40
body: 25
24Lambdaparameters: 43
body: 26
25Conditionalvalue: 27
condition: 28
26Conditionalvalue: 29
condition: 30
27Operationoperator: 32
operands: 40
28Operationoperator: 33
operands: 31
29Operationoperator: 32
operands: 43
30Operationoperator: 33
operands: 34
31ExprTuple35, 36
32Variable
33Literal
34ExprTuple37, 38
35ExprRangelambda_map: 39
start_index: 53
end_index: 54
36Operationoperator: 42
operands: 40
37ExprRangelambda_map: 41
start_index: 53
end_index: 54
38Operationoperator: 42
operands: 43
39Lambdaparameter: 62
body: 44
40ExprTuple45
41Lambdaparameter: 62
body: 46
42Variable
43ExprTuple47
44Operationoperator: 50
operands: 48
45ExprRangelambda_map: 49
start_index: 53
end_index: 54
46Operationoperator: 50
operands: 51
47ExprRangelambda_map: 52
start_index: 53
end_index: 54
48ExprTuple56, 55
49Lambdaparameter: 62
body: 56
50Literal
51ExprTuple58, 57
52Lambdaparameter: 62
body: 58
53Literal
54Variable
55Variable
56IndexedVarvariable: 59
index: 62
57Variable
58IndexedVarvariable: 60
index: 62
59Variable
60Variable
61ExprTuple62
62Variable