// // Course: BU CAS CS 520, Fall 2010 // Instructor: Hongwei Xi (hwxi AT cs DOT bu DOT edu) // Lecture on Thursday, Sep. 16, 2010 // (* ****** ****** *) datatype term = | TMvar of string // variable | TMlam of (string, term) // abstraction | TMapp of (term, term) // application // end of [term] (* ****** ****** *) // // for printing lambda-terms // fun fprint_term (out: FILEref, t: term): void fun print_term (t: term): void overload print with print_term fun prerr_term (t: term): void overload prerr with prerr_term (* ****** ****** *) // // Some commonly used lambda-terms // val I : term val K : term and K' : term val S : term (* ****** ****** *) fun size (t: term): int (* ****** ****** *) typedef path = list0 int fun subterm (t: term, ps: path): term (* ****** ****** *) // // HX: computing t[x->v] where [v] is closed. // fun subst0 (t: term, x: string, v: term): term (* ****** ****** *) // // HX: eval0(t) gives the so-called weak-head normal form (WHNF) // fun eval0 (t: term): term (* ****** ****** *) (* end of [lambda.sats] *)