X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_transformations%2Fcontent_expressions.ml;h=8b8d0361acd756e0eee840e1d9432822371e6bb8;hb=d3c72d6856cd185e5b3e9f2e8b928b78c7031ed1;hp=52318d1c010d7e25818c8a4b6d6180e995e1fe54;hpb=0cb045e7fe606a61ff725a2408684bb390bcb50c;p=helm.git diff --git a/helm/ocaml/cic_transformations/content_expressions.ml b/helm/ocaml/cic_transformations/content_expressions.ml index 52318d1c0..8b8d0361a 100644 --- a/helm/ocaml/cic_transformations/content_expressions.ml +++ b/helm/ocaml/cic_transformations/content_expressions.ml @@ -36,7 +36,7 @@ (* the type cexpr is inspired by OpenMath. A few primitive constructors have been added, in order to take into account some special features of functional expressions. Most notably: case, let in, let rec, and - explicit substitutons *) + explicit substitutions *) type cexpr = Symbol of string option * string * subst option * string option @@ -221,12 +221,41 @@ Hashtbl.add symbol_table "cic:/Coq/ZArith/fast_integer/Zplus.con" None, Some "cic:/Coq/ZArith/fast_integer/Zplus.con")) :: List.map acic2cexpr args));; +let rplus_uri = + UriManager.uri_of_string "cic:/Coq/Reals/Rdefinitions/Rplus.con" ;; +let r0_uri = UriManager.uri_of_string "cic:/Coq/Reals/Rdefinitions/R0.con" ;; +let r1_uri = UriManager.uri_of_string "cic:/Coq/Reals/Rdefinitions/R1.con" ;; + Hashtbl.add symbol_table "cic:/Coq/Reals/Rdefinitions/Rplus.con" (fun aid sid args acic2cexpr -> - Appl - (Some aid, (Symbol (Some sid, "plus", - None, Some "cic:/Coq/Reals/Rdefinitions/Rplus.con")) - :: List.map acic2cexpr args));; + let appl () = + Appl + (Some aid, (Symbol (Some sid, "plus", + None, Some "cic:/Coq/Reals/Rdefinitions/Rplus.con")) + :: List.map acic2cexpr args) + in + let rec aux acc = function + | [ Cic.AConst (nid, uri, []); n] when + UriManager.eq uri r1_uri -> + (match n with + | Cic.AConst (_, uri, []) when UriManager.eq uri r1_uri -> + Num (Some aid, string_of_int (acc + 2)) + | Cic.AAppl (_, Cic.AConst (_, uri, []) :: args) when + UriManager.eq uri rplus_uri -> + aux (acc + 1) args + | _ -> appl ()) + | _ -> appl () + in + aux 0 args) +;; + +(* zero and one *) + +Hashtbl.add symbol_table "cic:/Coq/Reals/Rdefinitions/R0.con" + (fun aid sid args acic2cexpr -> Num (Some sid, "0")) ;; + +Hashtbl.add symbol_table "cic:/Coq/Reals/Rdefinitions/R1.con" + (fun aid sid args acic2cexpr -> Num (Some sid, "1")) ;; (* times *) Hashtbl.add symbol_table "cic:/Coq/Init/Peano/mult.con" @@ -274,9 +303,10 @@ Hashtbl.add symbol_table "cic:/Coq/Reals/Rdefinitions/Rdiv.con" let string_of_sort = function - Cic.Prop -> "Prop" - | Cic.Set -> "Set" - | Cic.Type -> "Type" + Cic.Prop -> "Prop" + | Cic.Set -> "Set" + | Cic.Type -> "Type" + | Cic.CProp -> "Type" ;; let get_constructors uri i = @@ -354,7 +384,7 @@ let acic2cexpr ids_to_inner_sorts t = (try (let f = Hashtbl.find symbol_table uri_str in f aid sid tl acic2cexpr) - with notfound -> + with Not_found -> Appl (Some aid, Symbol (Some sid,UriManager.name_of_uri uri, make_subst subst, Some uri_str)::List.map acic2cexpr tl)) | C.AAppl (aid,C.AMutInd (sid,uri,i,subst)::tl) -> @@ -372,14 +402,19 @@ let acic2cexpr ids_to_inner_sorts t = (try (let f = Hashtbl.find symbol_table puri_str in f aid sid tl acic2cexpr) - with notfound -> + with Not_found -> Appl (Some aid, Symbol (Some sid, name, make_subst subst, Some uri_str)::List.map acic2cexpr tl)) | C.AAppl (id,li) -> Appl (Some id, List.map acic2cexpr li) | C.AConst (id,uri,subst) -> - Symbol (Some id, UriManager.name_of_uri uri, - make_subst subst, Some (UriManager.string_of_uri uri)) + let uri_str = UriManager.string_of_uri uri in + (try + let f = Hashtbl.find symbol_table uri_str in + f "dummy" id [] acic2cexpr + with Not_found -> + Symbol (Some id, UriManager.name_of_uri uri, + make_subst subst, Some (UriManager.string_of_uri uri))) | C.AMutInd (id,uri,i,subst) -> let inductive_types = (match CicEnvironment.get_obj uri with