//
// Course: BU CAS CS 520, Fall 2010
// Instructor: Hongwei Xi (hwxi AT cs DOT bu DOT edu)
// Lecture on Tuesday, Sep. 28, 2010
//

(* ****** ****** *)

datatype term =
  | TMvar of string // variable
  | TMlam of (string, term) // abstraction
  | TMapp of (term, term) // application
  | TMint of int
  | TMbool of bool
  | TMopr of (string (*opname*), termlst)
  | TMif of (term, term, term)
  | TMlet of (string, term, term) // let x = t1 in t2
// end of [term]

where termlst = list0 (term)

(* ****** ****** *)
//
// for printing lambda-terms
//
fun fprint_term (out: FILEref, t: term): void
fun fprint_termlst (out: FILEref, t: termlst): void
fun print_term (t: term): void
overload print with print_term
fun prerr_term (t: term): void
overload prerr with prerr_term

(* ****** ****** *)
//
// HX: [v] is assumed to be closed
//
fun subst0 (t: term, x: string, v: term): term

(* ****** ****** *)

fun eval0 (t: term): term // WHNF-evaluator

(* ****** ****** *)

fun genNumeral (n: int): term
fun print_numeral (n: term): void

(* ****** ****** *)

(* end of [lambda.sats] *)