- | Cic.AAppl (aid,(Cic.AMutConstruct _ as he::tl as args)) ->
- if CoercGraph.is_a_coercion (Deannotate.deannotate_term he) &&
- !Acic2content.hide_coercions
- then
- let rec last =
- function
- [] -> assert false
- | [t] -> t
- | _::tl -> last tl
- in
- idref aid (k (last tl))
- else
- idref aid (Ast.Appl (List.map k args))
+ | Cic.AAppl (aid,(Cic.AMutConstruct _ as he::tl as args)) as t ->
+ let last_n n l =
+ let rec aux =
+ function
+ [] -> assert false
+ | [_] as l -> l,1
+ | he::tl ->
+ let (res,len) as res' = aux tl in
+ if len < n then
+ he::res,len + 1
+ else
+ res'
+ in
+ match fst (aux l) with
+ [] -> assert false
+ | [t] -> t
+ | Ast.AttributedTerm (_,(Ast.Appl l))::tl ->
+ idref aid (Ast.Appl (l@tl))
+ | l -> idref aid (Ast.Appl l)
+ in
+ (match LibraryObjects.destroy_nat t with
+ | Some n -> idref aid (Ast.Num (string_of_int n, -1))
+ | None ->
+ let deannot_he = Deannotate.deannotate_term he in
+ if CoercDb.is_a_coercion' deannot_he && !Acic2content.hide_coercions
+ then
+ (match CoercDb.is_a_coercion_to_funclass deannot_he with
+ | None -> idref aid (last_n 1 (List.map k tl))
+ | Some i -> idref aid (last_n (i+1) (List.map k tl)))
+ else
+ idref aid (Ast.Appl (List.map k args)))