-let rec normalize ?(delta=0) ~subst ctx t =
- let aux = normalize ~delta ~subst in
- match NCicReduction.whd ~delta ~subst ctx t with
+let rec normalize status ?(delta=0) ~subst ctx t =
+ normalize_machine status ~delta ~subst ctx
+ (fst (NCicReduction.reduce_machine status ~delta ~subst ctx (0,[],t,[])))
+and normalize_machine status ?(delta=0) ~subst ctx (k,e,t,s) =
+ let t =
+ if k = 0 then t
+ else
+ NCicSubstitution.psubst status ~avoid_beta_redexes:true
+ (fun e -> normalize_machine status ~delta ~subst ctx (NCicReduction.from_env ~delta e)) e t in
+ let t =
+ match t with