src/HOL/Relation.thy
changeset 76559 4352d0ff165a
parent 76554 a7d9e34c85e6
child 76560 df6ba3cf7874
equal deleted inserted replaced
76554:a7d9e34c85e6 76559:4352d0ff165a
     1 (*  Title:      HOL/Relation.thy
     1 (*  Title:      HOL/Relation.thy
     2     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     2     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     3     Author:     Stefan Berghofer, TU Muenchen
     3     Author:     Stefan Berghofer, TU Muenchen
       
     4     Author:     Martin Desharnais, MPI-INF Saarbruecken
     4 *)
     5 *)
     5 
     6 
     6 section \<open>Relations -- as sets of pairs, and binary predicates\<close>
     7 section \<open>Relations -- as sets of pairs, and binary predicates\<close>
     7 
     8 
     8 theory Relation
     9 theory Relation
   263   by (simp add: reflp_onI)
   264   by (simp add: reflp_onI)
   264 
   265 
   265 
   266 
   266 subsubsection \<open>Irreflexivity\<close>
   267 subsubsection \<open>Irreflexivity\<close>
   267 
   268 
   268 definition irrefl :: "'a rel \<Rightarrow> bool"
   269 definition irrefl_on :: "'a set \<Rightarrow> 'a rel \<Rightarrow> bool" where
   269   where "irrefl r \<longleftrightarrow> (\<forall>a. (a, a) \<notin> r)"
   270   "irrefl_on A r \<longleftrightarrow> (\<forall>a \<in> A. (a, a) \<notin> r)"
   270 
   271 
   271 definition irreflp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool"
   272 abbreviation irrefl :: "'a rel \<Rightarrow> bool" where
   272   where "irreflp R \<longleftrightarrow> (\<forall>a. \<not> R a a)"
   273   "irrefl \<equiv> irrefl_on UNIV"
   273 
   274 
   274 lemma irreflp_irrefl_eq [pred_set_conv]: "irreflp (\<lambda>a b. (a, b) \<in> R) \<longleftrightarrow> irrefl R"
   275 definition irreflp_on :: "'a set \<Rightarrow> ('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where
   275   by (simp add: irrefl_def irreflp_def)
   276   "irreflp_on A R \<longleftrightarrow> (\<forall>a \<in> A. \<not> R a a)"
   276 
   277 
   277 lemma irreflI [intro?]: "(\<And>a. (a, a) \<notin> R) \<Longrightarrow> irrefl R"
   278 abbreviation irreflp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where
   278   by (simp add: irrefl_def)
   279   "irreflp \<equiv> irreflp_on UNIV"
   279 
   280 
   280 lemma irreflpI [intro?]: "(\<And>a. \<not> R a a) \<Longrightarrow> irreflp R"
   281 lemma irrefl_def[no_atp]: "irrefl r \<longleftrightarrow> (\<forall>a. (a, a) \<notin> r)"
   281   by (fact irreflI [to_pred])
   282   by (simp add: irrefl_on_def)
       
   283 
       
   284 lemma irreflp_def[no_atp]: "irreflp R \<longleftrightarrow> (\<forall>a. \<not> R a a)"
       
   285   by (simp add: irreflp_on_def)
       
   286 
       
   287 text \<open>@{thm [source] irrefl_def} and @{thm [source] irreflp_def} are for backward compatibility.\<close>
       
   288 
       
   289 lemma irreflp_on_irrefl_on_eq [pred_set_conv]: "irreflp_on A (\<lambda>a b. (a, b) \<in> r) \<longleftrightarrow> irrefl_on A r"
       
   290   by (simp add: irrefl_on_def irreflp_on_def)
       
   291 
       
   292 lemmas irreflp_irrefl_eq = irreflp_on_irrefl_on_eq[of UNIV]
       
   293 
       
   294 lemma irrefl_onI: "(\<And>a. a \<in> A \<Longrightarrow> (a, a) \<notin> r) \<Longrightarrow> irrefl_on A r"
       
   295   by (simp add: irrefl_on_def)
       
   296 
       
   297 lemma irreflI[intro?]: "(\<And>a. (a, a) \<notin> r) \<Longrightarrow> irrefl r"
       
   298   by (rule irrefl_onI[of UNIV, simplified])
       
   299 
       
   300 lemma irreflp_onI: "(\<And>a. a \<in> A \<Longrightarrow> \<not> R a a) \<Longrightarrow> irreflp_on A R"
       
   301   by (simp add: irreflp_on_def)
       
   302 
       
   303 lemma irreflpI[intro?]: "(\<And>a. \<not> R a a) \<Longrightarrow> irreflp R"
       
   304   by (rule irreflp_onI[of UNIV, simplified])
       
   305 
       
   306 lemma irrefl_onD: "irrefl_on A r \<Longrightarrow> a \<in> A \<Longrightarrow> (a, a) \<notin> r"
       
   307   by (simp add: irrefl_on_def)
   282 
   308 
   283 lemma irreflD: "irrefl r \<Longrightarrow> (x, x) \<notin> r"
   309 lemma irreflD: "irrefl r \<Longrightarrow> (x, x) \<notin> r"
   284   unfolding irrefl_def by simp
   310   by (rule irrefl_onD[of UNIV, simplified])
       
   311 
       
   312 lemma irreflp_onD: "irreflp_on A R \<Longrightarrow> a \<in> A \<Longrightarrow> \<not> R a a"
       
   313   by (simp add: irreflp_on_def)
   285 
   314 
   286 lemma irreflpD: "irreflp R \<Longrightarrow> \<not> R x x"
   315 lemma irreflpD: "irreflp R \<Longrightarrow> \<not> R x x"
   287   unfolding irreflp_def by simp
   316   by (rule irreflp_onD[of UNIV, simplified])
   288 
   317 
   289 lemma irrefl_distinct [code]: "irrefl r \<longleftrightarrow> (\<forall>(a, b) \<in> r. a \<noteq> b)"
   318 lemma irrefl_on_distinct [code]: "irrefl_on A r \<longleftrightarrow> (\<forall>(a, b) \<in> r. a \<in> A \<longrightarrow> b \<in> A \<longrightarrow> a \<noteq> b)"
   290   by (auto simp add: irrefl_def)
   319   by (auto simp add: irrefl_on_def)
       
   320 
       
   321 lemmas irrefl_distinct = irrefl_on_distinct \<comment> \<open>For backward compatibility\<close>
   291 
   322 
   292 lemma (in preorder) irreflp_less[simp]: "irreflp (<)"
   323 lemma (in preorder) irreflp_less[simp]: "irreflp (<)"
   293   by (simp add: irreflpI)
   324   by (simp add: irreflpI)
   294 
   325 
   295 lemma (in preorder) irreflp_greater[simp]: "irreflp (>)"
   326 lemma (in preorder) irreflp_greater[simp]: "irreflp (>)"