k s, k t))
| Cic.AAppl (aid,(Cic.AConst _ as he::tl as args))
| Cic.AAppl (aid,(Cic.AMutInd _ as he::tl as args))
- | Cic.AAppl (aid,(Cic.AMutConstruct _ as he::tl as args)) ->
+ | Cic.AAppl (aid,(Cic.AMutConstruct _ as he::tl as args)) as t ->
let last_n n l =
let rec aux =
function
idref aid (Ast.Appl (l@tl))
| l -> idref aid (Ast.Appl l)
in
- 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))
+ (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)))
| Cic.AAppl (aid,args) ->
idref aid (Ast.Appl (List.map k args))
| Cic.AConst (id,uri,substs) ->
let zero = Cic.MutConstruct (nat_URI,0,1,[])
let succ = Cic.MutConstruct (nat_URI,0,2,[])
+let is_zero = function
+ | Cic.AMutConstruct (_, uri, 0, 1, _) when UriManager.eq uri nat_URI -> true
+ | _ -> false
+
+let is_succ = function
+ | Cic.AMutConstruct (_, uri, 0, 2, _) when UriManager.eq uri nat_URI -> true
+ | _ -> false
+
let build_nat n =
if n < 0 then assert false;
let rec aux = function
| n -> Cic.Appl [ succ; (aux (n - 1)) ]
in
aux n
+
+let destroy_nat annterm =
+ let rec aux acc = function
+ | Cic.AAppl (_, [he ; tl]) when is_succ he -> aux (acc + 1) tl
+ | t when is_zero t -> Some acc
+ | _ -> None in
+ aux 0 annterm
+