10370
|
1 |
(* ID: $Id$ *)
|
10426
|
2 |
theory Advanced = Even:
|
|
3 |
|
|
4 |
text{* We completely forgot about "rule inversion", or whatever we may want
|
|
5 |
to call it. Just as a demo I include the two forms that Markus has made available. First the one for binding the result to a name *}
|
|
6 |
|
|
7 |
inductive_cases even_cases [elim!]:
|
|
8 |
"Suc(Suc n) \<in> even"
|
|
9 |
|
|
10 |
thm even_cases;
|
|
11 |
|
|
12 |
text{*and now the one for local usage:*}
|
|
13 |
|
|
14 |
lemma "Suc(Suc n) \<in> even \<Longrightarrow> n \<in> even";
|
|
15 |
by(ind_cases "Suc(Suc n) \<in> even");
|
|
16 |
|
|
17 |
text{*Both forms accept lists of strings.
|
|
18 |
|
|
19 |
Hope you can find some more exciting examples, although these may do
|
|
20 |
*}
|
|
21 |
|
10370
|
22 |
|
|
23 |
datatype 'f "term" = Apply 'f "'f term list"
|
|
24 |
|
|
25 |
consts terms :: "'f set \<Rightarrow> 'f term set"
|
|
26 |
inductive "terms F"
|
|
27 |
intros
|
|
28 |
step[intro]: "\<lbrakk>\<forall>t \<in> set term_list. t \<in> terms F; f \<in> F\<rbrakk>
|
|
29 |
\<Longrightarrow> (Apply f term_list) \<in> terms F"
|
|
30 |
|
|
31 |
|
|
32 |
lemma "F\<subseteq>G \<Longrightarrow> terms F \<subseteq> terms G"
|
|
33 |
apply clarify
|
|
34 |
apply (erule terms.induct)
|
|
35 |
apply blast
|
|
36 |
done
|
|
37 |
|
|
38 |
consts term_type :: "('f \<Rightarrow> 't list * 't) \<Rightarrow> ('f term * 't)set"
|
|
39 |
inductive "term_type sig"
|
|
40 |
intros
|
|
41 |
step[intro]: "\<lbrakk>\<forall>et \<in> set term_type_list. et \<in> term_type sig;
|
|
42 |
sig f = (map snd term_type_list, rtype)\<rbrakk>
|
|
43 |
\<Longrightarrow> (Apply f (map fst term_type_list), rtype) \<in> term_type sig"
|
|
44 |
|
|
45 |
consts term_type' :: "('f \<Rightarrow> 't list * 't) \<Rightarrow> ('f term * 't)set"
|
|
46 |
inductive "term_type' sig"
|
|
47 |
intros
|
|
48 |
step[intro]: "\<lbrakk>term_type_list \<in> lists(term_type' sig);
|
|
49 |
sig f = (map snd term_type_list, rtype)\<rbrakk>
|
|
50 |
\<Longrightarrow> (Apply f (map fst term_type_list), rtype) \<in> term_type' sig"
|
|
51 |
monos lists_mono
|
|
52 |
|
|
53 |
|
|
54 |
lemma "term_type sig \<subseteq> term_type' sig"
|
|
55 |
apply clarify
|
|
56 |
apply (erule term_type.induct)
|
|
57 |
apply auto
|
|
58 |
done
|
|
59 |
|
|
60 |
lemma "term_type' sig \<subseteq> term_type sig"
|
|
61 |
apply clarify
|
|
62 |
apply (erule term_type'.induct)
|
|
63 |
apply auto
|
|
64 |
done
|
|
65 |
|
|
66 |
end
|
|
67 |
|