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 Conditional, ExprArray, Lambda, i, j
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import And, Forall, InSet, NotEquals
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Lambda([i, j], Conditional(Forall(instance_param_or_params = [a_1_to_i, b_1_to_j], instance_expr = NotEquals(ExprArray(a_1_to_i), ExprArray(b_1_to_j))), And(InSet(i, Natural), InSet(j, Natural), NotEquals(i, j))))
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(i, j\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}}~\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}} \\
\end{array}
\right) \neq \left(\begin{array}{c} 
 \multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & b_{1} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & b_{2} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & \vdots & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & b_{j} & \rightarrow \end{array}} \\
\end{array}
\right)\right) \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  i \neq j\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 17
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 4
operand: 8
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple8
6Literal
7ExprTuple9, 10, 11
8Lambdaparameters: 12
body: 13
9Operationoperator: 15
operands: 14
10Operationoperator: 15
operands: 16
11Operationoperator: 18
operands: 17
12ExprTuple23, 24
13Operationoperator: 18
operands: 19
14ExprTuple26, 20
15Literal
16ExprTuple29, 20
17ExprTuple26, 29
18Literal
19ExprTuple21, 22
20Literal
21ExprTuple23
22ExprTuple24
23ExprRangelambda_map: 25
start_index: 28
end_index: 26
24ExprRangelambda_map: 27
start_index: 28
end_index: 29
25Lambdaparameter: 35
body: 30
26Variable
27Lambdaparameter: 35
body: 31
28Literal
29Variable
30IndexedVarvariable: 32
index: 35
31IndexedVarvariable: 33
index: 35
32Variable
33Variable
34ExprTuple35
35Variable