740 from `finite A` show ?thesis by (induct A arbitrary: B) simp_all |
740 from `finite A` show ?thesis by (induct A arbitrary: B) simp_all |
741 qed |
741 qed |
742 |
742 |
743 lemma minus_fold_remove: |
743 lemma minus_fold_remove: |
744 assumes "finite A" |
744 assumes "finite A" |
745 shows "B - A = fold (\<lambda>x A. A - {x}) B A" |
745 shows "B - A = fold Set.remove B A" |
746 proof - |
746 proof - |
747 interpret comp_fun_idem "\<lambda>x A. A - {x}" by (fact comp_fun_idem_remove) |
747 interpret comp_fun_idem Set.remove by (fact comp_fun_idem_remove) |
748 from `finite A` show ?thesis by (induct A arbitrary: B) auto |
748 from `finite A` have "fold Set.remove B A = B - A" by (induct A arbitrary: B) auto |
|
749 then show ?thesis .. |
749 qed |
750 qed |
750 |
751 |
751 context complete_lattice |
752 context complete_lattice |
752 begin |
753 begin |
753 |
754 |
777 lemma Sup_fold_sup: |
778 lemma Sup_fold_sup: |
778 assumes "finite A" |
779 assumes "finite A" |
779 shows "Sup A = fold sup bot A" |
780 shows "Sup A = fold sup bot A" |
780 using assms sup_Sup_fold_sup [of A bot] by (simp add: sup_absorb2) |
781 using assms sup_Sup_fold_sup [of A bot] by (simp add: sup_absorb2) |
781 |
782 |
782 lemma inf_INFI_fold_inf: |
783 lemma inf_INF_fold_inf: |
783 assumes "finite A" |
784 assumes "finite A" |
784 shows "inf B (INFI A f) = fold (inf \<circ> f) B A" (is "?inf = ?fold") |
785 shows "inf B (INFI A f) = fold (inf \<circ> f) B A" (is "?inf = ?fold") |
785 proof (rule sym) |
786 proof (rule sym) |
786 interpret comp_fun_idem inf by (fact comp_fun_idem_inf) |
787 interpret comp_fun_idem inf by (fact comp_fun_idem_inf) |
787 interpret comp_fun_idem "inf \<circ> f" by (fact comp_comp_fun_idem) |
788 interpret comp_fun_idem "inf \<circ> f" by (fact comp_comp_fun_idem) |
788 from `finite A` show "?fold = ?inf" |
789 from `finite A` show "?fold = ?inf" |
789 by (induct A arbitrary: B) |
790 by (induct A arbitrary: B) |
790 (simp_all add: INF_def inf_left_commute) |
791 (simp_all add: INF_def inf_left_commute) |
791 qed |
792 qed |
792 |
793 |
793 lemma sup_SUPR_fold_sup: |
794 lemma sup_SUP_fold_sup: |
794 assumes "finite A" |
795 assumes "finite A" |
795 shows "sup B (SUPR A f) = fold (sup \<circ> f) B A" (is "?sup = ?fold") |
796 shows "sup B (SUPR A f) = fold (sup \<circ> f) B A" (is "?sup = ?fold") |
796 proof (rule sym) |
797 proof (rule sym) |
797 interpret comp_fun_idem sup by (fact comp_fun_idem_sup) |
798 interpret comp_fun_idem sup by (fact comp_fun_idem_sup) |
798 interpret comp_fun_idem "sup \<circ> f" by (fact comp_comp_fun_idem) |
799 interpret comp_fun_idem "sup \<circ> f" by (fact comp_comp_fun_idem) |
799 from `finite A` show "?fold = ?sup" |
800 from `finite A` show "?fold = ?sup" |
800 by (induct A arbitrary: B) |
801 by (induct A arbitrary: B) |
801 (simp_all add: SUP_def sup_left_commute) |
802 (simp_all add: SUP_def sup_left_commute) |
802 qed |
803 qed |
803 |
804 |
804 lemma INFI_fold_inf: |
805 lemma INF_fold_inf: |
805 assumes "finite A" |
806 assumes "finite A" |
806 shows "INFI A f = fold (inf \<circ> f) top A" |
807 shows "INFI A f = fold (inf \<circ> f) top A" |
807 using assms inf_INFI_fold_inf [of A top] by simp |
808 using assms inf_INF_fold_inf [of A top] by simp |
808 |
809 |
809 lemma SUPR_fold_sup: |
810 lemma SUP_fold_sup: |
810 assumes "finite A" |
811 assumes "finite A" |
811 shows "SUPR A f = fold (sup \<circ> f) bot A" |
812 shows "SUPR A f = fold (sup \<circ> f) bot A" |
812 using assms sup_SUPR_fold_sup [of A bot] by simp |
813 using assms sup_SUP_fold_sup [of A bot] by simp |
813 |
814 |
814 end |
815 end |
815 |
816 |
816 |
817 |
817 subsection {* The derived combinator @{text fold_image} *} |
818 subsection {* The derived combinator @{text fold_image} *} |
2064 |
2065 |
2065 lemma finite_fun_UNIVD2: |
2066 lemma finite_fun_UNIVD2: |
2066 assumes fin: "finite (UNIV :: ('a \<Rightarrow> 'b) set)" |
2067 assumes fin: "finite (UNIV :: ('a \<Rightarrow> 'b) set)" |
2067 shows "finite (UNIV :: 'b set)" |
2068 shows "finite (UNIV :: 'b set)" |
2068 proof - |
2069 proof - |
2069 from fin have "finite (range (\<lambda>f :: 'a \<Rightarrow> 'b. f arbitrary))" |
2070 from fin have "\<And>arbitrary. finite (range (\<lambda>f :: 'a \<Rightarrow> 'b. f arbitrary))" |
2070 by(rule finite_imageI) |
2071 by (rule finite_imageI) |
2071 moreover have "UNIV = range (\<lambda>f :: 'a \<Rightarrow> 'b. f arbitrary)" |
2072 moreover have "\<And>arbitrary. UNIV = range (\<lambda>f :: 'a \<Rightarrow> 'b. f arbitrary)" |
2072 by(rule UNIV_eq_I) auto |
2073 by (rule UNIV_eq_I) auto |
2073 ultimately show "finite (UNIV :: 'b set)" by simp |
2074 ultimately show "finite (UNIV :: 'b set)" by simp |
2074 qed |
2075 qed |
2075 |
2076 |
2076 lemma card_UNIV_unit: "card (UNIV :: unit set) = 1" |
2077 lemma card_UNIV_unit: "card (UNIV :: unit set) = 1" |
2077 unfolding UNIV_unit by simp |
2078 unfolding UNIV_unit by simp |