logo

Expression of type Lambda

from the theory of proveit.core_expr_types.conditionals

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, a, m, n
from proveit.core_expr_types import Q_1_to_m, R_1_to_n
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda([m, n], Conditional(Forall(instance_param_or_params = [a, Q_1_to_m, R_1_to_n], instance_expr = Equals(Conditional(a, And(And(Q_1_to_m), And(R_1_to_n))), Conditional(a, And(Q_1_to_m, R_1_to_n))).with_wrapping_at(1)), And(InSet(m, Natural), InSet(n, Natural))))
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_{a, Q_{1}, Q_{2}, \ldots, Q_{m}, R_{1}, R_{2}, \ldots, R_{n}}~\left(\begin{array}{c} \begin{array}{l} \left\{a \textrm{ if } Q_{1} \land  Q_{2} \land  \ldots \land  Q_{m} ,  R_{1} \land  R_{2} \land  \ldots \land  R_{n}\right.. \\  = \left\{a \textrm{ if } Q_{1} ,  Q_{2} ,  \ldots ,  Q_{m}, R_{1} ,  R_{2} ,  \ldots ,  R_{n}\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
1ExprTuple34, 37
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 29
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 14
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple22, 31, 32
12Operationoperator: 16
operands: 17
13ExprTuple34, 18
14Literal
15ExprTuple37, 18
16Literal
17ExprTuple19, 20
18Literal
19Conditionalvalue: 22
condition: 21
20Conditionalvalue: 22
condition: 23
21Operationoperator: 29
operands: 24
22Variable
23Operationoperator: 29
operands: 25
24ExprTuple26, 27
25ExprTuple31, 32
26Operationoperator: 29
operands: 28
27Operationoperator: 29
operands: 30
28ExprTuple31
29Literal
30ExprTuple32
31ExprRangelambda_map: 33
start_index: 36
end_index: 34
32ExprRangelambda_map: 35
start_index: 36
end_index: 37
33Lambdaparameter: 43
body: 38
34Variable
35Lambdaparameter: 43
body: 39
36Literal
37Variable
38IndexedVarvariable: 40
index: 43
39IndexedVarvariable: 41
index: 43
40Variable
41Variable
42ExprTuple43
43Variable