| author | wenzelm | 
| Sun, 27 Oct 2024 11:46:04 +0100 | |
| changeset 81271 | fb391ad09b3c | 
| parent 74561 | 8e6c973003c8 | 
| child 82967 | 73af47bc277c | 
| permissions | -rw-r--r-- | 
| 35849 | 1 | (* Author: Clemens Ballarin | 
| 21505 | 2 | |
| 3 | Normalisation method for locales ring and cring. | |
| 13854 | 4 | *) | 
| 5 | ||
| 58811 | 6 | signature RINGSIMP = | 
| 20168 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 7 | sig | 
| 21505 | 8 | val print_structures: Proof.context -> unit | 
| 58811 | 9 | val add_struct: string * term list -> attribute | 
| 10 | val del_struct: string * term list -> attribute | |
| 47701 | 11 | val algebra_tac: Proof.context -> int -> tactic | 
| 20168 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 12 | end; | 
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 13 | |
| 58811 | 14 | structure Ringsimp: RINGSIMP = | 
| 20168 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 15 | struct | 
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 16 | |
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 17 | (** Theory and context data **) | 
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 18 | |
| 20547 | 19 | fun struct_eq ((s1: string, ts1), (s2, ts2)) = | 
| 20348 | 20 | (s1 = s2) andalso eq_list (op aconv) (ts1, ts2); | 
| 13854 | 21 | |
| 33519 | 22 | structure Data = Generic_Data | 
| 22846 | 23 | ( | 
| 20168 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 24 | type T = ((string * term list) * thm list) list; | 
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 25 | (* Algebraic structures: | 
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 26 | identifier of the structure, list of operations and simp rules, | 
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 27 | identifier and operations identify the structure uniquely. *) | 
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 28 | val empty = []; | 
| 33520 | 29 | val merge = AList.join struct_eq (K Thm.merge_thms); | 
| 22846 | 30 | ); | 
| 13854 | 31 | |
| 22846 | 32 | fun print_structures ctxt = | 
| 33 | let | |
| 34 | val structs = Data.get (Context.Proof ctxt); | |
| 24920 | 35 | val pretty_term = Pretty.quote o Syntax.pretty_term ctxt; | 
| 22846 | 36 | fun pretty_struct ((s, ts), _) = Pretty.block | 
| 37 | [Pretty.str s, Pretty.str ":", Pretty.brk 1, | |
| 38 |        Pretty.enclose "(" ")" (Pretty.breaks (map pretty_term ts))];
 | |
| 39 | in Pretty.writeln (Pretty.big_list "Algebraic structures:" (map pretty_struct structs)) end; | |
| 13854 | 40 | |
| 20168 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 41 | |
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 42 | (** Method **) | 
| 13854 | 43 | |
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
47701diff
changeset | 44 | fun struct_tac ctxt ((s, ts), simps) = | 
| 20168 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 45 | let | 
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 46 | val ops = map (fst o Term.strip_comb) ts; | 
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 47 | fun ord (Const (a, _)) = find_index (fn (Const (b, _)) => a=b | _ => false) ops | 
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 48 | | ord (Free (a, _)) = find_index (fn (Free (b, _)) => a=b | _ => false) ops; | 
| 67561 
f0b11413f1c9
clarified signature: prefer proper order operation;
 wenzelm parents: 
67560diff
changeset | 49 | in | 
| 
f0b11413f1c9
clarified signature: prefer proper order operation;
 wenzelm parents: 
67560diff
changeset | 50 | asm_full_simp_tac | 
| 
f0b11413f1c9
clarified signature: prefer proper order operation;
 wenzelm parents: 
67560diff
changeset | 51 | (put_simpset HOL_ss ctxt addsimps simps |> Simplifier.set_term_ord (Term_Ord.term_lpo ord)) | 
| 
f0b11413f1c9
clarified signature: prefer proper order operation;
 wenzelm parents: 
67560diff
changeset | 52 | end; | 
| 20168 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 53 | |
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 54 | fun algebra_tac ctxt = | 
| 51717 
9e7d1c139569
simplifier uses proper Proof.context instead of historic type simpset;
 wenzelm parents: 
47701diff
changeset | 55 | EVERY' (map (fn s => TRY o struct_tac ctxt s) (Data.get (Context.Proof ctxt))); | 
| 20168 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 56 | |
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 57 | |
| 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 58 | (** Attribute **) | 
| 14399 
dc677b35e54f
New lemmas about inversion of restricted functions.
 ballarin parents: 
13936diff
changeset | 59 | |
| 58811 | 60 | fun add_struct s = | 
| 22634 | 61 | Thm.declaration_attribute | 
| 22846 | 62 | (fn thm => Data.map (AList.map_default struct_eq (s, []) (insert Thm.eq_thm_prop thm))); | 
| 47701 | 63 | |
| 20168 
ed7bced29e1b
Reimplemented algebra method; now controlled by attribute.
 ballarin parents: 
20129diff
changeset | 64 | fun del_struct s = | 
| 22634 | 65 | Thm.declaration_attribute | 
| 22846 | 66 | (fn _ => Data.map (AList.delete struct_eq s)); | 
| 13854 | 67 | |
| 21505 | 68 | end; |