author | bulwahn |
Mon, 29 Mar 2010 17:30:52 +0200 | |
changeset 36032 | dfd30b5b4e73 |
parent 35494 | 45c9a8278faf |
child 36452 | d37c6eed8117 |
permissions | -rw-r--r-- |
33813 | 1 |
(* Title: HOLCF/ex/New_Domain.thy |
2 |
Author: Brian Huffman |
|
3 |
*) |
|
4 |
||
5 |
header {* Definitional domain package *} |
|
6 |
||
7 |
theory New_Domain |
|
8 |
imports HOLCF |
|
9 |
begin |
|
10 |
||
11 |
text {* |
|
12 |
The definitional domain package only works with representable domains, |
|
13 |
i.e. types in class @{text rep}. |
|
14 |
*} |
|
15 |
||
16 |
defaultsort rep |
|
17 |
||
18 |
text {* |
|
19 |
Provided that @{text rep} is the default sort, the @{text new_domain} |
|
20 |
package should work with any type definition supported by the old |
|
21 |
domain package. |
|
22 |
*} |
|
23 |
||
24 |
new_domain 'a llist = LNil | LCons (lazy 'a) (lazy "'a llist") |
|
25 |
||
26 |
text {* |
|
27 |
The difference is that the new domain package is completely |
|
28 |
definitional, and does not generate any axioms. The following type |
|
29 |
and constant definitions are not produced by the old domain package. |
|
30 |
*} |
|
31 |
||
32 |
thm type_definition_llist |
|
33 |
thm llist_abs_def llist_rep_def |
|
34 |
||
35 |
text {* |
|
36 |
The new domain package also adds support for indirect recursion with |
|
37 |
user-defined datatypes. This definition of a tree datatype uses |
|
38 |
indirect recursion through the lazy list type constructor. |
|
39 |
*} |
|
40 |
||
41 |
new_domain 'a ltree = Leaf (lazy 'a) | Branch (lazy "'a ltree llist") |
|
42 |
||
43 |
text {* |
|
44 |
For indirect-recursive definitions, the domain package is not able to |
|
45 |
generate a high-level induction rule. (It produces a warning |
|
46 |
message instead.) The low-level reach lemma (now proved as a |
|
47 |
theorem, no longer generated as an axiom) can be used to derive |
|
48 |
other induction rules. |
|
49 |
*} |
|
50 |
||
51 |
thm ltree.reach |
|
52 |
||
53 |
text {* |
|
35494
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
54 |
The definition of the take function uses map functions associated with |
33813 | 55 |
each type constructor involved in the definition. A map function |
56 |
for the lazy list type has been generated by the new domain package. |
|
57 |
*} |
|
58 |
||
35494
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
59 |
thm ltree.take_rews |
33813 | 60 |
thm llist_map_def |
61 |
||
62 |
lemma ltree_induct: |
|
63 |
fixes P :: "'a ltree \<Rightarrow> bool" |
|
64 |
assumes adm: "adm P" |
|
65 |
assumes bot: "P \<bottom>" |
|
66 |
assumes Leaf: "\<And>x. P (Leaf\<cdot>x)" |
|
67 |
assumes Branch: "\<And>f l. \<forall>x. P (f\<cdot>x) \<Longrightarrow> P (Branch\<cdot>(llist_map\<cdot>f\<cdot>l))" |
|
68 |
shows "P x" |
|
69 |
proof - |
|
35494
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
70 |
have "P (\<Squnion>i. ltree_take i\<cdot>x)" |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
71 |
using adm |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
72 |
proof (rule admD) |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
73 |
fix i |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
74 |
show "P (ltree_take i\<cdot>x)" |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
75 |
proof (induct i arbitrary: x) |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
76 |
case (0 x) |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
77 |
show "P (ltree_take 0\<cdot>x)" by (simp add: bot) |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
78 |
next |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
79 |
case (Suc n x) |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
80 |
show "P (ltree_take (Suc n)\<cdot>x)" |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
81 |
apply (cases x) |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
82 |
apply (simp add: bot) |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
83 |
apply (simp add: Leaf) |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
84 |
apply (simp add: Branch Suc) |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
85 |
done |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
86 |
qed |
45c9a8278faf
domain package no longer generates copy functions; all proofs use take functions instead
huffman
parents:
33813
diff
changeset
|
87 |
qed (simp add: ltree.chain_take) |
33813 | 88 |
thus ?thesis |
89 |
by (simp add: ltree.reach) |
|
90 |
qed |
|
91 |
||
92 |
end |