14350
|
1 |
(* Title: HOL/Tools/refute_isar.ML
|
|
2 |
Author: Tjark Weber
|
22092
|
3 |
Copyright 2003-2007
|
14350
|
4 |
|
32855
|
5 |
Outer syntax commands 'refute' and 'refute_params'.
|
14350
|
6 |
*)
|
|
7 |
|
32855
|
8 |
structure Refute_Isar: sig end =
|
14350
|
9 |
struct
|
|
10 |
|
32855
|
11 |
(* argument parsing *)
|
14350
|
12 |
|
32855
|
13 |
(*optional list of arguments of the form [name1=value1, name2=value2, ...]*)
|
14350
|
14 |
|
32855
|
15 |
val scan_parm = OuterParse.name -- (OuterParse.$$$ "=" |-- OuterParse.name);
|
14350
|
16 |
|
32855
|
17 |
val scan_parms = Scan.optional
|
|
18 |
(OuterParse.$$$ "[" |-- OuterParse.list scan_parm --| OuterParse.$$$ "]") [];
|
14350
|
19 |
|
|
20 |
|
32855
|
21 |
(* 'refute' command *)
|
14350
|
22 |
|
32855
|
23 |
val _ =
|
|
24 |
OuterSyntax.improper_command "refute"
|
|
25 |
"try to find a model that refutes a given subgoal" OuterKeyword.diag
|
|
26 |
(scan_parms -- Scan.optional OuterParse.nat 1 >> (fn (parms, subgoal) =>
|
|
27 |
Toplevel.keep (fn state =>
|
|
28 |
let
|
|
29 |
val thy = Toplevel.theory_of state
|
|
30 |
val st = (snd o snd) (Proof.get_goal (Toplevel.proof_of state))
|
|
31 |
in
|
|
32 |
Refute.refute_subgoal thy parms st (subgoal - 1)
|
|
33 |
end)));
|
14350
|
34 |
|
|
35 |
|
32855
|
36 |
(* 'refute_params' command *)
|
14350
|
37 |
|
32855
|
38 |
val _ =
|
|
39 |
OuterSyntax.command "refute_params"
|
|
40 |
"show/store default parameters for the 'refute' command" OuterKeyword.thy_decl
|
|
41 |
(scan_parms >> (fn parms =>
|
|
42 |
Toplevel.theory (fn thy =>
|
|
43 |
let
|
|
44 |
val thy' = fold Refute.set_default_param parms thy
|
|
45 |
val output =
|
|
46 |
(case Refute.get_default_params thy' of
|
|
47 |
[] => "none"
|
|
48 |
| new_defaults => cat_lines (map (fn (name, value) => name ^ "=" ^ value) new_defaults))
|
|
49 |
val _ = writeln ("Default parameters for 'refute':\n" ^ output);
|
|
50 |
in thy' end)))
|
14350
|
51 |
|
|
52 |
end;
|
|
53 |
|