(* well typed and avoid_beta_redexes is true. *)
(* map_arg is ReductionStrategy.from_env_for_unwind when psubst is *)
(* used to implement nCicReduction.unwind' *)
-let rec psubst ?(avoid_beta_redexes=false) delift lift_args map_arg args =
+let rec psubst ?(avoid_beta_redexes=false) map_arg args =
let nargs = List.length args in
let rec substaux k = function
| NCic.Rel n as t ->
(match n with
| n when n >= (k+nargs) ->
- if delift && nargs <> 0 then NCic.Rel (n - nargs) else t
+ if nargs <> 0 then NCic.Rel (n - nargs) else t
| n when n < k -> t
| n (* k <= n < k+nargs *) ->
- (try lift (k-1+lift_args) (map_arg (List.nth args (n-k)))
+ (try lift (k-1) (map_arg (List.nth args (n-k)))
with Failure _ -> assert false))
| NCic.Meta (i,(m,l)) as t when m >= k + nargs - 1 ->
- if delift && nargs <> 0 then NCic.Meta (i,(m-nargs,l)) else t
+ if nargs <> 0 then NCic.Meta (i,(m-nargs,l)) else t
| NCic.Meta (i,(m,(NCic.Irl l as irl))) as t when k > l + m ->
- if delift && nargs <> 0 then NCic.Meta (i,(m-nargs,irl)) else t
+ if nargs <> 0 then NCic.Meta (i,(m-nargs,irl)) else t
| NCic.Meta (i,(m,l)) ->
let lctx = NCicUtils.expand_local_context l in
(* 1-nargs < k-m, when <= 0 is still reasonable because we will
(* map_arg is here \x.x, Obj magic is needed because
* we don't have polymorphic recursion w/o records *)
avoid (psubst
- ~avoid_beta_redexes true 0 Obj.magic [Obj.magic arg] bo) tl'
+ ~avoid_beta_redexes Obj.magic [Obj.magic arg] bo) tl'
| _ -> if he == he' && args == tl then t else NCic.Appl (he'::args))
in
let tl = HExtlib.sharing_map (substaux k) tl in
;;
let subst ?avoid_beta_redexes arg =
- psubst ?avoid_beta_redexes true 0 (fun x -> x)[arg];;
+ psubst ?avoid_beta_redexes (fun x -> x)[arg];;
(* subst_meta (n, Some [t_1 ; ... ; t_n]) t *)
(* returns the term [t] where [Rel i] is substituted with [t_i] lifted by n *)
(* [t_i] is lifted as usual when it crosses an abstraction *)
-(* subst_meta (n, Non) t -> lift n t *)
+(* subst_meta (n, Non) t -> lift n t *)
let subst_meta = function
| m, NCic.Irl _
| m, NCic.Ctx [] -> lift m
- | m, NCic.Ctx l -> psubst false m (fun x -> x) l
+ | m, NCic.Ctx l -> psubst (lift m) l
;;