equal
deleted
inserted
replaced
1 (* Title: HOL/Relation.thy |
1 (* Title: HOL/Relation.thy |
2 ID: $Id$ |
|
3 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
2 Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
4 Copyright 1996 University of Cambridge |
3 Copyright 1996 University of Cambridge |
5 *) |
4 *) |
6 |
5 |
7 header {* Relations *} |
6 header {* Relations *} |
8 |
7 |
9 theory Relation |
8 theory Relation |
10 imports Product_Type |
9 imports Datatype Finite_Set |
11 begin |
10 begin |
12 |
11 |
13 subsection {* Definitions *} |
12 subsection {* Definitions *} |
14 |
13 |
15 definition |
14 definition |
376 lemma Domain_mono: "r \<subseteq> s ==> Domain r \<subseteq> Domain s" |
375 lemma Domain_mono: "r \<subseteq> s ==> Domain r \<subseteq> Domain s" |
377 by blast |
376 by blast |
378 |
377 |
379 lemma fst_eq_Domain: "fst ` R = Domain R"; |
378 lemma fst_eq_Domain: "fst ` R = Domain R"; |
380 by (auto intro!:image_eqI) |
379 by (auto intro!:image_eqI) |
|
380 |
|
381 lemma Domain_dprod [simp]: "Domain (dprod r s) = uprod (Domain r) (Domain s)" |
|
382 by auto |
|
383 |
|
384 lemma Domain_dsum [simp]: "Domain (dsum r s) = usum (Domain r) (Domain s)" |
|
385 by auto |
381 |
386 |
382 |
387 |
383 subsection {* Range *} |
388 subsection {* Range *} |
384 |
389 |
385 lemma Range_iff: "(a : Range r) = (EX y. (y, a) : r)" |
390 lemma Range_iff: "(a : Range r) = (EX y. (y, a) : r)" |
564 apply (simp (no_asm)) |
569 apply (simp (no_asm)) |
565 apply blast |
570 apply blast |
566 done |
571 done |
567 |
572 |
568 |
573 |
|
574 subsection {* Finiteness *} |
|
575 |
|
576 lemma finite_converse [iff]: "finite (r^-1) = finite r" |
|
577 apply (subgoal_tac "r^-1 = (%(x,y). (y,x))`r") |
|
578 apply simp |
|
579 apply (rule iffI) |
|
580 apply (erule finite_imageD [unfolded inj_on_def]) |
|
581 apply (simp split add: split_split) |
|
582 apply (erule finite_imageI) |
|
583 apply (simp add: converse_def image_def, auto) |
|
584 apply (rule bexI) |
|
585 prefer 2 apply assumption |
|
586 apply simp |
|
587 done |
|
588 |
|
589 text {* \paragraph{Finiteness of transitive closure} (Thanks to Sidi |
|
590 Ehmety) *} |
|
591 |
|
592 lemma finite_Field: "finite r ==> finite (Field r)" |
|
593 -- {* A finite relation has a finite field (@{text "= domain \<union> range"}. *} |
|
594 apply (induct set: finite) |
|
595 apply (auto simp add: Field_def Domain_insert Range_insert) |
|
596 done |
|
597 |
|
598 |
569 subsection {* Version of @{text lfp_induct} for binary relations *} |
599 subsection {* Version of @{text lfp_induct} for binary relations *} |
570 |
600 |
571 lemmas lfp_induct2 = |
601 lemmas lfp_induct2 = |
572 lfp_induct_set [of "(a, b)", split_format (complete)] |
602 lfp_induct_set [of "(a, b)", split_format (complete)] |
573 |
603 |