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, R, a, m
from proveit.core_expr_types import Q_1_to_m
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, Conditional(Forall(instance_param_or_params = [a, Q_1_to_m, R], instance_expr = Equals(Conditional(a, And(And(Q_1_to_m), R)), Conditional(a, And(Q_1_to_m, R))).with_wrapping_at(1)), InSet(m, 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())
m \mapsto \left\{\forall_{a, Q_{1}, Q_{2}, \ldots, Q_{m}, R}~\left(\begin{array}{c} \begin{array}{l} \left\{a \textrm{ if } Q_{1} \land  Q_{2} \land  \ldots \land  Q_{m} ,  R\right.. \\  = \left\{a \textrm{ if } Q_{1} ,  Q_{2} ,  \ldots ,  Q_{m} ,  R\right.. \end{array} \end{array}\right) \textrm{ if } m \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: 29
body: 2
1ExprTuple29
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple29, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple18, 26, 23
12Operationoperator: 13
operands: 14
13Literal
14ExprTuple15, 16
15Conditionalvalue: 18
condition: 17
16Conditionalvalue: 18
condition: 19
17Operationoperator: 24
operands: 20
18Variable
19Operationoperator: 24
operands: 21
20ExprTuple22, 23
21ExprTuple26, 23
22Operationoperator: 24
operands: 25
23Variable
24Literal
25ExprTuple26
26ExprRangelambda_map: 27
start_index: 28
end_index: 29
27Lambdaparameter: 33
body: 30
28Literal
29Variable
30IndexedVarvariable: 31
index: 33
31Variable
32ExprTuple33
33Variable