src/HOL/Fun_Def.thy
changeset 56643 41d3596d8a64
parent 56248 67dc9549fa15
child 56846 9df717fef2bb
equal deleted inserted replaced
56642:15cd15f9b40c 56643:41d3596d8a64
   109 setup {*
   109 setup {*
   110   Function.setup
   110   Function.setup
   111   #> Function_Fun.setup
   111   #> Function_Fun.setup
   112 *}
   112 *}
   113 
   113 
   114 subsection {* Measure Functions *}
   114 
       
   115 subsection {* Measure functions *}
   115 
   116 
   116 inductive is_measure :: "('a \<Rightarrow> nat) \<Rightarrow> bool"
   117 inductive is_measure :: "('a \<Rightarrow> nat) \<Rightarrow> bool"
   117 where is_measure_trivial: "is_measure f"
   118 where is_measure_trivial: "is_measure f"
   118 
   119 
   119 ML_file "Tools/Function/measure_functions.ML"
   120 ML_file "Tools/Function/measure_functions.ML"
   135 *} "termination prover for lexicographic orderings"
   136 *} "termination prover for lexicographic orderings"
   136 
   137 
   137 setup Lexicographic_Order.setup
   138 setup Lexicographic_Order.setup
   138 
   139 
   139 
   140 
   140 subsection {* Congruence Rules *}
   141 subsection {* Congruence rules *}
   141 
   142 
   142 lemma let_cong [fundef_cong]:
   143 lemma let_cong [fundef_cong]:
   143   "M = N \<Longrightarrow> (\<And>x. x = N \<Longrightarrow> f x = g x) \<Longrightarrow> Let M f = Let N g"
   144   "M = N \<Longrightarrow> (\<And>x. x = N \<Longrightarrow> f x = g x) \<Longrightarrow> Let M f = Let N g"
   144   unfolding Let_def by blast
   145   unfolding Let_def by blast
   145 
   146 
   154 
   155 
   155 lemma comp_cong [fundef_cong]:
   156 lemma comp_cong [fundef_cong]:
   156   "f (g x) = f' (g' x') \<Longrightarrow> (f o g) x = (f' o g') x'"
   157   "f (g x) = f' (g' x') \<Longrightarrow> (f o g) x = (f' o g') x'"
   157   unfolding o_apply .
   158   unfolding o_apply .
   158 
   159 
       
   160 
   159 subsection {* Simp rules for termination proofs *}
   161 subsection {* Simp rules for termination proofs *}
   160 
   162 
   161 lemma termination_basic_simps[termination_simp]:
   163 declare
   162   "x < (y::nat) \<Longrightarrow> x < y + z"
   164   trans_less_add1[termination_simp]
   163   "x < z \<Longrightarrow> x < y + z"
   165   trans_less_add2[termination_simp]
   164   "x \<le> y \<Longrightarrow> x \<le> y + (z::nat)"
   166   trans_le_add1[termination_simp]
   165   "x \<le> z \<Longrightarrow> x \<le> y + (z::nat)"
   167   trans_le_add2[termination_simp]
   166   "x < y \<Longrightarrow> x \<le> (y::nat)"
   168   less_imp_le_nat[termination_simp]
   167 by arith+
   169   le_imp_less_Suc[termination_simp]
   168 
       
   169 declare le_imp_less_Suc[termination_simp]
       
   170 
   170 
   171 lemma prod_size_simp[termination_simp]:
   171 lemma prod_size_simp[termination_simp]:
   172   "prod_size f g p = f (fst p) + g (snd p) + Suc 0"
   172   "prod_size f g p = f (fst p) + g (snd p) + Suc 0"
   173 by (induct p) auto
   173 by (induct p) auto
       
   174 
   174 
   175 
   175 subsection {* Decomposition *}
   176 subsection {* Decomposition *}
   176 
   177 
   177 lemma less_by_empty:
   178 lemma less_by_empty:
   178   "A = {} \<Longrightarrow> A \<subseteq> B"
   179   "A = {} \<Longrightarrow> A \<subseteq> B"
   183 and wf_no_loop:
   184 and wf_no_loop:
   184   "R O R = {} \<Longrightarrow> wf R"
   185   "R O R = {} \<Longrightarrow> wf R"
   185 by (auto simp add: wf_comp_self[of R])
   186 by (auto simp add: wf_comp_self[of R])
   186 
   187 
   187 
   188 
   188 subsection {* Reduction Pairs *}
   189 subsection {* Reduction pairs *}
   189 
   190 
   190 definition
   191 definition
   191   "reduction_pair P = (wf (fst P) \<and> fst P O snd P \<subseteq> fst P)"
   192   "reduction_pair P = (wf (fst P) \<and> fst P O snd P \<subseteq> fst P)"
   192 
   193 
   193 lemma reduction_pairI[intro]: "wf R \<Longrightarrow> R O S \<subseteq> R \<Longrightarrow> reduction_pair (R, S)"
   194 lemma reduction_pairI[intro]: "wf R \<Longrightarrow> R O S \<subseteq> R \<Longrightarrow> reduction_pair (R, S)"