logo

Expression of type Lambda

from the theory of proveit.core_expr_types.expr_arrays

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 ExprArray, Lambda, b, d
from proveit.core_expr_types import a_1_to_i, c_1_to_i
from proveit.logic import And, Equals
In [2]:
# build up the expression from sub-expressions
expr = Lambda([a_1_to_i, b, c_1_to_i, d], Equals(Equals(ExprArray(a_1_to_i, b), ExprArray(c_1_to_i, d)), And(Equals([a_1_to_i], [c_1_to_i]), Equals(b, d))).with_wrapping_at(2))
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(a_{1}, a_{2}, \ldots, a_{i}, b, c_{1}, c_{2}, \ldots, c_{i}, d\right) \mapsto \left(\begin{array}{c} \begin{array}{l} \left(\left(\begin{array}{c} 
 \multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & a_{1} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & a_{2} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & \vdots & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & a_{i} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & b & \rightarrow \end{array}} \\
\end{array}
\right) = \left(\begin{array}{c} 
 \multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & c_{1} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & c_{2} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & \vdots & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & c_{i} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & d & \rightarrow \end{array}} \\
\end{array}
\right)\right) =  \\ \left(\left(\left(a_{1}, a_{2}, \ldots, a_{i}\right) = \left(c_{1}, c_{2}, \ldots, c_{i}\right)\right) \land \left(b = d\right)\right) \end{array} \end{array}\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
1ExprTuple20, 18, 21, 19
2Operationoperator: 14
operands: 3
3ExprTuple4, 5
4Operationoperator: 14
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple9, 10
7Literal
8ExprTuple11, 12
9ExprTuple20, 18
10ExprTuple21, 19
11Operationoperator: 14
operands: 13
12Operationoperator: 14
operands: 15
13ExprTuple16, 17
14Literal
15ExprTuple18, 19
16ExprTuple20
17ExprTuple21
18Variable
19Variable
20ExprRangelambda_map: 22
start_index: 24
end_index: 25
21ExprRangelambda_map: 23
start_index: 24
end_index: 25
22Lambdaparameter: 31
body: 26
23Lambdaparameter: 31
body: 27
24Literal
25Variable
26IndexedVarvariable: 28
index: 31
27IndexedVarvariable: 29
index: 31
28Variable
29Variable
30ExprTuple31
31Variable