| OCR Text |
Show Reduce(term) begin if term is a constant or a variable or none of its subterms (including itself) is reducible then return term; let term be f(t1'" .. ,tn) if One_ Step_ Reduction(term) returns "irreducible" then return f(Reduce(t 1 ), ... ,Reduce(tn)) else return Reduce(One Step_ Reduction(term)) end. Figure 16: An interpreter for function reductions Example 12. Computing any finite portion of an infinite se - quence whose elements are pairs of consecutive integers and their squares, both increased by 1. pairs(N) = [N, N*N]Apairs(N+1) first_N_pairs(N) = truncate(N, map(map(plus1))(pairs(1))) plus1 (N) = N+1 truncate(O, L) = [] truncate(N, AAL) = AAtruncate(N-1, L) The function map is defined in Example 10. Note that we have used [N ,N*N] (which is the Pro log list representation) to represent NAN*N for clarity. The sequence of reductions in interpreting the function term first N_pairs( 2) is shown in Figure 17. 0 6.2 A Combined Computational Model for Functions and logic i' 111 In this section we describe a computation model that combines functions and logic. We first generalize the notion of biased semantic unification to semantic unification, and then discuss general unification in the presence of an equational theory. The semantic foundations of Funlog are also discussed. |