let rec psubst ?(avoid_beta_redexes=false) delift lift_args args =
let nargs = List.length args in
let rec substaux k = function
+ | NCic.Sort _
+ | NCic.Const _ as t -> t
| NCic.Rel n as t ->
(match n with
| n when n >= (k+nargs) -> if delift then NCic.Rel (n - nargs) else t
(* 1-nargs < k-m, when <= 0 is still reasonable because we will
* substitute args[ k-m ... k-m+nargs-1 > 0 ] *)
NCic.Meta (i,(m, NCic.Ctx (List.map (substaux (k-m)) lctx)))
- | NCic.Sort _ as t -> t
| NCic.Implicit _ -> assert false (* was identity *)
| NCic.Prod (n,s,t) -> NCic.Prod (n, substaux k s, substaux (k + 1) t)
| NCic.Lambda (n,s,t) -> NCic.Lambda (n, substaux k s, substaux (k + 1) t)
let tl = List.map (substaux k) tl in
avoid (substaux k he) tl
| NCic.Appl _ -> assert false
- | NCic.Const _ as t -> t
| NCic.Match (r,outt,t,pl) ->
NCic.Match (r,substaux k outt, substaux k t, List.map (substaux k) pl)
in