(* Copyright (C) 2003-2005, HELM Team. * * This file is part of HELM, an Hypertextual, Electronic * Library of Mathematics, developed at the Computer Science * Department, University of Bologna, Italy. * * HELM is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * HELM is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HELM; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * For details, see the HELM World-Wide-Web page, * http://cs.unibo.it/helm/. *) module H = HExtlib module C = Content module G = GrafiteAst module N = CicNotationPt (* grafite ast constructors *************************************************) let floc = H.dummy_floc let mk_note str = G.Comment (floc, G.Note (floc, str)) let mk_theorem name t = let obj = N.Theorem (`Theorem, name, t, None) in G.Executable (floc, G.Command (floc, G.Obj (floc, obj))) let mk_tactic tactic = let sep = G.Dot floc in G.Executable (floc, G.Tactical (floc, G.Tactic (floc, tactic), Some sep)) let mk_intros xi ids = let tactic = G.Intros (floc, xi, ids) in mk_tactic tactic let mk_exact t = let tactic = G.Exact (floc, t) in mk_tactic tactic (* internal functions *******************************************************) let mk_intros_arg = function | `Declaration {C.dec_name = Some name} | `Hypothesis {C.dec_name = Some name} | `Definition {C.def_name = Some name} -> name | _ -> assert false let mk_intros_args pc = List.map mk_intros_arg pc let rec mk_proof p = let cmethod = p.C.proof_conclude.C.conclude_method in let cargs = p.C.proof_conclude.C.conclude_args in match cmethod, cargs with | "Intros+LetTac", [C.ArgProof q] -> let names = mk_intros_args q.C.proof_context in let num = List.length names in let text = String.concat " " names in mk_intros (Some num) [] :: mk_note text :: mk_proof q | _ -> [mk_note (Printf.sprintf "%s %u" cmethod (List.length cargs))] (* interface functions ******************************************************) let content2procedural ~ids_to_inner_sorts prefix (_, params, xmenv, obj) = if List.length params > 0 || xmenv <> None then assert false; match obj with | `Def (C.Const, t, `Proof ({C.proof_name = Some name} as p)) -> mk_theorem name t :: mk_proof p | _ -> assert false