diff options
author | Samuel Mimram <smimram@debian.org> | 2006-06-16 14:41:51 +0000 |
---|---|---|
committer | Samuel Mimram <smimram@debian.org> | 2006-06-16 14:41:51 +0000 |
commit | e978da8c41d8a3c19a29036d9c569fbe2a4616b0 (patch) | |
tree | 0de2a907ee93c795978f3c843155bee91c11ed60 /kernel/term.ml | |
parent | 3ef7797ef6fc605dfafb32523261fe1b023aeecb (diff) |
Imported Upstream version 8.0pl3+8.1betaupstream/8.0pl3+8.1beta
Diffstat (limited to 'kernel/term.ml')
-rw-r--r-- | kernel/term.ml | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/kernel/term.ml b/kernel/term.ml index 7060d000..228ae48a 100644 --- a/kernel/term.ml +++ b/kernel/term.ml @@ -6,7 +6,7 @@ (* * GNU Lesser General Public License Version 2.1 *) (************************************************************************) -(* $Id: term.ml 8049 2006-02-16 10:42:18Z coq $ *) +(* $Id: term.ml 8850 2006-05-23 16:11:31Z herbelin $ *) (* This module instantiates the structure of generic deBruijn terms to Coq *) @@ -643,7 +643,7 @@ let body_of_type ty = ty type named_declaration = identifier * constr option * types type rel_declaration = name * constr option * types -let map_named_declaration f (id, v, ty) = (id, option_app f v, f ty) +let map_named_declaration f (id, v, ty) = (id, option_map f v, f ty) let map_rel_declaration = map_named_declaration (****************************************************************************) @@ -752,36 +752,34 @@ let rec lift_substituend depth s = let make_substituend c = { sinfo=Unknown; sit=c } -let substn_many lamv n = +let substn_many lamv n c = let lv = Array.length lamv in - let rec substrec depth c = match kind_of_term c with - | Rel k -> - if k<=depth then - c - else if k-depth <= lv then - lift_substituend depth lamv.(k-depth-1) - else - mkRel (k-lv) - | _ -> map_constr_with_binders succ substrec depth c - in - substrec n + if lv = 0 then c + else + let rec substrec depth c = match kind_of_term c with + | Rel k -> + if k<=depth then c + else if k-depth <= lv then lift_substituend depth lamv.(k-depth-1) + else mkRel (k-lv) + | _ -> map_constr_with_binders succ substrec depth c in + substrec n c (* let substkey = Profile.declare_profile "substn_many";; let substn_many lamv n c = Profile.profile3 substkey substn_many lamv n c;; *) -let substnl laml k = - substn_many (Array.map make_substituend (Array.of_list laml)) k -let substl laml = - substn_many (Array.map make_substituend (Array.of_list laml)) 0 +let substnl laml n = + substn_many (Array.map make_substituend (Array.of_list laml)) n +let substl laml = substnl laml 0 let subst1 lam = substl [lam] -let substl_decl laml (id,bodyopt,typ) = - match bodyopt with - | None -> (id,None,substl laml typ) - | Some body -> (id, Some (substl laml body), type_app (substl laml) typ) +let substnl_decl laml k (id,bodyopt,typ) = + (id,option_map (substnl laml k) bodyopt,substnl laml k typ) +let substl_decl laml = substnl_decl laml 0 let subst1_decl lam = substl_decl [lam] +let subst1_named_decl = subst1_decl +let substl_named_decl = substl_decl (* (thin_val sigma) removes identity substitutions from sigma *) |