open Format open Syntax open Support.Error open Support.Pervasive (* ------------------------ EVALUATION ------------------------ *) let rec isval ctx t = match t with TmAbs(_,_,_) -> true | _ -> false exception NoRuleApplies let rec eval ctx t = match t with _ when isval ctx t -> t | TmApp(fi,t1,t2) -> (match eval ctx t1 with TmAbs(_,_,t12) -> let v2 = eval ctx t2 in eval ctx (termSubstTop v2 t12) | _ -> raise NoRuleApplies) | _ -> raise NoRuleApplies