author | wenzelm |
Tue, 10 Jul 2007 23:29:43 +0200 | |
changeset 23719 | ccd9cb15c062 |
parent 19739 | c58ef2aa5430 |
child 25136 | 3cfa2a60837f |
permissions | -rw-r--r-- |
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
1 |
(* Title: HOL/IOA/NTP/Multiset.thy |
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
2 |
ID: $Id$ |
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
3 |
Author: Tobias Nipkow & Konrad Slind |
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
4 |
*) |
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
5 |
|
17244 | 6 |
header {* Axiomatic multisets *} |
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
7 |
|
17244 | 8 |
theory Multiset |
9 |
imports Lemmas |
|
10 |
begin |
|
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
11 |
|
17244 | 12 |
typedecl |
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
13 |
'a multiset |
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
14 |
|
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
15 |
consts |
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
16 |
|
17244 | 17 |
"{|}" :: "'a multiset" ("{|}") |
18 |
addm :: "['a multiset, 'a] => 'a multiset" |
|
19 |
delm :: "['a multiset, 'a] => 'a multiset" |
|
20 |
countm :: "['a multiset, 'a => bool] => nat" |
|
21 |
count :: "['a multiset, 'a] => nat" |
|
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
22 |
|
17244 | 23 |
axioms |
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
24 |
|
17244 | 25 |
delm_empty_def: |
26 |
"delm {|} x = {|}" |
|
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
27 |
|
17244 | 28 |
delm_nonempty_def: |
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
29 |
"delm (addm M x) y == (if x=y then M else addm (delm M y) x)" |
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
30 |
|
17244 | 31 |
countm_empty_def: |
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
32 |
"countm {|} P == 0" |
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
33 |
|
17244 | 34 |
countm_nonempty_def: |
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
35 |
"countm (addm M x) P == countm M P + (if P x then Suc 0 else 0)" |
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
36 |
|
17244 | 37 |
count_def: |
3852 | 38 |
"count M x == countm M (%y. y = x)" |
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
39 |
|
17244 | 40 |
"induction": |
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
41 |
"[| P({|}); !!M x. P(M) ==> P(addm M x) |] ==> P(M)" |
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
42 |
|
19739 | 43 |
lemma count_empty: |
44 |
"count {|} x = 0" |
|
45 |
by (simp add: Multiset.count_def Multiset.countm_empty_def) |
|
46 |
||
47 |
lemma count_addm_simp: |
|
48 |
"count (addm M x) y = (if y=x then Suc(count M y) else count M y)" |
|
49 |
by (simp add: Multiset.count_def Multiset.countm_nonempty_def) |
|
50 |
||
51 |
lemma count_leq_addm: "count M y <= count (addm M x) y" |
|
52 |
by (simp add: count_addm_simp) |
|
53 |
||
54 |
lemma count_delm_simp: |
|
55 |
"count (delm M x) y = (if y=x then count M y - 1 else count M y)" |
|
56 |
apply (unfold Multiset.count_def) |
|
57 |
apply (rule_tac M = "M" in Multiset.induction) |
|
58 |
apply (simp (no_asm_simp) add: Multiset.delm_empty_def Multiset.countm_empty_def) |
|
59 |
apply (simp add: Multiset.delm_nonempty_def Multiset.countm_nonempty_def) |
|
60 |
apply safe |
|
61 |
apply simp |
|
62 |
done |
|
63 |
||
64 |
lemma countm_props: "!!M. (!x. P(x) --> Q(x)) ==> (countm M P <= countm M Q)" |
|
65 |
apply (rule_tac M = "M" in Multiset.induction) |
|
66 |
apply (simp (no_asm) add: Multiset.countm_empty_def) |
|
67 |
apply (simp (no_asm) add: Multiset.countm_nonempty_def) |
|
68 |
apply auto |
|
69 |
done |
|
70 |
||
71 |
lemma countm_spurious_delm: "!!P. ~P(obj) ==> countm M P = countm (delm M obj) P" |
|
72 |
apply (rule_tac M = "M" in Multiset.induction) |
|
73 |
apply (simp (no_asm) add: Multiset.delm_empty_def Multiset.countm_empty_def) |
|
74 |
apply (simp (no_asm_simp) add: Multiset.countm_nonempty_def Multiset.delm_nonempty_def) |
|
75 |
done |
|
76 |
||
77 |
||
78 |
lemma pos_count_imp_pos_countm [rule_format (no_asm)]: "!!P. P(x) ==> 0<count M x --> 0<countm M P" |
|
79 |
apply (rule_tac M = "M" in Multiset.induction) |
|
80 |
apply (simp (no_asm) add: Multiset.delm_empty_def Multiset.count_def Multiset.countm_empty_def) |
|
81 |
apply (simp (no_asm_simp) add: Multiset.count_def Multiset.delm_nonempty_def Multiset.countm_nonempty_def) |
|
82 |
done |
|
83 |
||
84 |
lemma countm_done_delm: |
|
85 |
"!!P. P(x) ==> 0<count M x --> countm (delm M x) P = countm M P - 1" |
|
86 |
apply (rule_tac M = "M" in Multiset.induction) |
|
87 |
apply (simp (no_asm) add: Multiset.delm_empty_def Multiset.countm_empty_def) |
|
88 |
apply (simp (no_asm_simp) add: count_addm_simp Multiset.delm_nonempty_def Multiset.countm_nonempty_def pos_count_imp_pos_countm) |
|
89 |
apply auto |
|
90 |
done |
|
91 |
||
92 |
||
93 |
declare count_addm_simp [simp] count_delm_simp [simp] |
|
94 |
Multiset.countm_empty_def [simp] Multiset.delm_empty_def [simp] count_empty [simp] |
|
17244 | 95 |
|
3073
88366253a09a
Old NTP files now running under the IOA meta theory based on HOLCF;
mueller
parents:
diff
changeset
|
96 |
end |