| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
open Names |
| 12 |
|
| 13 |
open GlobRef |
| 14 |
|
| 15 |
let isVarRef = function VarRef _ -> true | _ -> false |
| 16 |
let isConstRef = function ConstRef _ -> true | _ -> false |
| 17 |
let isIndRef = function IndRef _ -> true | _ -> false |
| 18 |
let isConstructRef = function ConstructRef _ -> true | _ -> false |
| 19 |
|
| 20 |
let destVarRef = function VarRef ind -> ind | _ -> failwith "destVarRef" |
| 21 |
let destConstRef = function ConstRef ind -> ind | _ -> failwith "destConstRef" |
| 22 |
let destIndRef = function IndRef ind -> ind | _ -> failwith "destIndRef" |
| 23 |
let destConstructRef = function ConstructRef ind -> ind | _ -> failwith "destConstructRef" |
| 24 |
|
| 25 |
|
| 26 |
let subst_global_reference subst ref = match ref with |
| 27 |
| VarRef var -> ref |
| 28 |
| ConstRef kn -> |
| 29 |
let kn' = Mod_subst.subst_constant subst kn in |
| 30 |
if kn==kn' then ref else ConstRef kn' |
| 31 |
| IndRef ind -> |
| 32 |
let ind' = Mod_subst.subst_ind subst ind in |
| 33 |
if ind==ind' then ref else IndRef ind' |
| 34 |
| ConstructRef ((kn,i),j as c) -> |
| 35 |
let c' = Mod_subst.subst_constructor subst c in |
| 36 |
if c'==c then ref else ConstructRef c' |
| 37 |
|
| 38 |
let subst_global subst ref = match ref with |
| 39 |
| VarRef var -> ref, None |
| 40 |
| ConstRef kn -> |
| 41 |
let kn',t = Mod_subst.subst_con subst kn in |
| 42 |
if kn==kn' then ref, None else ConstRef kn', t |
| 43 |
| IndRef ind -> |
| 44 |
let ind' = Mod_subst.subst_ind subst ind in |
| 45 |
if ind==ind' then ref, None else IndRef ind', None |
| 46 |
| ConstructRef ((kn,i),j as c) -> |
| 47 |
let c' = Mod_subst.subst_constructor subst c in |
| 48 |
if c'==c then ref,None else ConstructRef c', None |
| 49 |
|
| 50 |
let canonical_gr = function |
| 51 |
| ConstRef con -> ConstRef(Constant.make1 (Constant.canonical con)) |
| 52 |
| IndRef (kn,i) -> IndRef(MutInd.make1(MutInd.canonical kn),i) |
| 53 |
| ConstructRef ((kn,i),j )-> ConstructRef((MutInd.make1(MutInd.canonical kn),i),j) |
| 54 |
| VarRef id -> VarRef id |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
type abbreviation = KerName.t |
| 59 |
|
| 60 |
type extended_global_reference = |
| 61 |
| TrueGlobal of GlobRef.t |
| 62 |
| Abbrev of abbreviation |
| 63 |
|
| 64 |
let abbreviation_eq = KerName.equal |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
module ExtRefOrdered = struct |
| 70 |
type t = extended_global_reference |
| 71 |
|
| 72 |
let equal x y = |
| 73 |
x == y || |
| 74 |
match x, y with |
| 75 |
| TrueGlobal rx, TrueGlobal ry -> GlobRef.UserOrd.equal rx ry |
| 76 |
| Abbrev knx, Abbrev kny -> KerName.equal knx kny |
| 77 |
| (TrueGlobal _ | Abbrev _), _ -> false |
| 78 |
|
| 79 |
let compare x y = |
| 80 |
if x == y then 0 |
| 81 |
else match x, y with |
| 82 |
| TrueGlobal rx, TrueGlobal ry -> GlobRef.UserOrd.compare rx ry |
| 83 |
| Abbrev knx, Abbrev kny -> KerName.compare knx kny |
| 84 |
| TrueGlobal _, Abbrev _ -> -1 |
| 85 |
| Abbrev _, TrueGlobal _ -> 1 |
| 86 |
|
| 87 |
open Hashset.Combine |
| 88 |
|
| 89 |
let hash = function |
| 90 |
| TrueGlobal gr -> combinesmall 1 (GlobRef.UserOrd.hash gr) |
| 91 |
| Abbrev kn -> combinesmall 2 (KerName.hash kn) |
| 92 |
|
| 93 |
end |
| 94 |
|
| 95 |
module ExtRefMap = HMap.Make(ExtRefOrdered) |
| 96 |
module ExtRefSet = ExtRefMap.Set |
| 97 |
|
| 98 |
let subst_extended_reference sub = function |
| 99 |
| Abbrev kn -> Abbrev (Mod_subst.subst_kn sub kn) |
| 100 |
| TrueGlobal gr -> TrueGlobal (subst_global_reference sub gr) |
| 101 |
|
| 102 |
module CustomName = KerName |