- let s1, s2, s3 = s ^ " in the context", "the term", "and in the context" in
- L.log O.specs level (L.ct_items2 s1 cu s2 u s3 ct s2 t)
-
-let error0 i =
- let s = Printf.sprintf "local reference not found %u" i in
- raise (TypeError (L.items1 s))
-
-let error1 st c t =
- let sc = "In the context" in
- raise (TypeError (L.ct_items1 sc c st t))
-
-let error3 c t1 t2 t3 =
- let sc, st1, st2, st3 =
- "In the context", "the term", "is of type", "but must be of type"
- in
- raise (TypeError (L.ct_items3 sc c st1 t1 st2 t2 st3 t3))
-
-let empty_machine c = {
- c = c; s = []
-}
-
-let get f m i =
- let f e = function
- | Some (_, b) -> f e b
- | None -> error0 i
+ let s1, s2, s3 = s ^ " in the environment", "the term", "and in the environment" in
+ L.log O.specs level (L.et_items2 s1 cu s2 u ~sc2:s3 ~c2:ct s2 t)
+
+let rec list_and map = function
+ | hd1 :: tl1, hd2 :: tl2 ->
+ if map hd1 hd2 then list_and map (tl1, tl2) else false
+ | l1, l2 -> l1 = l2
+
+(* check closure *)
+let are_alpha_convertible err f t1 t2 =
+ let rec aux f = function
+ | B.Sort (_, p1), B.Sort (_, p2)
+ | B.LRef (_, p1), B.LRef (_, p2) ->
+ if p1 = p2 then f () else err ()
+ | B.GRef (_, u1), B.GRef (_, u2) ->
+ if U.eq u1 u2 then f () else err ()
+ | B.Cast (_, v1, t1), B.Cast (_, v2, t2)
+ | B.Appl (_, v1, t1), B.Appl (_, v2, t2) ->
+ let f _ = aux f (t1, t2) in
+ aux f (v1, v2)
+ | B.Bind (_, b1, t1), B.Bind (_, b2, t2) ->
+ let f _ = aux f (t1, t2) in
+ aux_bind f (b1, b2)
+ | _ -> err ()
+ and aux_bind f = function
+ | B.Abbr v1, B.Abbr v2
+ | B.Abst v1, B.Abst v2 -> aux f (v1, v2)
+ | B.Void, B.Void -> f ()
+ | _ -> err ()