let splat_args ctx t n_fix =
let bound, free, primo_ce_dopo_fix = context_tassonomy ctx in
- let rec aux = function
- | 0 -> []
- | n ->
- (match List.nth ctx (n-1) with
- | Ce _ when n <= bound -> NCic.Rel n
- | Fix (refe, _, _) when n < primo_ce_dopo_fix ->
- splat_args_for_rel ctx (NCic.Const refe)
- | Fix _ | Ce _ -> NCic.Rel (n - n_fix)
- ) :: aux (n-1)
- in
- NCic.Appl (t:: aux (List.length ctx))
+ if ctx = [] then t
+ else
+ let rec aux = function
+ | 0 -> []
+ | n ->
+ (match List.nth ctx (n-1) with
+ | Ce _ when n <= bound -> NCic.Rel n
+ | Fix (refe, _, _) when n < primo_ce_dopo_fix ->
+ splat_args_for_rel ctx (NCic.Const refe)
+ | Fix _ | Ce _ -> NCic.Rel (n - n_fix)
+ ) :: aux (n-1)
+ in
+ NCic.Appl (t:: aux (List.length ctx))
;;
(* we are lambda-lifting also variables that do not occur *)