author | ballarin |
Fri, 14 Jul 2006 14:37:15 +0200 | |
changeset 20129 | 95e84d2c9f2c |
parent 19931 | fb32b43e7f80 |
child 20168 | ed7bced29e1b |
permissions | -rw-r--r-- |
13854 | 1 |
(* |
2 |
Title: Normalisation method for locale cring |
|
3 |
Id: $Id$ |
|
4 |
Author: Clemens Ballarin |
|
5 |
Copyright: TU Muenchen |
|
6 |
*) |
|
7 |
||
8 |
(*** Term order for commutative rings ***) |
|
9 |
||
20129
95e84d2c9f2c
Term.term_lpo takes order on terms rather than strings as argument.
ballarin
parents:
19931
diff
changeset
|
10 |
fun ring_ord (Const (a, _)) = |
95e84d2c9f2c
Term.term_lpo takes order on terms rather than strings as argument.
ballarin
parents:
19931
diff
changeset
|
11 |
find_index_eq a ["CRing.ring.zero", "CRing.ring.add", "CRing.a_inv", |
95e84d2c9f2c
Term.term_lpo takes order on terms rather than strings as argument.
ballarin
parents:
19931
diff
changeset
|
12 |
"CRing.minus", "Group.monoid.one", "Group.monoid.mult"] |
95e84d2c9f2c
Term.term_lpo takes order on terms rather than strings as argument.
ballarin
parents:
19931
diff
changeset
|
13 |
| ring_ord _ = ~1; |
13854 | 14 |
|
16568 | 15 |
fun termless_ring (a, b) = (Term.term_lpo ring_ord (a, b) = LESS); |
13854 | 16 |
|
17 |
val cring_ss = HOL_ss settermless termless_ring; |
|
18 |
||
19 |
fun cring_normalise ctxt = let |
|
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
20 |
fun filter p t = (case HOLogic.dest_Trueprop t of |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
21 |
Const (p', _) $ Free (s, _) => if p = p' then [s] else [] |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
22 |
| _ => []) |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
23 |
handle TERM _ => []; |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
24 |
fun filter21 p t = (case HOLogic.dest_Trueprop t of |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
25 |
Const (p', _) $ Free (s, _) $ _ => if p = p' then [s] else [] |
14399
dc677b35e54f
New lemmas about inversion of restricted functions.
ballarin
parents:
13936
diff
changeset
|
26 |
| _ => []) |
dc677b35e54f
New lemmas about inversion of restricted functions.
ballarin
parents:
13936
diff
changeset
|
27 |
handle TERM _ => []; |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
28 |
fun filter22 p t = (case HOLogic.dest_Trueprop t of |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
29 |
Const (p', _) $ _ $ Free (s, _) => if p = p' then [s] else [] |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
30 |
| _ => []) |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
31 |
handle TERM _ => []; |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
32 |
fun filter31 p t = (case HOLogic.dest_Trueprop t of |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
33 |
Const (p', _) $ Free (s, _) $ _ $ _ => if p = p' then [s] else [] |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
34 |
| _ => []) |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
35 |
handle TERM _ => []; |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
36 |
fun filter32 p t = (case HOLogic.dest_Trueprop t of |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
37 |
Const (p', _) $ _ $ Free (s, _) $ _ => if p = p' then [s] else [] |
13864 | 38 |
| _ => []) |
13854 | 39 |
handle TERM _ => []; |
14399
dc677b35e54f
New lemmas about inversion of restricted functions.
ballarin
parents:
13936
diff
changeset
|
40 |
|
dc677b35e54f
New lemmas about inversion of restricted functions.
ballarin
parents:
13936
diff
changeset
|
41 |
val prems = ProofContext.prems_of ctxt; |
19931
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
42 |
val non_comm_rings = List.concat (map (filter "CRing.ring" o #prop o rep_thm) prems); |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
43 |
val comm_rings = List.concat (map (filter "CRing.cring" o #prop o rep_thm) prems) @ |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
44 |
List.concat (map (filter "CRing.domain" o #prop o rep_thm) prems) @ |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
45 |
List.concat (map (filter21 "Module.module" o #prop o rep_thm) prems) @ |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
46 |
List.concat (map (filter21 "Module.algebra" o #prop o rep_thm) prems) @ |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
47 |
List.concat (map (filter22 "Module.algebra" o #prop o rep_thm) prems) @ |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
48 |
List.concat (map (filter "UnivPoly.UP_cring" o #prop o rep_thm) prems) @ |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
49 |
List.concat (map (filter "UnivPoly.UP_domain" o #prop o rep_thm) prems) @ |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
50 |
List.concat (map (filter31 "CRing.ring_hom_cring" o #prop o rep_thm) prems) @ |
fb32b43e7f80
Restructured locales with predicates: import is now an interpretation.
ballarin
parents:
16568
diff
changeset
|
51 |
List.concat (map (filter32 "CRing.ring_hom_cring" o #prop o rep_thm) prems); |
14399
dc677b35e54f
New lemmas about inversion of restricted functions.
ballarin
parents:
13936
diff
changeset
|
52 |
val _ = tracing |
dc677b35e54f
New lemmas about inversion of restricted functions.
ballarin
parents:
13936
diff
changeset
|
53 |
("Non-commutative rings in proof context: " ^ commas non_comm_rings ^ |
dc677b35e54f
New lemmas about inversion of restricted functions.
ballarin
parents:
13936
diff
changeset
|
54 |
"\nCommutative rings in proof context: " ^ commas comm_rings); |
13854 | 55 |
val simps = |
16486 | 56 |
List.concat (map (fn s => ProofContext.get_thms ctxt (Name (s ^ ".ring_simprules"))) |
14399
dc677b35e54f
New lemmas about inversion of restricted functions.
ballarin
parents:
13936
diff
changeset
|
57 |
non_comm_rings) @ |
16486 | 58 |
List.concat (map (fn s => ProofContext.get_thms ctxt (Name (s ^ ".cring_simprules"))) |
14399
dc677b35e54f
New lemmas about inversion of restricted functions.
ballarin
parents:
13936
diff
changeset
|
59 |
comm_rings); |
13854 | 60 |
in Method.SIMPLE_METHOD' HEADGOAL (asm_full_simp_tac (cring_ss addsimps simps)) |
61 |
end; |
|
62 |
||
63 |
(* |
|
64 |
val ring_ss = HOL_basic_ss settermless termless_ring addsimps |
|
65 |
[a_assoc, l_zero, l_neg, a_comm, m_assoc, l_one, l_distr, m_comm, minus_def, |
|
66 |
r_zero, r_neg, r_neg2, r_neg1, minus_add, minus_minus, minus0, |
|
67 |
a_lcomm, m_lcomm, (*r_one,*) r_distr, l_null, r_null, l_minus, r_minus]; |
|
68 |
*) |