1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
\DOC FOLDL_CONV
\TYPE {FOLDL_CONV : conv -> conv}
\SYNOPSIS
Computes by inference the result of applying a function to elements of a list.
\KEYWORDS
conversion, list.
\DESCRIBE
{FOLDL_CONV} takes a conversion {conv} and a term {tm} in the following form:
{
FOLDL f e [x0;...xn]
}
\noindent It returns the theorem
{
|- FOLDL f e [x0;...xn] = tm'
}
\noindent where {tm'} is the result of applying the function {f} iteratively to
the successive elements of the list and the result of the previous
application starting from the tail end of the list. During each
iteration, an expression {f ei xi} is evaluated. The user supplied
conversion {conv} is used to derive a theorem
{
|- f ei xi = e(i+1)
}
\noindent which is used in the next iteration.
\FAILURE
{FOLDL_CONV conv tm} fails if {tm} is not of the form described above.
\EXAMPLE
To sum the elements of a list, one can evaluate
{
FOLDL_CONV ADD_CONV "FOLDL $+ 0 [0;1;2;3]";;
}
\noindent which returns the following theorem:
{
|- FOLDL $+ 0[0;1;2;3] = 6
}
\noindent In general, if the function {f} is an explicit lambda abstraction
{(\x x'. t[x,x'])}, the conversion should be in the form
{
((RATOR_CONV BETA_CONV) THENC BETA_CONV THENC conv'))
}
\noindent where {conv'} applied to {t[x,x']} returns the theorem
{
|-t[x,x'] = e''.
}
\SEEALSO
FOLDR_CONV, list_FOLD_CONV.
\ENDDOC
|