| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
e |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
open Util |
| 32 |
open Names |
| 33 |
|
| 34 |
type ('a,'r) pbinder_annot = { binder_name : 'a; binder_relevance : 'r } |
| 35 |
|
| 36 |
let eq_annot eq eqr {binder_name=na1;binder_relevance=r1} {binder_name=na2;binder_relevance=r2} = |
| 37 |
eq na1 na2 && eqr r1 r2 |
| 38 |
|
| 39 |
let hash_annot h {binder_name=n;binder_relevance=r} = |
| 40 |
Hashset.Combine.combinesmall (Sorts.relevance_hash r) (h n) |
| 41 |
|
| 42 |
let map_annot f {binder_name=na;binder_relevance} = |
| 43 |
let na' = f na in |
| 44 |
{binder_name=na';binder_relevance} |
| 45 |
|
| 46 |
let map_annot_relevance fr ({binder_name=na;binder_relevance=r} as a) = |
| 47 |
let r' = fr r in |
| 48 |
if r == r' then a else {binder_name=na;binder_relevance=r'} |
| 49 |
|
| 50 |
let map_annot_relevance_het fr {binder_name=na;binder_relevance=r} = |
| 51 |
let r' = fr r in |
| 52 |
{binder_name=na;binder_relevance=r'} |
| 53 |
|
| 54 |
let make_annot x r = {binder_name=x;binder_relevance=r} |
| 55 |
|
| 56 |
let binder_name x = x.binder_name |
| 57 |
let binder_relevance x = x.binder_relevance |
| 58 |
|
| 59 |
let annotR x = make_annot x Sorts.Relevant |
| 60 |
|
| 61 |
let nameR x = annotR (Name x) |
| 62 |
let anonR = annotR Anonymous |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
module Rel = |
| 67 |
struct |
| 68 |
|
| 69 |
module Declaration = |
| 70 |
struct |
| 71 |
|
| 72 |
type ('constr, 'types, 'r) pt = |
| 73 |
| LocalAssum of (Name.t,'r) pbinder_annot * 'types |
| 74 |
| LocalDef of (Name.t,'r) pbinder_annot * 'constr * 'types |
| 75 |
|
| 76 |
let get_annot = function |
| 77 |
| LocalAssum (na,_) | LocalDef (na,_,_) -> na |
| 78 |
|
| 79 |
|
| 80 |
let get_name x = (get_annot x).binder_name |
| 81 |
|
| 82 |
|
| 83 |
let get_value = function |
| 84 |
| LocalAssum _ -> None |
| 85 |
| LocalDef (_,v,_) -> Some v |
| 86 |
|
| 87 |
|
| 88 |
let get_type = function |
| 89 |
| LocalAssum (_,ty) |
| 90 |
| LocalDef (_,_,ty) -> ty |
| 91 |
|
| 92 |
let get_relevance x = (get_annot x).binder_relevance |
| 93 |
|
| 94 |
let set_annot x d = |
| 95 |
if get_annot d == x then d else match d with |
| 96 |
| LocalAssum (_,ty) -> LocalAssum (x, ty) |
| 97 |
| LocalDef (_,v,ty) -> LocalDef (x, v, ty) |
| 98 |
|
| 99 |
|
| 100 |
let set_name na = function |
| 101 |
| LocalAssum (x,ty) -> LocalAssum ({x with binder_name=na}, ty) |
| 102 |
| LocalDef (x,v,ty) -> LocalDef ({x with binder_name=na}, v, ty) |
| 103 |
|
| 104 |
let set_relevance r = function |
| 105 |
| LocalAssum (x,ty) -> LocalAssum ({x with binder_relevance=r}, ty) |
| 106 |
| LocalDef (x,v,ty) -> LocalDef ({x with binder_relevance=r}, v, ty) |
| 107 |
|
| 108 |
|
| 109 |
let set_type ty = function |
| 110 |
| LocalAssum (na,_) -> LocalAssum (na, ty) |
| 111 |
| LocalDef (na,v,_) -> LocalDef (na, v, ty) |
| 112 |
|
| 113 |
|
| 114 |
let is_local_assum = function |
| 115 |
| LocalAssum _ -> true |
| 116 |
| LocalDef _ -> false |
| 117 |
|
| 118 |
|
| 119 |
let is_local_def = function |
| 120 |
| LocalAssum _ -> false |
| 121 |
| LocalDef _ -> true |
| 122 |
|
| 123 |
|
| 124 |
let exists f = function |
| 125 |
| LocalAssum (_, ty) -> f ty |
| 126 |
| LocalDef (_, v, ty) -> f v || f ty |
| 127 |
|
| 128 |
|
| 129 |
let for_all f = function |
| 130 |
| LocalAssum (_, ty) -> f ty |
| 131 |
| LocalDef (_, v, ty) -> f v && f ty |
| 132 |
|
| 133 |
|
| 134 |
let equal eqr eq decl1 decl2 = |
| 135 |
match decl1, decl2 with |
| 136 |
| LocalAssum (n1,ty1), LocalAssum (n2, ty2) -> |
| 137 |
eq_annot Name.equal eqr n1 n2 && eq ty1 ty2 |
| 138 |
| LocalDef (n1,v1,ty1), LocalDef (n2,v2,ty2) -> |
| 139 |
eq_annot Name.equal eqr n1 n2 && eq v1 v2 && eq ty1 ty2 |
| 140 |
| _ -> |
| 141 |
false |
| 142 |
|
| 143 |
|
| 144 |
let map_name f x = |
| 145 |
let na = get_name x in |
| 146 |
let na' = f na in |
| 147 |
if na == na' then x else set_name na' x |
| 148 |
|
| 149 |
let map_relevance f x = |
| 150 |
let r = get_relevance x in |
| 151 |
let r' = f r in |
| 152 |
if r == r' then x else set_relevance r' x |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
let map_value f = function |
| 157 |
| LocalAssum _ as decl -> decl |
| 158 |
| LocalDef (na, v, t) as decl -> |
| 159 |
let v' = f v in |
| 160 |
if v == v' then decl else LocalDef (na, v', t) |
| 161 |
|
| 162 |
|
| 163 |
let map_type f = function |
| 164 |
| LocalAssum (na, ty) as decl -> |
| 165 |
let ty' = f ty in |
| 166 |
if ty == ty' then decl else LocalAssum (na, ty') |
| 167 |
| LocalDef (na, v, ty) as decl -> |
| 168 |
let ty' = f ty in |
| 169 |
if ty == ty' then decl else LocalDef (na, v, ty') |
| 170 |
|
| 171 |
|
| 172 |
let map_constr f = function |
| 173 |
| LocalAssum (na, ty) as decl -> |
| 174 |
let ty' = f ty in |
| 175 |
if ty == ty' then decl else LocalAssum (na, ty') |
| 176 |
| LocalDef (na, v, ty) as decl -> |
| 177 |
let v' = f v in |
| 178 |
let ty' = f ty in |
| 179 |
if v == v' && ty == ty' then decl else LocalDef (na, v', ty') |
| 180 |
|
| 181 |
|
| 182 |
let map_constr_with_relevance g f = function |
| 183 |
| LocalAssum (na, ty) as decl -> |
| 184 |
let na' = map_annot_relevance g na in |
| 185 |
let ty' = f ty in |
| 186 |
if na == na' && ty == ty' then decl else LocalAssum (na', ty') |
| 187 |
| LocalDef (na, v, ty) as decl -> |
| 188 |
let na' = map_annot_relevance g na in |
| 189 |
let v' = f v in |
| 190 |
let ty' = f ty in |
| 191 |
if na == na' && v == v' && ty == ty' then decl else LocalDef (na', v', ty') |
| 192 |
|
| 193 |
let map_constr_het fr f = function |
| 194 |
| LocalAssum (na, ty) -> |
| 195 |
let ty' = f ty in |
| 196 |
LocalAssum (map_annot_relevance_het fr na, ty') |
| 197 |
| LocalDef (na, v, ty) -> |
| 198 |
let v' = f v in |
| 199 |
let ty' = f ty in |
| 200 |
LocalDef (map_annot_relevance_het fr na, v', ty') |
| 201 |
|
| 202 |
|
| 203 |
let iter_constr f = function |
| 204 |
| LocalAssum (_,ty) -> f ty |
| 205 |
| LocalDef (_,v,ty) -> f v; f ty |
| 206 |
|
| 207 |
|
| 208 |
let fold_constr f decl acc = |
| 209 |
match decl with |
| 210 |
| LocalAssum (_n,ty) -> f ty acc |
| 211 |
| LocalDef (_n,v,ty) -> f ty (f v acc) |
| 212 |
|
| 213 |
let to_tuple = function |
| 214 |
| LocalAssum (na, ty) -> na, None, ty |
| 215 |
| LocalDef (na, v, ty) -> na, Some v, ty |
| 216 |
|
| 217 |
let drop_body = function |
| 218 |
| LocalAssum _ as d -> d |
| 219 |
| LocalDef (na, _v, ty) -> LocalAssum (na, ty) |
| 220 |
|
| 221 |
end |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
type ('constr, 'types, 'r) pt = ('constr, 'types, 'r) Declaration.pt list |
| 227 |
|
| 228 |
|
| 229 |
let empty = [] |
| 230 |
|
| 231 |
|
| 232 |
let add d ctx = d :: ctx |
| 233 |
|
| 234 |
|
| 235 |
let length = List.length |
| 236 |
|
| 237 |
|
| 238 |
let nhyps ctx = |
| 239 |
let open Declaration in |
| 240 |
let rec nhyps acc = function |
| 241 |
| [] -> acc |
| 242 |
| LocalAssum _ :: hyps -> nhyps (succ acc) hyps |
| 243 |
| LocalDef _ :: hyps -> nhyps acc hyps |
| 244 |
in |
| 245 |
nhyps 0 ctx |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
let rec lookup n ctx = |
| 250 |
match n, ctx with |
| 251 |
| 1, decl :: _ -> decl |
| 252 |
| n, _ :: sign -> lookup (n-1) sign |
| 253 |
| _, [] -> raise Not_found |
| 254 |
|
| 255 |
|
| 256 |
let equal eqr eq l = List.equal (fun c -> Declaration.equal eqr eq c) l |
| 257 |
|
| 258 |
|
| 259 |
let map f = List.Smart.map (Declaration.map_constr f) |
| 260 |
|
| 261 |
let map_with_relevance g f = List.Smart.map (Declaration.map_constr_with_relevance g f) |
| 262 |
|
| 263 |
let map_het fr f = List.map (Declaration.map_constr_het fr f) |
| 264 |
|
| 265 |
|
| 266 |
let map_with_binders f ctx = |
| 267 |
let rec aux k = function |
| 268 |
| decl :: ctx as l -> |
| 269 |
let decl' = Declaration.map_constr (f k) decl in |
| 270 |
let ctx' = aux (k-1) ctx in |
| 271 |
if decl == decl' && ctx == ctx' then l else decl' :: ctx' |
| 272 |
| [] -> [] |
| 273 |
in |
| 274 |
aux (length ctx) ctx |
| 275 |
|
| 276 |
|
| 277 |
let iter f = List.iter (Declaration.iter_constr f) |
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
let fold_inside f ~init = List.fold_left f init |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
let fold_outside f l ~init = List.fold_right f l init |
| 286 |
|
| 287 |
|
| 288 |
let to_vars l = |
| 289 |
List.fold_left (fun accu decl -> |
| 290 |
match Declaration.get_name decl with |
| 291 |
| Name id -> Id.Set.add id accu |
| 292 |
| Anonymous -> accu) |
| 293 |
Id.Set.empty l |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
let to_tags l = |
| 298 |
let rec aux l = function |
| 299 |
| [] -> l |
| 300 |
| Declaration.LocalDef _ :: ctx -> aux (true::l) ctx |
| 301 |
| Declaration.LocalAssum _ :: ctx -> aux (false::l) ctx |
| 302 |
in aux [] l |
| 303 |
|
| 304 |
let drop_bodies l = List.Smart.map Declaration.drop_body l |
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
let chop_nhyps n l = |
| 309 |
let rec aux l' = function |
| 310 |
| (0, l) -> (List.rev l', l) |
| 311 |
| (n, (Declaration.LocalDef _ as h) :: l) -> aux (h::l') (n, l) |
| 312 |
| (n, (Declaration.LocalAssum _ as h) :: l) -> aux (h::l') (n-1, l) |
| 313 |
| (_, []) -> CErrors.anomaly (Pp.str "chop_nhyps: not enough hypotheses.") |
| 314 |
in aux [] (n,l) |
| 315 |
|
| 316 |
gs:Γ] |
| 317 |
in |
| 318 |
|
| 319 |
let to_extended_list mk n l = |
| 320 |
let rec reln l p = function |
| 321 |
| Declaration.LocalAssum _ :: hyps -> reln (mk (n+p) :: l) (p+1) hyps |
| 322 |
| Declaration.LocalDef _ :: hyps -> reln l (p+1) hyps |
| 323 |
| [] -> l |
| 324 |
in |
| 325 |
reln [] 1 l |
| 326 |
|
| 327 |
) |
| 328 |
let to_extended_vect mk n hyps = Array.of_list (to_extended_list mk n hyps) |
| 329 |
|
| 330 |
|
| 331 |
let instance = to_extended_vect |
| 332 |
let instance_list = to_extended_list |
| 333 |
end |
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
module Named = |
| 338 |
struct |
| 339 |
|
| 340 |
module Declaration = |
| 341 |
struct |
| 342 |
|
| 343 |
type ('constr, 'types, 'r) pt = |
| 344 |
| LocalAssum of (Id.t,'r) pbinder_annot * 'types |
| 345 |
| LocalDef of (Id.t,'r) pbinder_annot * 'constr * 'types |
| 346 |
|
| 347 |
let get_annot = function |
| 348 |
| LocalAssum (na,_) | LocalDef (na,_,_) -> na |
| 349 |
|
| 350 |
|
| 351 |
let get_id x = (get_annot x).binder_name |
| 352 |
|
| 353 |
|
| 354 |
let get_value = function |
| 355 |
| LocalAssum _ -> None |
| 356 |
| LocalDef (_,v,_) -> Some v |
| 357 |
|
| 358 |
|
| 359 |
let get_type = function |
| 360 |
| LocalAssum (_,ty) |
| 361 |
| LocalDef (_,_,ty) -> ty |
| 362 |
|
| 363 |
let get_relevance x = (get_annot x).binder_relevance |
| 364 |
|
| 365 |
|
| 366 |
let set_id id = |
| 367 |
let set x = {x with binder_name = id} in |
| 368 |
function |
| 369 |
| LocalAssum (x,ty) -> LocalAssum (set x, ty) |
| 370 |
| LocalDef (x, v, ty) -> LocalDef (set x, v, ty) |
| 371 |
|
| 372 |
|
| 373 |
let set_type ty = function |
| 374 |
| LocalAssum (id,_) -> LocalAssum (id, ty) |
| 375 |
| LocalDef (id,v,_) -> LocalDef (id, v, ty) |
| 376 |
|
| 377 |
|
| 378 |
let is_local_assum = function |
| 379 |
| LocalAssum _ -> true |
| 380 |
| LocalDef _ -> false |
| 381 |
|
| 382 |
|
| 383 |
let is_local_def = function |
| 384 |
| LocalDef _ -> true |
| 385 |
| LocalAssum _ -> false |
| 386 |
|
| 387 |
|
| 388 |
let exists f = function |
| 389 |
| LocalAssum (_, ty) -> f ty |
| 390 |
| LocalDef (_, v, ty) -> f v || f ty |
| 391 |
|
| 392 |
|
| 393 |
let for_all f = function |
| 394 |
| LocalAssum (_, ty) -> f ty |
| 395 |
| LocalDef (_, v, ty) -> f v && f ty |
| 396 |
|
| 397 |
|
| 398 |
let equal eqr eq decl1 decl2 = |
| 399 |
match decl1, decl2 with |
| 400 |
| LocalAssum (id1, ty1), LocalAssum (id2, ty2) -> |
| 401 |
eq_annot Id.equal eqr id1 id2 && eq ty1 ty2 |
| 402 |
| LocalDef (id1, v1, ty1), LocalDef (id2, v2, ty2) -> |
| 403 |
eq_annot Id.equal eqr id1 id2 && eq v1 v2 && eq ty1 ty2 |
| 404 |
| _ -> |
| 405 |
false |
| 406 |
|
| 407 |
|
| 408 |
let map_id f x = |
| 409 |
let id = get_id x in |
| 410 |
let id' = f id in |
| 411 |
if id == id' then x else set_id id' x |
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
let map_value f = function |
| 416 |
| LocalAssum _ as decl -> decl |
| 417 |
| LocalDef (na, v, t) as decl -> |
| 418 |
let v' = f v in |
| 419 |
if v == v' then decl else LocalDef (na, v', t) |
| 420 |
|
| 421 |
|
| 422 |
let map_type f = function |
| 423 |
| LocalAssum (id, ty) as decl -> |
| 424 |
let ty' = f ty in |
| 425 |
if ty == ty' then decl else LocalAssum (id, ty') |
| 426 |
| LocalDef (id, v, ty) as decl -> |
| 427 |
let ty' = f ty in |
| 428 |
if ty == ty' then decl else LocalDef (id, v, ty') |
| 429 |
|
| 430 |
|
| 431 |
let map_constr f = function |
| 432 |
| LocalAssum (id, ty) as decl -> |
| 433 |
let ty' = f ty in |
| 434 |
if ty == ty' then decl else LocalAssum (id, ty') |
| 435 |
| LocalDef (id, v, ty) as decl -> |
| 436 |
let v' = f v in |
| 437 |
let ty' = f ty in |
| 438 |
if v == v' && ty == ty' then decl else LocalDef (id, v', ty') |
| 439 |
|
| 440 |
|
| 441 |
let map_constr_with_relevance g f = function |
| 442 |
| LocalAssum (id, ty) as decl -> |
| 443 |
let id' = map_annot_relevance g id in |
| 444 |
let ty' = f ty in |
| 445 |
if id == id' && ty == ty' then decl else LocalAssum (id', ty') |
| 446 |
| LocalDef (id, v, ty) as decl -> |
| 447 |
let id' = map_annot_relevance g id in |
| 448 |
let v' = f v in |
| 449 |
let ty' = f ty in |
| 450 |
if id == id' && v == v' && ty == ty' then decl else LocalDef (id', v', ty') |
| 451 |
|
| 452 |
let map_constr_het fr f = function |
| 453 |
| LocalAssum (id, ty) -> |
| 454 |
let ty' = f ty in |
| 455 |
LocalAssum (map_annot_relevance_het fr id, ty') |
| 456 |
| LocalDef (id, v, ty) -> |
| 457 |
let v' = f v in |
| 458 |
let ty' = f ty in |
| 459 |
LocalDef (map_annot_relevance_het fr id, v', ty') |
| 460 |
|
| 461 |
|
| 462 |
let iter_constr f = function |
| 463 |
| LocalAssum (_, ty) -> f ty |
| 464 |
| LocalDef (_, v, ty) -> f v; f ty |
| 465 |
|
| 466 |
|
| 467 |
let fold_constr f decl a = |
| 468 |
match decl with |
| 469 |
| LocalAssum (_, ty) -> f ty a |
| 470 |
| LocalDef (_, v, ty) -> a |> f v |> f ty |
| 471 |
|
| 472 |
let to_tuple = function |
| 473 |
| LocalAssum (id, ty) -> id, None, ty |
| 474 |
| LocalDef (id, v, ty) -> id, Some v, ty |
| 475 |
|
| 476 |
let of_tuple = function |
| 477 |
| id, None, ty -> LocalAssum (id, ty) |
| 478 |
| id, Some v, ty -> LocalDef (id, v, ty) |
| 479 |
|
| 480 |
let drop_body = function |
| 481 |
| LocalAssum _ as d -> d |
| 482 |
| LocalDef (id, _v, ty) -> LocalAssum (id, ty) |
| 483 |
|
| 484 |
let of_rel_decl f = function |
| 485 |
| Rel.Declaration.LocalAssum (na,t) -> |
| 486 |
LocalAssum (map_annot f na, t) |
| 487 |
| Rel.Declaration.LocalDef (na,v,t) -> |
| 488 |
LocalDef (map_annot f na, v, t) |
| 489 |
|
| 490 |
let to_rel_decl = |
| 491 |
let name x = {binder_name=Name x.binder_name;binder_relevance=x.binder_relevance} in |
| 492 |
function |
| 493 |
| LocalAssum (id,t) -> |
| 494 |
Rel.Declaration.LocalAssum (name id, t) |
| 495 |
| LocalDef (id,v,t) -> |
| 496 |
Rel.Declaration.LocalDef (name id,v,t) |
| 497 |
end |
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
type ('constr, 'types, 'r) pt = ('constr, 'types, 'r) Declaration.pt list |
| 503 |
|
| 504 |
|
| 505 |
let empty = [] |
| 506 |
|
| 507 |
|
| 508 |
let add d ctx = d :: ctx |
| 509 |
|
| 510 |
|
| 511 |
let length = List.length |
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
let rec lookup id = function |
| 516 |
| decl :: _ when Id.equal id (Declaration.get_id decl) -> decl |
| 517 |
| _ :: sign -> lookup id sign |
| 518 |
| [] -> raise Not_found |
| 519 |
|
| 520 |
|
| 521 |
let equal eqr eq l = List.equal (fun c -> Declaration.equal eqr eq c) l |
| 522 |
|
| 523 |
|
| 524 |
let map f = List.Smart.map (Declaration.map_constr f) |
| 525 |
|
| 526 |
let map_with_relevance g f = List.Smart.map (Declaration.map_constr_with_relevance g f) |
| 527 |
|
| 528 |
let map_het fr f = List.map (Declaration.map_constr_het fr f) |
| 529 |
|
| 530 |
|
| 531 |
let iter f = List.iter (Declaration.iter_constr f) |
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
let fold_inside f ~init = List.fold_left f init |
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
let fold_outside f l ~init = List.fold_right f l init |
| 540 |
|
| 541 |
|
| 542 |
let to_vars l = |
| 543 |
List.fold_left (fun accu decl -> Id.Set.add (Declaration.get_id decl) accu) Id.Set.empty l |
| 544 |
|
| 545 |
let drop_bodies l = List.Smart.map Declaration.drop_body l |
| 546 |
|
| 547 |
h |
| 548 |
local |
| 549 |
t |
| 550 |
|
| 551 |
let to_instance mk l = |
| 552 |
let filter = function |
| 553 |
| Declaration.LocalAssum (id, _) -> Some (mk id.binder_name) |
| 554 |
| _ -> None |
| 555 |
in |
| 556 |
List.map_filter filter l |
| 557 |
|
| 558 |
h |
| 559 |
local |
| 560 |
t |
| 561 |
|
| 562 |
let instance_list mk l = |
| 563 |
let filter = function |
| 564 |
| Declaration.LocalAssum (id, _) -> Some (mk id.binder_name) |
| 565 |
| _ -> None |
| 566 |
in |
| 567 |
List.rev (List.map_filter filter l) |
| 568 |
|
| 569 |
let instance mk l = |
| 570 |
Array.of_list (instance_list mk l) |
| 571 |
end |
| 572 |
|
| 573 |
module Compacted = |
| 574 |
struct |
| 575 |
module Declaration = |
| 576 |
struct |
| 577 |
type ('constr, 'types, 'r) pt = |
| 578 |
| LocalAssum of (Id.t,'r) pbinder_annot list * 'types |
| 579 |
| LocalDef of (Id.t,'r) pbinder_annot list * 'constr * 'types |
| 580 |
|
| 581 |
let map_constr f = function |
| 582 |
| LocalAssum (ids, ty) as decl -> |
| 583 |
let ty' = f ty in |
| 584 |
if ty == ty' then decl else LocalAssum (ids, ty') |
| 585 |
| LocalDef (ids, c, ty) as decl -> |
| 586 |
let ty' = f ty in |
| 587 |
let c' = f c in |
| 588 |
if c == c' && ty == ty' then decl else LocalDef (ids,c',ty') |
| 589 |
|
| 590 |
let of_named_decl = function |
| 591 |
| Named.Declaration.LocalAssum (id,t) -> |
| 592 |
LocalAssum ([id],t) |
| 593 |
| Named.Declaration.LocalDef (id,v,t) -> |
| 594 |
LocalDef ([id],v,t) |
| 595 |
|
| 596 |
let to_named_context = function |
| 597 |
| LocalAssum (ids, t) -> |
| 598 |
List.map (fun id -> Named.Declaration.LocalAssum (id,t)) ids |
| 599 |
| LocalDef (ids, v, t) -> |
| 600 |
List.map (fun id -> Named.Declaration.LocalDef (id,v,t)) ids |
| 601 |
end |
| 602 |
|
| 603 |
type ('constr, 'types, 'r) pt = ('constr, 'types, 'r) Declaration.pt list |
| 604 |
|
| 605 |
let fold f l ~init = List.fold_right f l init |
| 606 |
end |