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, Q, a, n
from proveit.core_expr_types import 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(n, Conditional(Forall(instance_param_or_params = [a, Q, R_1_to_n], instance_expr = Equals(Conditional(a, And(Q, And(R_1_to_n))), Conditional(a, And(Q, R_1_to_n))).with_wrapping_at(1)), 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())
n \mapsto \left\{\forall_{a, Q, R_{1}, R_{2}, \ldots, R_{n}}~\left(\begin{array}{c} \begin{array}{l} \left\{a \textrm{ if } Q ,  R_{1} \land  R_{2} \land  \ldots \land  R_{n}\right.. \\  = \left\{a \textrm{ if } Q, R_{1} ,  R_{2} ,  \ldots ,  R_{n}\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: 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, 23, 26
12Operationoperator: 13
operands: 14
13Literal
14ExprTuple15, 16
15Conditionalvalue: 18
condition: 17
16Conditionalvalue: 18
condition: 19
17Operationoperator: 24
operands: 20
18Variable
19Operationoperator: 24
operands: 21
20ExprTuple23, 22
21ExprTuple23, 26
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