module U = NUri
module C = Cps
+module S = Share
module L = Log
module P = Output
module B = Brg
in
raise (TypeError (L.ct_items3 sc c st1 t1 st2 t2 st3 t3))
+let are_alpha_convertible f t1 t2 =
+ let rec aux f = function
+ | B.Sort (_, p1), B.Sort (_, p2)
+ | B.LRef (_, p1), B.LRef (_, p2) -> f (p1 = p2)
+ | B.GRef (_, u1), B.GRef (_, u2) -> f (U.eq u1 u2)
+ | B.Cast (_, v1, t1), B.Cast (_, v2, t2)
+ | B.Appl (_, v1, t1), B.Appl (_, v2, t2) ->
+ let f r = if r then aux f (t1, t2) else f r in
+ aux f (v1, v2)
+ | B.Bind (_, b1, t1), B.Bind (_, b2, t2) ->
+ let f r = if r then aux f (t1, t2) else f r in
+ aux_bind f (b1, b2)
+ | B.Sort _ as t1, B.Bind (_, _, t2) -> aux f (t1, t2)
+ | _ -> f false
+ 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 true
+ | _ -> f false
+ in
+ if S.eq t1 t2 then f true else aux f (t1, t2)
+
let get f m i =
B.get error0 f m.c i
get f m i
let assert_conversion f ?(si=false) ?(rt=false) mw u w v =
- let f b = L.unbox level; f b in
let f mu u =
- let f = function
- | true -> f ()
- | false -> error3 mw.c v w u
- in
L.box level; log2 "Now converting" mu.c u mw.c w;
- ac f ~si true mu u mw w
+ let f r =
+ if r then begin L.unbox level; f () end else error3 mw.c v w u
+ in
+ let g r = if r then f r else ac f ~si true mu u mw w in
+ if S.eq mu mw then are_alpha_convertible g u w else g false
in
if rt then domain f mw u else f mw u