src/HOL/Library/Executable_Set.thy
changeset 38304 df7d5143db55
parent 37595 9591362629e3
child 39141 5ec8e4404c33
equal deleted inserted replaced
38303:ad4b59e9d0f9 38304:df7d5143db55
   266   unfolding Union_def Sup_sup by simp_all
   266   unfolding Union_def Sup_sup by simp_all
   267 
   267 
   268 hide_const (open) is_empty empty remove
   268 hide_const (open) is_empty empty remove
   269   set_eq subset_eq subset inter union subtract Inf Sup Inter Union
   269   set_eq subset_eq subset inter union subtract Inf Sup Inter Union
   270 
   270 
       
   271 
       
   272 subsection {* Operations on relations *}
       
   273 
       
   274 text {* Initially contributed by Tjark Weber. *}
       
   275 
       
   276 lemma bounded_Collect_code [code_unfold]:
       
   277   "{x\<in>S. P x} = project P S"
       
   278   by (auto simp add: project_def)
       
   279 
       
   280 lemma Id_on_code [code]:
       
   281   "Id_on (Set xs) = Set [(x,x). x \<leftarrow> xs]"
       
   282   by (auto simp add: Id_on_def)
       
   283 
       
   284 lemma Domain_fst [code]:
       
   285   "Domain r = fst ` r"
       
   286   by (auto simp add: image_def Bex_def)
       
   287 
       
   288 lemma Range_snd [code]:
       
   289   "Range r = snd ` r"
       
   290   by (auto simp add: image_def Bex_def)
       
   291 
       
   292 lemma irrefl_code [code]:
       
   293   "irrefl r \<longleftrightarrow> (\<forall>(x, y)\<in>r. x \<noteq> y)"
       
   294   by (auto simp add: irrefl_def)
       
   295 
       
   296 lemma trans_def [code]:
       
   297   "trans r \<longleftrightarrow> (\<forall>(x, y1)\<in>r. \<forall>(y2, z)\<in>r. y1 = y2 \<longrightarrow> (x, z)\<in>r)"
       
   298   by (auto simp add: trans_def)
       
   299 
       
   300 definition "exTimes A B = Sigma A (%_. B)"
       
   301 
       
   302 lemma [code_unfold]:
       
   303   "Sigma A (%_. B) = exTimes A B"
       
   304   by (simp add: exTimes_def)
       
   305 
       
   306 lemma exTimes_code [code]:
       
   307   "exTimes (Set xs) (Set ys) = Set [(x,y). x \<leftarrow> xs, y \<leftarrow> ys]"
       
   308   by (auto simp add: exTimes_def)
       
   309 
       
   310 lemma rel_comp_code [code]:
       
   311   "(Set xys) O (Set yzs) = Set (remdups [(fst xy, snd yz). xy \<leftarrow> xys, yz \<leftarrow> yzs, snd xy = fst yz])"
       
   312  by (auto simp add: Bex_def)
       
   313 
       
   314 lemma acyclic_code [code]:
       
   315   "acyclic r = irrefl (r^+)"
       
   316   by (simp add: acyclic_def irrefl_def)
       
   317 
       
   318 lemma wf_code [code]:
       
   319   "wf (Set xs) = acyclic (Set xs)"
       
   320   by (simp add: wf_iff_acyclic_if_finite)
       
   321 
   271 end
   322 end