12 header {* The accessible part of a relation *} |
12 header {* The accessible part of a relation *} |
13 |
13 |
14 theory Acc = Main: |
14 theory Acc = Main: |
15 |
15 |
16 consts |
16 consts |
17 acc :: "('a * 'a)set => 'a set" -- {* accessible part *} |
17 acc :: "('a \<times> 'a) set => 'a set" -- {* accessible part *} |
18 |
18 |
19 inductive "acc r" |
19 inductive "acc r" |
20 intros |
20 intros |
21 accI [rulify_prems]: |
21 accI [rulify_prems]: |
22 "ALL y. (y, x) : r --> y : acc r ==> x : acc r" |
22 "\<forall>y. (y, x) \<in> r --> y \<in> acc r ==> x \<in> acc r" |
23 |
23 |
24 syntax |
24 syntax |
25 termi :: "('a * 'a)set => 'a set" |
25 termi :: "('a \<times> 'a) set => 'a set" |
26 translations |
26 translations |
27 "termi r" == "acc(r^-1)" |
27 "termi r" == "acc (r^-1)" |
|
28 |
|
29 |
|
30 theorem acc_induct: |
|
31 "[| a \<in> acc r; |
|
32 !!x. [| x \<in> acc r; \<forall>y. (y, x) \<in> r --> P y |] ==> P x |
|
33 |] ==> P a" |
|
34 proof - |
|
35 assume major: "a \<in> acc r" |
|
36 assume hyp: "!!x. [| x \<in> acc r; \<forall>y. (y, x) \<in> r --> P y |] ==> P x" |
|
37 show ?thesis |
|
38 apply (rule major [THEN acc.induct]) |
|
39 apply (rule hyp) |
|
40 apply (rule accI) |
|
41 apply fast |
|
42 apply fast |
|
43 done |
|
44 qed |
|
45 |
|
46 theorem acc_downward: "[| b \<in> acc r; (a, b) \<in> r |] ==> a \<in> acc r" |
|
47 apply (erule acc.elims) |
|
48 apply fast |
|
49 done |
|
50 |
|
51 lemma acc_downwards_aux: "(b, a) \<in> r^* ==> a \<in> acc r --> b \<in> acc r" |
|
52 apply (erule rtrancl_induct) |
|
53 apply blast |
|
54 apply (blast dest: acc_downward) |
|
55 done |
|
56 |
|
57 theorem acc_downwards: "[| a \<in> acc r; (b, a) \<in> r^* |] ==> b \<in> acc r" |
|
58 apply (blast dest: acc_downwards_aux) |
|
59 done |
|
60 |
|
61 theorem acc_wfI: "\<forall>x. x \<in> acc r ==> wf r" |
|
62 apply (rule wfUNIVI) |
|
63 apply (induct_tac P x rule: acc_induct) |
|
64 apply blast |
|
65 apply blast |
|
66 done |
|
67 |
|
68 theorem acc_wfD: "wf r ==> x \<in> acc r" |
|
69 apply (erule wf_induct) |
|
70 apply (rule accI) |
|
71 apply blast |
|
72 done |
|
73 |
|
74 theorem wf_acc_iff: "wf r = (\<forall>x. x \<in> acc r)" |
|
75 apply (blast intro: acc_wfI dest: acc_wfD) |
|
76 done |
28 |
77 |
29 end |
78 end |