From: Claudio Sacerdoti Coen Date: Fri, 13 Jul 2007 18:04:35 +0000 (+0000) Subject: Dirty patch by Zack: natural numbers of Matita are now pretty-printed as numbers... X-Git-Tag: make_still_working~6190 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=af95d9e68e803244c919fee21877a38ef13c863b;p=helm.git Dirty patch by Zack: natural numbers of Matita are now pretty-printed as numbers. Eureka. --- diff --git a/helm/software/components/acic_content/termAcicContent.ml b/helm/software/components/acic_content/termAcicContent.ml index eaa532590..9a30b50fb 100644 --- a/helm/software/components/acic_content/termAcicContent.ml +++ b/helm/software/components/acic_content/termAcicContent.ml @@ -123,7 +123,7 @@ let ast_of_acic0 term_info acic k = 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 @@ -143,14 +143,17 @@ let ast_of_acic0 term_info acic k = 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) -> diff --git a/helm/software/components/cic/libraryObjects.ml b/helm/software/components/cic/libraryObjects.ml index e2f5fd363..7e1dc626f 100644 --- a/helm/software/components/cic/libraryObjects.ml +++ b/helm/software/components/cic/libraryObjects.ml @@ -200,6 +200,14 @@ let nat_URI = UriManager.uri_of_string "cic:/matita/nat/nat/nat.ind" 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 @@ -207,3 +215,11 @@ let build_nat n = | 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 + diff --git a/helm/software/components/cic/libraryObjects.mli b/helm/software/components/cic/libraryObjects.mli index 8aacd8da3..bb742f172 100644 --- a/helm/software/components/cic/libraryObjects.mli +++ b/helm/software/components/cic/libraryObjects.mli @@ -65,3 +65,5 @@ val true_URI : unit -> UriManager.uri option val absurd_URI : unit -> UriManager.uri option val build_nat : int -> Cic.term +val destroy_nat : Cic.annterm -> int option +