5261
|
1 |
(* Title: HOL/Lambda/InductTermi.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Tobias Nipkow
|
|
4 |
Copyright 1998 TU Muenchen
|
|
5 |
|
|
6 |
Inductive characterization of terminating lambda terms.
|
|
7 |
Goes back to
|
|
8 |
Raamsdonk & Severi. On normalization. CWI TR CS-R9545, 1995.
|
|
9 |
Also rediscovered by Matthes and Joachimski.
|
|
10 |
*)
|
|
11 |
|
9716
|
12 |
theory InductTermi = ListBeta:
|
5261
|
13 |
|
9716
|
14 |
consts
|
|
15 |
IT :: "dB set"
|
|
16 |
|
5261
|
17 |
inductive IT
|
9716
|
18 |
intros
|
|
19 |
Var: "rs : lists IT ==> Var n $$ rs : IT"
|
|
20 |
Lambda: "r : IT ==> Abs r : IT"
|
|
21 |
Beta: "[| (r[s/0])$$ss : IT; s : IT |] ==> (Abs r $ s)$$ss : IT"
|
|
22 |
monos lists_mono (* FIXME move to HOL!? *)
|
|
23 |
|
|
24 |
|
|
25 |
text {* Every term in IT terminates. *}
|
|
26 |
|
|
27 |
lemma double_induction_lemma [rulify]:
|
|
28 |
"s : termi beta ==> \<forall>t. t : termi beta -->
|
|
29 |
(\<forall>r ss. t = r[s/0] $$ ss --> Abs r $ s $$ ss : termi beta)"
|
|
30 |
apply (erule acc_induct)
|
|
31 |
apply (erule thin_rl)
|
|
32 |
apply (rule allI)
|
|
33 |
apply (rule impI)
|
|
34 |
apply (erule acc_induct)
|
|
35 |
apply clarify
|
|
36 |
apply (rule accI)
|
9762
|
37 |
apply (tactic {* safe_tac (claset () addSEs [thm "apps_betasE"]) *}) -- FIXME
|
9716
|
38 |
apply assumption
|
|
39 |
apply (blast intro: subst_preserves_beta apps_preserves_beta)
|
|
40 |
apply (blast intro: apps_preserves_beta2 subst_preserves_beta2 rtrancl_converseI
|
|
41 |
dest: acc_downwards) (* FIXME: acc_downwards can be replaced by acc(R ^* ) = acc(r) *)
|
|
42 |
apply (blast dest: apps_preserves_betas)
|
|
43 |
done
|
|
44 |
|
|
45 |
lemma IT_implies_termi: "t : IT ==> t : termi beta"
|
|
46 |
apply (erule IT.induct)
|
|
47 |
apply (drule rev_subsetD)
|
|
48 |
apply (rule lists_mono)
|
|
49 |
apply (rule Int_lower2)
|
|
50 |
apply simp
|
|
51 |
apply (drule lists_accD)
|
|
52 |
apply (erule acc_induct)
|
|
53 |
apply (rule accI)
|
|
54 |
apply (blast dest: head_Var_reduction)
|
|
55 |
apply (erule acc_induct)
|
|
56 |
apply (rule accI)
|
|
57 |
apply blast
|
|
58 |
apply (blast intro: double_induction_lemma)
|
|
59 |
done
|
|
60 |
|
|
61 |
|
|
62 |
text {* Every terminating term is in IT *}
|
|
63 |
|
|
64 |
declare Var_apps_neq_Abs_apps [THEN not_sym, simp]
|
|
65 |
|
|
66 |
lemma [simp, THEN not_sym, simp]: "Var n $$ ss ~= Abs r $ s $$ ts"
|
|
67 |
apply (simp add: foldl_Cons [symmetric] del: foldl_Cons)
|
|
68 |
done
|
|
69 |
|
|
70 |
lemma [simp]:
|
|
71 |
"(Abs r $ s $$ ss = Abs r' $ s' $$ ss') = (r=r' \<and> s=s' \<and> ss=ss')"
|
|
72 |
apply (simp add: foldl_Cons [symmetric] del: foldl_Cons)
|
|
73 |
done
|
|
74 |
|
|
75 |
inductive_cases [elim!]:
|
|
76 |
"Var n $$ ss : IT"
|
|
77 |
"Abs t : IT"
|
|
78 |
"Abs r $ s $$ ts : IT"
|
|
79 |
|
|
80 |
|
|
81 |
theorem termi_implies_IT: "r : termi beta ==> r : IT"
|
|
82 |
apply (erule acc_induct)
|
|
83 |
apply (rename_tac r)
|
|
84 |
apply (erule thin_rl)
|
|
85 |
apply (erule rev_mp)
|
|
86 |
apply simp
|
|
87 |
apply (rule_tac t = r in Apps_dB_induct)
|
|
88 |
apply clarify
|
|
89 |
apply (rule IT.intros)
|
|
90 |
apply clarify
|
|
91 |
apply (drule bspec, assumption)
|
|
92 |
apply (erule mp)
|
|
93 |
apply clarify
|
|
94 |
apply (drule converseI)
|
|
95 |
apply (drule ex_step1I, assumption)
|
|
96 |
apply clarify
|
|
97 |
apply (rename_tac us)
|
|
98 |
apply (erule_tac x = "Var n $$ us" in allE)
|
|
99 |
apply force
|
|
100 |
apply (rename_tac u ts)
|
|
101 |
apply (case_tac ts)
|
|
102 |
apply simp
|
|
103 |
apply (blast intro: IT.intros)
|
|
104 |
apply (rename_tac s ss)
|
|
105 |
apply simp
|
|
106 |
apply clarify
|
|
107 |
apply (rule IT.intros)
|
|
108 |
apply (blast intro: apps_preserves_beta)
|
|
109 |
apply (erule mp)
|
|
110 |
apply clarify
|
|
111 |
apply (rename_tac t)
|
|
112 |
apply (erule_tac x = "Abs u $ t $$ ss" in allE)
|
|
113 |
apply force
|
|
114 |
done
|
5261
|
115 |
|
|
116 |
end
|