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, TRUE
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(Q_1_to_m, TRUE, 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} ,  Q_{2} ,  \ldots ,  Q_{m} ,  \top, R_{1} ,  R_{2} ,  \ldots ,  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
1ExprTuple31, 34
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 25
operands: 7
5Literal
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameters: 11
body: 12
9Operationoperator: 14
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple22, 28, 29
12Operationoperator: 16
operands: 17
13ExprTuple31, 18
14Literal
15ExprTuple34, 18
16Literal
17ExprTuple19, 20
18Literal
19Conditionalvalue: 22
condition: 21
20Conditionalvalue: 22
condition: 23
21Operationoperator: 25
operands: 24
22Variable
23Operationoperator: 25
operands: 26
24ExprTuple28, 27, 29
25Literal
26ExprTuple28, 29
27Literal
28ExprRangelambda_map: 30
start_index: 33
end_index: 31
29ExprRangelambda_map: 32
start_index: 33
end_index: 34
30Lambdaparameter: 40
body: 35
31Variable
32Lambdaparameter: 40
body: 36
33Literal
34Variable
35IndexedVarvariable: 37
index: 40
36IndexedVarvariable: 38
index: 40
37Variable
38Variable
39ExprTuple40
40Variable