X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fcic_omdoc%2Fcic2content.ml;h=0295daac326659968bb6d8637ad9956583e90afa;hb=1c7fb836e2af4f2f3d18afd0396701f2094265ff;hp=82f0005f5eaf08af13187c769ba2323da61205e0;hpb=9e781c8957ff049e7bba65e1d611e5f007b02fb5;p=helm.git diff --git a/helm/ocaml/cic_omdoc/cic2content.ml b/helm/ocaml/cic_omdoc/cic2content.ml index 82f0005f5..0295daac3 100644 --- a/helm/ocaml/cic_omdoc/cic2content.ml +++ b/helm/ocaml/cic_omdoc/cic2content.ml @@ -99,14 +99,21 @@ let get_id = | C.ACoFix (id,_,_) -> id ;; -let test_for_lifting ~ids_to_inner_types = +let test_for_lifting ~ids_to_inner_types ~ids_to_inner_sorts= let module C = Cic in let module C2A = Cic2acic in (* atomic terms are never lifted, according to my policy *) function C.ARel (id,_,_,_) -> false - | C.AVar (id,_,_) -> false - | C.AMeta (id,_,_) -> false + | C.AVar (id,_,_) -> + (try + ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized; + true; + with Not_found -> false) + | C.AMeta (id,_,_) -> + (try + Hashtbl.find ids_to_inner_sorts id = "Prop" + with Not_found -> assert false) | C.ASort (id,_) -> false | C.AImplicit _ -> raise NotImplemented | C.AProd (id,_,_,_) -> false @@ -114,55 +121,56 @@ let test_for_lifting ~ids_to_inner_types = (try ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized; true; - with notfound -> false) + with Not_found -> false) | C.ALambda (id,_,_,_) -> (try ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized; true; - with notfound -> false) + with Not_found -> false) | C.ALetIn (id,_,_,_) -> (try ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized; true; - with notfound -> false) + with Not_found -> false) | C.AAppl (id,_) -> (try ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized; true; - with notfound -> false) + with Not_found -> false) | C.AConst (id,_,_) -> (try ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized; true; - with notfound -> false) + with Not_found -> false) | C.AMutInd (id,_,_,_) -> false | C.AMutConstruct (id,_,_,_,_) -> (try ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized; true; - with notfound -> false) + with Not_found -> false) (* oppure: false *) | C.AMutCase (id,_,_,_,_,_) -> (try ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized; true; - with notfound -> false) + with Not_found -> false) | C.AFix (id,_,_) -> (try ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized; true; - with notfound -> false) + with Not_found -> false) | C.ACoFix (id,_,_) -> (try ignore (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized; true; - with notfound -> false) + with Not_found -> false) ;; +(* let build_args seed l subproofs ~ids_to_inner_types ~ids_to_inner_sorts = let module C = Cic in let module K = Content in - let rec aux l subrpoofs = + let rec aux l subproofs = match l with [] -> [] | t::l1 -> @@ -184,7 +192,7 @@ let build_args seed l subproofs ~ids_to_inner_types ~ids_to_inner_sorts = C.ARel (idr,idref,n,b) -> let sort = (try Hashtbl.find ids_to_inner_sorts idr - with notfound -> "Type") in + with Not_found -> "Type") in if sort ="Prop" then K.Premise { K.premise_id = gen_id seed; @@ -197,6 +205,7 @@ let build_args seed l subproofs ~ids_to_inner_types ~ids_to_inner_sorts = hd::(aux l1 subproofs) in aux l subproofs ;; +*) (* transform a proof p into a proof list, concatenating the last conclude element to the apply_context list, in case context is @@ -209,7 +218,6 @@ let flat seed p = else let p1 = { p with - K.proof_id = gen_id seed; K.proof_context = []; K.proof_apply_context = [] } in @@ -220,8 +228,9 @@ let flat seed p = let rec serialize seed = function - [] -> [] - | p::tl -> (flat seed p)@(serialize seed tl);; + [] -> [] + | a::l -> (flat seed a)@(serialize seed l) +;; (* top_down = true if the term is a LAMBDA or a decl *) let generate_conversion seed top_down id inner_proof ~ids_to_inner_types = @@ -234,7 +243,7 @@ let generate_conversion seed top_down id inner_proof ~ids_to_inner_types = None -> inner_proof | Some expty -> if inner_proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then - { K.proof_name = None ; + { K.proof_name = inner_proof.K.proof_name; K.proof_id = gen_id seed; K.proof_context = [] ; K.proof_apply_context = []; @@ -242,15 +251,16 @@ let generate_conversion seed top_down id inner_proof ~ids_to_inner_types = { K.conclude_id = gen_id seed; K.conclude_aref = id; K.conclude_method = "TD_Conversion"; - K.conclude_args = [K.ArgProof inner_proof]; + K.conclude_args = + [K.ArgProof {inner_proof with K.proof_name = None}]; K.conclude_conclusion = Some expty }; } else - { K.proof_name = None ; + { K.proof_name = inner_proof.K.proof_name; K.proof_id = gen_id seed; K.proof_context = [] ; - K.proof_apply_context = [inner_proof]; + K.proof_apply_context = [{inner_proof with K.proof_name = None}]; K.proof_conclude = { K.conclude_id = gen_id seed; K.conclude_aref = id; @@ -282,7 +292,7 @@ let generate_exact seed t id name ~ids_to_inner_types = K.conclude_args = [K.Term t]; K.conclude_conclusion = try Some (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized - with notfound -> None + with Not_found -> None }; } ;; @@ -303,7 +313,7 @@ let generate_intros_let_tac seed id n s is_intro inner_proof name ~ids_to_inner_ K.conclude_conclusion = try Some (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized - with notfound -> + with Not_found -> (match inner_proof.K.proof_conclude.K.conclude_conclusion with None -> None | Some t -> @@ -315,44 +325,147 @@ let generate_intros_let_tac seed id n s is_intro inner_proof name ~ids_to_inner_ let build_decl_item seed id n s ~ids_to_inner_sorts = let module K = Content in - let sort = Hashtbl.find ids_to_inner_sorts (Cic2acic.source_id_of_id id) in - if sort = "Prop" then - `Hypothesis - { K.dec_name = name_of n; - K.dec_id = gen_id seed; - K.dec_inductive = false; - K.dec_aref = id; - K.dec_type = s - } - else - `Declaration - { K.dec_name = name_of n; - K.dec_id = gen_id seed; - K.dec_inductive = false; - K.dec_aref = id; - K.dec_type = s - } + try + let sort = Hashtbl.find ids_to_inner_sorts (Cic2acic.source_id_of_id id) in + if sort = "Prop" then + `Hypothesis + { K.dec_name = name_of n; + K.dec_id = gen_id seed; + K.dec_inductive = false; + K.dec_aref = id; + K.dec_type = s + } + else + `Declaration + { K.dec_name = name_of n; + K.dec_id = gen_id seed; + K.dec_inductive = false; + K.dec_aref = id; + K.dec_type = s + } + with + Not_found -> assert false ;; -let rec build_def_item seed id n t ~ids_to_inner_sorts ~ids_to_inner_types = +let rec build_subproofs_and_args seed l ~ids_to_inner_types ~ids_to_inner_sorts = + let module C = Cic in + let module K = Content in + let rec aux = + function + [] -> [],[] + | t::l1 -> + let subproofs,args = aux l1 in + if (test_for_lifting t ~ids_to_inner_types ~ids_to_inner_sorts) then + let new_subproof = + acic2content + seed ~name:"H" ~ids_to_inner_types ~ids_to_inner_sorts t in + let new_arg = + K.Premise + { K.premise_id = gen_id seed; + K.premise_xref = new_subproof.K.proof_id; + K.premise_binder = new_subproof.K.proof_name; + K.premise_n = None + } in + new_subproof::subproofs,new_arg::args + else + let hd = + (match t with + C.ARel (idr,idref,n,b) -> + let sort = + (try Hashtbl.find ids_to_inner_sorts idr + with Not_found -> "Type") in + if sort ="Prop" then + K.Premise + { K.premise_id = gen_id seed; + K.premise_xref = idr; + K.premise_binder = Some b; + K.premise_n = Some n + } + else (K.Term t) + | C.AConst(id,uri,[]) -> + let sort = + (try Hashtbl.find ids_to_inner_sorts id + with Not_found -> "Type") in + if sort ="Prop" then + K.Lemma + { K.lemma_id = gen_id seed; + K.lemma_name = UriManager.name_of_uri uri; + K.lemma_uri = UriManager.string_of_uri uri + } + else (K.Term t) + | C.AMutConstruct(id,uri,tyno,consno,[]) -> + let sort = + (try Hashtbl.find ids_to_inner_sorts id + with Not_found -> "Type") in + if sort ="Prop" then + let inductive_types = + (match CicEnvironment.get_obj uri with + Cic.Constant _ -> assert false + | Cic.Variable _ -> assert false + | Cic.CurrentProof _ -> assert false + | Cic.InductiveDefinition (l,_,_) -> l + ) in + let (_,_,_,constructors) = + List.nth inductive_types tyno in + let name,_ = List.nth constructors (consno - 1) in + K.Lemma + { K.lemma_id = gen_id seed; + K.lemma_name = name; + K.lemma_uri = + UriManager.string_of_uri uri ^ "#xpointer(1/" ^ + string_of_int (tyno+1) ^ "/" ^ string_of_int consno ^ + ")" + } + else (K.Term t) + | _ -> (K.Term t)) in + subproofs,hd::args + in + match (aux l) with + [p],args -> + [{p with K.proof_name = None}], + List.map + (function + K.Premise prem when prem.K.premise_xref = p.K.proof_id -> + K.Premise {prem with K.premise_binder = None} + | i -> i) args + | p,a as c -> c + +and + +build_def_item seed id n t ~ids_to_inner_sorts ~ids_to_inner_types = let module K = Content in - let sort = Hashtbl.find ids_to_inner_sorts id in - if sort = "Prop" then - `Proof (acic2content seed ~name:(name_of n) ~ids_to_inner_sorts ~ids_to_inner_types t) - else - `Definition - { K.def_name = name_of n; - K.def_id = gen_id seed; - K.def_aref = id; - K.def_term = t - } + try + let sort = Hashtbl.find ids_to_inner_sorts id in + (match name_of n with + Some "w" -> prerr_endline ("build_def: " ^ sort ); + | _ -> ()); + if sort = "Prop" then + (prerr_endline ("entro"); + let p = + (acic2content seed ?name:(name_of n) ~ids_to_inner_sorts ~ids_to_inner_types t) + in + (match p.K.proof_name with + Some "w" -> prerr_endline ("TUTTO BENE:"); + | Some s -> prerr_endline ("mi chiamo " ^ s); + | _ -> prerr_endline ("ho perso il nome");); + prerr_endline ("esco"); `Proof p;) + else + (prerr_endline ("siamo qui???"); + `Definition + { K.def_name = name_of n; + K.def_id = gen_id seed; + K.def_aref = id; + K.def_term = t + }) + with + Not_found -> assert false (* the following function must be called with an object of sort Prop. For debugging purposes this is tested again, possibly raising an Not_a_proof exception *) -and acic2content seed ?(name = None) ~ids_to_inner_sorts ~ids_to_inner_types t = - let rec aux ?(name = None) t = +and acic2content seed ?name ~ids_to_inner_sorts ~ids_to_inner_types t = + let rec aux ?name t = let module C = Cic in let module K = Content in let module C2A = Cic2acic in @@ -380,7 +493,7 @@ and acic2content seed ?(name = None) ~ids_to_inner_sorts ~ids_to_inner_types t = | C.ALambda (id,n,s,t) -> let sort = Hashtbl.find ids_to_inner_sorts id in if sort = "Prop" then - let proof = aux t ~name:None in + let proof = aux t in let proof' = if proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then match proof.K.proof_conclude.K.conclude_args with @@ -399,7 +512,7 @@ and acic2content seed ?(name = None) ~ids_to_inner_sorts ~ids_to_inner_types t = else raise Not_a_proof | C.ALetIn (id,n,s,t) -> let sort = Hashtbl.find ids_to_inner_sorts id in - if sort = "Prop" then + if sort = "Prop" then let proof = aux t in let proof' = if proof.K.proof_conclude.K.conclude_method = "Intros+LetTac" then @@ -409,7 +522,7 @@ and acic2content seed ?(name = None) ~ids_to_inner_sorts ~ids_to_inner_types t = else proof in let proof'' = { proof' with - K.proof_name = name; + K.proof_name = None; K.proof_context = ((build_def_item seed id n s ids_to_inner_sorts ids_to_inner_types):> Cic.annterm K.in_proof_context_element) @@ -420,19 +533,23 @@ and acic2content seed ?(name = None) ~ids_to_inner_sorts ~ids_to_inner_types t = else raise Not_a_proof | C.AAppl (id,li) -> (try rewrite - seed name id li ids_to_inner_types ids_to_inner_sorts + seed name id li ~ids_to_inner_types ~ids_to_inner_sorts with NotApplicable -> try inductive - seed name id li ids_to_inner_types ids_to_inner_sorts + seed name id li ~ids_to_inner_types ~ids_to_inner_sorts with NotApplicable -> + let subproofs, args = + build_subproofs_and_args + seed li ~ids_to_inner_types ~ids_to_inner_sorts in +(* let args_to_lift = List.filter (test_for_lifting ~ids_to_inner_types) li in let subproofs = match args_to_lift with [_] -> List.map aux args_to_lift - | _ -> List.map (aux ~name:(Some "H")) args_to_lift in + | _ -> List.map (aux ~name:"H") args_to_lift in let args = build_args seed li subproofs - ~ids_to_inner_types ~ids_to_inner_sorts in + ~ids_to_inner_types ~ids_to_inner_sorts in *) { K.proof_name = name; K.proof_id = gen_id seed; K.proof_context = []; @@ -445,7 +562,7 @@ and acic2content seed ?(name = None) ~ids_to_inner_sorts ~ids_to_inner_types t = K.conclude_conclusion = try Some (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized - with notfound -> None + with Not_found -> None }; }) | C.AConst (id,uri,exp_named_subst) as t -> @@ -460,76 +577,51 @@ and acic2content seed ?(name = None) ~ids_to_inner_sorts ~ids_to_inner_types t = generate_exact seed t id name ~ids_to_inner_types else raise Not_a_proof | C.AMutCase (id,uri,typeno,ty,te,patterns) -> + let inductive_types = + (match CicEnvironment.get_obj uri with + Cic.Constant _ -> assert false + | Cic.Variable _ -> assert false + | Cic.CurrentProof _ -> assert false + | Cic.InductiveDefinition (l,_,_) -> l + ) in + let (_,_,_,constructors) = List.nth inductive_types typeno in let teid = get_id te in - let pp = List.map (function p -> (K.ArgProof (aux p))) patterns in - (match - (try Some (Hashtbl.find ids_to_inner_types teid).C2A.annsynthesized - with notfound -> None) - with - Some tety -> (* we must lift up the argument *) - let p = (aux te) in - { K.proof_name = Some "name"; - K.proof_id = gen_id seed; - K.proof_context = []; - K.proof_apply_context = flat seed p; - K.proof_conclude = - { K.conclude_id = gen_id seed; - K.conclude_aref = id; - K.conclude_method = "Case"; - K.conclude_args = (K.Term ty)::(K.Term te)::pp; - K.conclude_conclusion = - try Some - (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized - with notfound -> None - } - } - | None -> - { K.proof_name = name; - K.proof_id = gen_id seed; - K.proof_context = []; - K.proof_apply_context = []; - K.proof_conclude = - { K.conclude_id = gen_id seed; - K.conclude_aref = id; - K.conclude_method = "Case"; - K.conclude_args = (K.Term ty)::(K.Term te)::pp; - K.conclude_conclusion = - try Some - (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized - with notfound -> None - } - } - ) - | C.AFix (id, no, [(id1,n,_,ty,bo)]) -> - let proof = (aux bo) in (* must be recursive !! *) - { K.proof_name = name; - K.proof_id = gen_id seed; - K.proof_context = [`Proof proof]; - K.proof_apply_context = []; - K.proof_conclude = - { K.conclude_id = gen_id seed; - K.conclude_aref = id; - K.conclude_method = "Exact"; - K.conclude_args = - [ K.Premise - { K.premise_id = gen_id seed; - K.premise_xref = proof.K.proof_id; - K.premise_binder = proof.K.proof_name; - K.premise_n = Some 1; - } - ]; - K.conclude_conclusion = - try Some - (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized - with notfound -> None - } + let pp = List.map2 + (fun p (name,_) -> (K.ArgProof (aux ~name p))) + patterns constructors in + let context,term = + (match + build_subproofs_and_args + seed ~ids_to_inner_types ~ids_to_inner_sorts [te] + with + l,[t] -> l,t + | _ -> assert false) in + { K.proof_name = name; + K.proof_id = gen_id seed; + K.proof_context = []; + K.proof_apply_context = serialize seed context; + K.proof_conclude = + { K.conclude_id = gen_id seed; + K.conclude_aref = id; + K.conclude_method = "Case"; + K.conclude_args = + (K.Aux (UriManager.string_of_uri uri)):: + (K.Aux (string_of_int typeno))::(K.Term ty)::term::pp; + K.conclude_conclusion = + try Some + (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized + with Not_found -> None + } } | C.AFix (id, no, funs) -> let proofs = - List.map (function (id1,n,_,ty,bo) -> (`Proof (aux bo))) funs in + List.map + (function (_,name,_,_,bo) -> `Proof (aux ~name bo)) funs in + let decreasing_args = + List.map (function (_,_,n,_,_) -> n) funs in let jo = { K.joint_id = gen_id seed; - K.joint_kind = `Recursive; + K.joint_kind = `Recursive decreasing_args; K.joint_defs = proofs } in @@ -552,39 +644,16 @@ and acic2content seed ?(name = None) ~ids_to_inner_sorts ~ids_to_inner_types t = K.conclude_conclusion = try Some (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized - with notfound -> None - } - } - | C.ACoFix (id,no,[(id1,n,ty,bo)]) -> - let proof = (aux bo) in (* must be recursive !! *) - { K.proof_name = name; - K.proof_id = gen_id seed; - K.proof_context = [`Proof proof]; - K.proof_apply_context = []; - K.proof_conclude = - { K.conclude_id = gen_id seed; - K.conclude_aref = id; - K.conclude_method = "Exact"; - K.conclude_args = - [ K.Premise - { K.premise_id = gen_id seed; - K.premise_xref = proof.K.proof_id; - K.premise_binder = proof.K.proof_name; - K.premise_n = Some 1; - } - ]; - K.conclude_conclusion = - try Some - (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized - with notfound -> None + with Not_found -> None } } | C.ACoFix (id,no,funs) -> let proofs = - List.map (function (id1,n,ty,bo) -> (`Proof (aux bo))) funs in + List.map + (function (_,name,_,bo) -> `Proof (aux ~name bo)) funs in let jo = { K.joint_id = gen_id seed; - K.joint_kind = `Recursive; + K.joint_kind = `CoRecursive; K.joint_defs = proofs } in @@ -607,16 +676,16 @@ and acic2content seed ?(name = None) ~ids_to_inner_sorts ~ids_to_inner_types t = K.conclude_conclusion = try Some (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized - with notfound -> None + with Not_found -> None }; } in let id = get_id t in generate_conversion seed false id t1 ~ids_to_inner_types -in aux ~name:name t +in aux ?name t -and inductive seed name id li ids_to_inner_types ids_to_inner_sorts = - let aux ?(name = None) = acic2content seed ~name:None ~ids_to_inner_types ~ids_to_inner_sorts in +and inductive seed name id li ~ids_to_inner_types ~ids_to_inner_sorts = + let aux ?name = acic2content seed ~ids_to_inner_types ~ids_to_inner_sorts in let module C2A = Cic2acic in let module K = Content in let module C = Cic in @@ -629,6 +698,11 @@ and inductive seed name id li ids_to_inner_types ids_to_inner_sorts = with Not_found -> -1) in if n<0 then raise NotApplicable else + let method_name = + if (uri_str = "cic:/Coq/Init/Logic_Type/exT_ind.con" or + uri_str = "cic:/Coq/Init/Logic/ex_ind.con") then "Exists" + else if uri_str = "cic:/Coq/Init/Logic/and_ind.con" then "AndInd" + else "ByInduction" in let prefix = String.sub uri_str 0 n in let ind_str = (prefix ^ ".ind") in let ind_uri = UriManager.uri_of_string ind_str in @@ -643,7 +717,10 @@ and inductive seed name id li ids_to_inner_types ids_to_inner_sorts = if n = 0 then ([],l) else let p,a = split (n-1) (List.tl l) in ((List.hd l::p),a) in - let params_and_IP,tail_args = split (noparams+1) args in + let params_and_IP,tail_args = split (noparams+1) args in + if method_name = "Exists" then + (prerr_endline ("+++++args++++:" ^ string_of_int (List.length args)); + prerr_endline ("+++++tail++++:" ^ string_of_int (List.length tail_args))); let constructors = (match inductive_types with [(_,_,_,l)] -> l @@ -658,25 +735,9 @@ and inductive seed name id li ids_to_inner_types ids_to_inner_sorts = let no_constructors= List.length constructors in let args_for_cases, other_args = split no_constructors tail_args in - let args_to_lift = - List.filter (test_for_lifting ~ids_to_inner_types) other_args in - let subproofs = - match args_to_lift with - [_] -> List.map aux args_to_lift - | _ -> List.map (aux ~name:(Some "H")) args_to_lift in - prerr_endline "****** end subproofs *******"; flush stderr; - let other_method_args = - build_args seed other_args subproofs + let subproofs,other_method_args = + build_subproofs_and_args seed other_args ~ids_to_inner_types ~ids_to_inner_sorts in -(* - let rparams,inductive_arg = - let rec aux = - function - [] -> assert false - | [ia] -> [],ia - | a::tl -> let (p,ia) = aux tl in (a::p,ia) in - aux other_method_args in -*) prerr_endline "****** end other *******"; flush stderr; let method_args= let rec build_method_args = @@ -715,7 +776,7 @@ and inductive seed name id li ids_to_inner_types ids_to_inner_sorts = ( prerr_endline ("no inductive:" ^ (UriManager.string_of_uri ind_uri) ^ (CicPp.ppterm s)); flush stderr; let (context,body) = bc (t,t1) in (ce::context,body)) - | _ , t -> ([],aux t ~name:None) in + | _ , t -> ([],aux t) in bc (ty,arg) in K.ArgProof { bo with @@ -726,28 +787,28 @@ and inductive seed name id li ids_to_inner_types ids_to_inner_sorts = hdarg::(build_method_args (tlc,tla)) | _ -> assert false in build_method_args (constructors1,args_for_cases) in - { K.proof_name = None; + { K.proof_name = name; K.proof_id = gen_id seed; K.proof_context = []; - K.proof_apply_context = subproofs; + K.proof_apply_context = serialize seed subproofs; K.proof_conclude = { K.conclude_id = gen_id seed; K.conclude_aref = id; - K.conclude_method = "ByInduction"; + K.conclude_method = method_name; K.conclude_args = - K.Aux no_constructors + K.Aux (string_of_int no_constructors) ::K.Term (C.AAppl id ((C.AConst(idc,uri,exp_named_subst))::params_and_IP)) ::method_args@other_method_args; K.conclude_conclusion = try Some (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized - with notfound -> None + with Not_found -> None } } | _ -> raise NotApplicable -and rewrite seed name id li ids_to_inner_types ids_to_inner_sorts = - let aux ?(name = None) = acic2content seed ~name:None ~ids_to_inner_types ~ids_to_inner_sorts in +and rewrite seed name id li ~ids_to_inner_types ~ids_to_inner_sorts = + let aux ?name = acic2content seed ~ids_to_inner_types ~ids_to_inner_sorts in let module C2A = Cic2acic in let module K = Content in let module C = Cic in @@ -756,19 +817,19 @@ and rewrite seed name id li ids_to_inner_types ids_to_inner_sorts = let uri_str = UriManager.string_of_uri uri in if uri_str = "cic:/Coq/Init/Logic/eq_ind.con" or uri_str = "cic:/Coq/Init/Logic/eq_ind_r.con" then - let subproof = aux (List.nth args 3) in + let subproofs,arg = + (match + build_subproofs_and_args + seed ~ids_to_inner_types ~ids_to_inner_sorts [List.nth args 3] + with + l,[p] -> l,p + | _,_ -> assert false) in let method_args = let rec ma_aux n = function [] -> [] | a::tl -> let hd = - if n = 0 then - K.Premise - { K.premise_id = gen_id seed; - K.premise_xref = subproof.K.proof_id; - K.premise_binder = None; - K.premise_n = None - } + if n = 0 then arg else let aid = get_id a in let asort = (try (Hashtbl.find ids_to_inner_sorts aid) @@ -778,10 +839,10 @@ and rewrite seed name id li ids_to_inner_types ids_to_inner_sorts = else K.Term a in hd::(ma_aux (n-1) tl) in (ma_aux 3 args) in - { K.proof_name = None; + { K.proof_name = name; K.proof_id = gen_id seed; K.proof_context = []; - K.proof_apply_context = [subproof]; + K.proof_apply_context = serialize seed subproofs; K.proof_conclude = { K.conclude_id = gen_id seed; K.conclude_aref = id; @@ -791,7 +852,7 @@ and rewrite seed name id li ids_to_inner_types ids_to_inner_sorts = K.conclude_conclusion = try Some (Hashtbl.find ids_to_inner_types id).C2A.annsynthesized - with notfound -> None + with Not_found -> None } } else raise NotApplicable @@ -801,6 +862,7 @@ and rewrite seed name id li ids_to_inner_types ids_to_inner_sorts = let map_conjectures seed ~ids_to_inner_sorts ~ids_to_inner_types (id,n,context,ty) = + let module K = Content in let context' = List.map (function @@ -808,13 +870,26 @@ let map_conjectures | (id,Some (name,Cic.ADecl t)) -> id, Some - (build_decl_item seed (get_id t) name t - ~ids_to_inner_sorts) + (* We should call build_decl_item, but we have not computed *) + (* the inner-types ==> we always produce a declaration *) + (`Declaration + { K.dec_name = name_of name; + K.dec_id = gen_id seed; + K.dec_inductive = false; + K.dec_aref = get_id t; + K.dec_type = t + }) | (id,Some (name,Cic.ADef t)) -> id, Some - (build_def_item seed (get_id t) name t - ~ids_to_inner_sorts ~ids_to_inner_types) + (* We should call build_def_item, but we have not computed *) + (* the inner-types ==> we always produce a declaration *) + (`Definition + { K.def_name = name_of name; + K.def_id = gen_id seed; + K.def_aref = get_id t; + K.def_term = t + }) ) context in (id,n,context',ty)