| author | blanchet | 
| Wed, 18 Apr 2012 22:39:35 +0200 | |
| changeset 47558 | 55b42f9af99d | 
| parent 47548 | 60849d8c457d | 
| child 47687 | bfbd2d0bb348 | 
| permissions | -rw-r--r-- | 
| 47366 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 1 | (* Title: HOL/TPTP/TPTP_Parser_Example.thy | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 2 | Author: Nik Sultana, Cambridge University Computer Laboratory | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 3 | |
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 4 | Example of importing a TPTP problem and trying to prove it in Isabelle/HOL. | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 5 | *) | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 6 | |
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 7 | theory TPTP_Parser_Example | 
| 47518 | 8 | imports TPTP_Parser TPTP_Interpret | 
| 47366 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 9 | uses "~~/src/HOL/ex/sledgehammer_tactics.ML" | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 10 | begin | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 11 | |
| 47558 
55b42f9af99d
phase out "$TPTP_PROBLEMS_PATH"; prefer "$TPTP" for consistency with CASC setup
 blanchet parents: 
47548diff
changeset | 12 | import_tptp "$TPTP/Problems/ALG/ALG001^5.p" | 
| 47366 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 13 | |
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 14 | ML {*
 | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 15 | val an_fmlas = | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 16 |   TPTP_Interpret.get_manifests @{theory}
 | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 17 | |> hd (*FIXME use named lookup*) | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 18 | |> #2 (*get problem contents*) | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 19 | |> #3 (*get formulas*) | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 20 | *} | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 21 | |
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 22 | (*Display nicely.*) | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 23 | ML {*
 | 
| 47548 | 24 | List.app (fn (n, role, fmla, _) => | 
| 47366 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 25 | Pretty.writeln | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 26 |     (Pretty.block [Pretty.str ("\"" ^ n ^ "\"" ^ "(" ^
 | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 27 |       TPTP_Syntax.role_to_string role  ^ "): "), Syntax.pretty_term @{context} fmla])
 | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 28 | ) (rev an_fmlas) | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 29 | *} | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 30 | |
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 31 | ML {*
 | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 32 | (*Extract the (name, term) pairs of formulas having roles belonging to a | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 33 | user-supplied set*) | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 34 | fun extract_terms roles : TPTP_Interpret.tptp_formula_meaning list -> | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 35 | (string * term) list = | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 36 | let | 
| 47548 | 37 | fun role_predicate (_, role, _, _) = | 
| 47366 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 38 | fold (fn r1 => fn b => role = r1 orelse b) roles false | 
| 47548 | 39 | in filter role_predicate #> map (fn (n, _, t, _) => (n, t)) end | 
| 47366 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 40 | *} | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 41 | |
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 42 | ML {*
 | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 43 | (*Use a given tactic on a goal*) | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 44 | fun prove_conjectures tactic ctxt an_fmlas = | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 45 | let | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 46 | val assumptions = | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 47 | extract_terms | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 48 | [TPTP_Syntax.Role_Definition (*FIXME include axioms, etc here*)] | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 49 | an_fmlas | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 50 | |> map snd | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 51 | val goals = extract_terms [TPTP_Syntax.Role_Conjecture] an_fmlas | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 52 | fun driver (n, goal) = | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 53 | (n, Goal.prove ctxt [] assumptions goal (fn _ => tactic ctxt)) | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 54 | in map driver goals end | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 55 | |
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 56 | val auto_prove = prove_conjectures auto_tac | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 57 | val sh_prove = prove_conjectures (fn ctxt => | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 58 | Sledgehammer_Tactics.sledgehammer_with_metis_tac ctxt [] | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 59 | (*FIXME use relevance_override*) | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 60 |   {add = [], del = [], only = false} 1)
 | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 61 | *} | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 62 | |
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 63 | ML "auto_prove @{context} an_fmlas"
 | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 64 | |
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 65 | sledgehammer_params [provers = z3_tptp leo2, debug] | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 66 | ML "sh_prove @{context} an_fmlas"
 | 
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 67 | |
| 
f5a304ca037e
improved import_tptp to use standard TPTP directory structure; extended the TPTP testing theory to include an example of using the import_tptp command;
 sultana parents: diff
changeset | 68 | end |