- 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"
+ 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 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 ()