23311
|
1 |
(* Title: HOL/Tools/Presburger/cooper_data.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Amine Chaieb, TU Muenchen
|
|
4 |
*)
|
|
5 |
|
|
6 |
signature COOPER_DATA =
|
|
7 |
sig
|
|
8 |
type entry
|
|
9 |
val get: Proof.context -> entry
|
|
10 |
val del: term list -> attribute
|
|
11 |
val add: term list -> attribute
|
|
12 |
val setup: theory -> theory
|
|
13 |
end;
|
|
14 |
|
|
15 |
structure Cooper_Data : COOPER_DATA =
|
|
16 |
struct
|
|
17 |
|
|
18 |
type entry = simpset* (term list);
|
|
19 |
val start_ss = HOL_ss addsimps @{thms "Groebner_Basis.comp_arith"}
|
|
20 |
addcongs [if_weak_cong, @{thm "let_weak_cong"}];
|
|
21 |
val allowed_consts =
|
|
22 |
[@{term "op + :: int => _"}, @{term "op + :: nat => _"},
|
|
23 |
@{term "op - :: int => _"}, @{term "op - :: nat => _"},
|
|
24 |
@{term "op * :: int => _"}, @{term "op * :: nat => _"},
|
|
25 |
@{term "op div :: int => _"}, @{term "op div :: nat => _"},
|
|
26 |
@{term "op mod :: int => _"}, @{term "op mod :: nat => _"},
|
|
27 |
@{term "Numeral.Bit"},
|
|
28 |
@{term "op &"}, @{term "op |"}, @{term "op -->"},
|
|
29 |
@{term "op = :: int => _"}, @{term "op = :: nat => _"}, @{term "op = :: bool => _"},
|
|
30 |
@{term "op < :: int => _"}, @{term "op < :: nat => _"},
|
|
31 |
@{term "op <= :: int => _"}, @{term "op <= :: nat => _"},
|
|
32 |
@{term "op dvd :: int => _"}, @{term "op dvd :: nat => _"},
|
|
33 |
@{term "abs :: int => _"}, @{term "abs :: nat => _"},
|
|
34 |
@{term "max :: int => _"}, @{term "max :: nat => _"},
|
|
35 |
@{term "min :: int => _"}, @{term "min :: nat => _"},
|
|
36 |
@{term "HOL.uminus :: int => _"}, @{term "HOL.uminus :: nat => _"},
|
|
37 |
@{term "Not"}, @{term "Suc"},
|
|
38 |
@{term "Ex :: (int => _) => _"}, @{term "Ex :: (nat => _) => _"},
|
|
39 |
@{term "All :: (int => _) => _"}, @{term "All :: (nat => _) => _"},
|
|
40 |
@{term "nat"}, @{term "int"},
|
|
41 |
@{term "Numeral.bit.B0"},@{term "Numeral.bit.B1"},
|
|
42 |
@{term "Numeral.Bit"}, @{term "Numeral.Pls"}, @{term "Numeral.Min"},
|
|
43 |
@{term "Numeral.number_of :: int => int"}, @{term "Numeral.number_of :: int => nat"},
|
|
44 |
@{term "0::int"}, @{term "1::int"}, @{term "0::nat"}, @{term "1::nat"},
|
|
45 |
@{term "True"}, @{term "False"}];
|
|
46 |
|
|
47 |
structure Data = GenericDataFun
|
|
48 |
(
|
|
49 |
val name = "Cooper-Data";
|
|
50 |
type T = simpset * (term list)
|
|
51 |
val empty = (start_ss, allowed_consts);
|
|
52 |
fun extend (ss,ts) = (MetaSimplifier.inherit_context empty_ss ss, ts);
|
|
53 |
fun merge _ ((ss1,ts1), (ss2,ts2)) = (merge_ss (ss1,ss2),
|
|
54 |
Library.merge (op aconv) (ts1,ts2)));
|
|
55 |
|
|
56 |
val get = Data.get o Context.Proof;
|
|
57 |
|
|
58 |
fun add ts = Thm.declaration_attribute (fn th => fn context =>
|
|
59 |
context |> Data.map (fn (ss,ts') =>
|
|
60 |
(ss addsimps [th], Library.merge (op aconv) (ts',ts) )))
|
|
61 |
|
|
62 |
fun del ts = Thm.declaration_attribute (fn th => fn context =>
|
|
63 |
context |> Data.map (fn (ss,ts') =>
|
|
64 |
(ss delsimps [th], Library.subtract (op aconv) ts' ts )))
|
|
65 |
|
|
66 |
(* concrete syntax *)
|
23336
|
67 |
local
|
23311
|
68 |
fun keyword k = Scan.lift (Args.$$$ k -- Args.colon) >> K ();
|
|
69 |
|
|
70 |
val constsN = "consts";
|
|
71 |
val any_keyword = keyword constsN
|
|
72 |
val thms = Scan.repeat (Scan.unless any_keyword Attrib.multi_thm) >> flat;
|
|
73 |
val terms = thms >> map (term_of o Drule.dest_term);
|
|
74 |
|
|
75 |
fun optional scan = Scan.optional scan [];
|
|
76 |
|
23336
|
77 |
in
|
23311
|
78 |
fun att_syntax src = src |> Attrib.syntax
|
|
79 |
((Scan.lift (Args.$$$ "del") |-- optional (keyword constsN |-- terms)) >> del ||
|
23336
|
80 |
optional (keyword constsN |-- terms) >> add)
|
|
81 |
end;
|
23311
|
82 |
|
|
83 |
|
|
84 |
(* theory setup *)
|
|
85 |
val setup =
|
|
86 |
Attrib.add_attributes [("presburger", att_syntax, "Cooper data")];
|
|
87 |
end;
|