diff --git a/thys/Ordered_Resolution_Prover/Herbrand_Interpretation.thy b/thys/Ordered_Resolution_Prover/Herbrand_Interpretation.thy --- a/thys/Ordered_Resolution_Prover/Herbrand_Interpretation.thy +++ b/thys/Ordered_Resolution_Prover/Herbrand_Interpretation.thy @@ -1,137 +1,143 @@ (* Title: Herbrand Interpretation Author: Jasmin Blanchette , 2014, 2017 Author: Dmitriy Traytel , 2014 Maintainer: Jasmin Blanchette *) section \Herbrand Intepretation\ theory Herbrand_Interpretation imports Clausal_Logic begin text \ The material formalized here corresponds roughly to Sections 2.2 (``Herbrand Interpretations'') of Bachmair and Ganzinger, excluding the formula and term syntax. A Herbrand interpretation is a set of ground atoms that are to be considered true. \ type_synonym 'a interp = "'a set" definition true_lit :: "'a interp \ 'a literal \ bool" (infix "\l" 50) where "I \l L \ (if is_pos L then (\P. P) else Not) (atm_of L \ I)" lemma true_lit_simps[simp]: "I \l Pos A \ A \ I" "I \l Neg A \ A \ I" unfolding true_lit_def by auto lemma true_lit_iff[iff]: "I \l L \ (\A. L = Pos A \ A \ I \ L = Neg A \ A \ I)" by (cases L) simp+ definition true_cls :: "'a interp \ 'a clause \ bool" (infix "\" 50) where "I \ C \ (\L \# C. I \l L)" lemma true_cls_empty[iff]: "\ I \ {#}" unfolding true_cls_def by simp lemma true_cls_singleton[iff]: "I \ {#L#} \ I \l L" unfolding true_cls_def by simp lemma true_cls_add_mset[iff]: "I \ add_mset C D \ I \l C \ I \ D" unfolding true_cls_def by auto lemma true_cls_union[iff]: "I \ C + D \ I \ C \ I \ D" unfolding true_cls_def by auto lemma true_cls_mono: "set_mset C \ set_mset D \ I \ C \ I \ D" unfolding true_cls_def subset_eq by metis lemma assumes "I \ J" shows false_to_true_imp_ex_pos: "\ I \ C \ J \ C \ \A \ J. Pos A \# C" and true_to_false_imp_ex_neg: "I \ C \ \ J \ C \ \A \ J. Neg A \# C" using assms unfolding subset_iff true_cls_def by (metis literal.collapse true_lit_simps)+ lemma true_cls_replicate_mset[iff]: "I \ replicate_mset n L \ n \ 0 \ I \l L" by (simp add: true_cls_def) lemma pos_literal_in_imp_true_cls[intro]: "Pos A \# C \ A \ I \ I \ C" using true_cls_def by blast lemma neg_literal_notin_imp_true_cls[intro]: "Neg A \# C \ A \ I \ I \ C" using true_cls_def by blast lemma pos_neg_in_imp_true: "Pos A \# C \ Neg A \# C \ I \ C" using true_cls_def by blast definition true_clss :: "'a interp \ 'a clause set \ bool" (infix "\s" 50) where "I \s CC \ (\C \ CC. I \ C)" lemma true_clss_empty[iff]: "I \s {}" by (simp add: true_clss_def) lemma true_clss_singleton[iff]: "I \s {C} \ I \ C" unfolding true_clss_def by blast lemma true_clss_insert[iff]: "I \s insert C DD \ I \ C \ I \s DD" unfolding true_clss_def by blast lemma true_clss_union[iff]: "I \s CC \ DD \ I \s CC \ I \s DD" unfolding true_clss_def by blast +lemma true_clss_Union[iff]: "I \s \ CCC \ (\CC \ CCC. I \s CC)" + unfolding true_clss_def by simp + lemma true_clss_mono: "DD \ CC \ I \s CC \ I \s DD" by (simp add: subsetD true_clss_def) lemma true_clss_mono_strong: "(\D \ DD. \C \ CC. C \# D) \ I \s CC \ I \s DD" unfolding true_clss_def true_cls_def true_lit_def by (meson mset_subset_eqD) lemma true_clss_subclause: "C \# D \ I \s {C} \ I \s {D}" by (rule true_clss_mono_strong[of _ "{C}"]) auto abbreviation satisfiable :: "'a clause set \ bool" where "satisfiable CC \ \I. I \s CC" lemma satisfiable_antimono: "CC \ DD \ satisfiable DD \ satisfiable CC" using true_clss_mono by blast lemma unsatisfiable_mono: "CC \ DD \ \ satisfiable CC \ \ satisfiable DD" using satisfiable_antimono by blast definition true_cls_mset :: "'a interp \ 'a clause multiset \ bool" (infix "\m" 50) where "I \m CC \ (\C \# CC. I \ C)" lemma true_cls_mset_empty[iff]: "I \m {#}" unfolding true_cls_mset_def by auto lemma true_cls_mset_singleton[iff]: "I \m {#C#} \ I \ C" by (simp add: true_cls_mset_def) lemma true_cls_mset_union[iff]: "I \m CC + DD \ I \m CC \ I \m DD" unfolding true_cls_mset_def by auto +lemma true_cls_mset_Union[iff]: "I \m \# CCC \ (\CC \# CCC. I \m CC)" + unfolding true_cls_mset_def by simp + lemma true_cls_mset_add_mset[iff]: "I \m add_mset C CC \ I \ C \ I \m CC" unfolding true_cls_mset_def by auto lemma true_cls_mset_image_mset[iff]: "I \m image_mset f A \ (\x \# A. I \ f x)" unfolding true_cls_mset_def by auto lemma true_cls_mset_mono: "set_mset DD \ set_mset CC \ I \m CC \ I \m DD" unfolding true_cls_mset_def subset_iff by auto lemma true_cls_mset_mono_strong: "(\D \# DD. \C \# CC. C \# D) \ I \m CC \ I \m DD" unfolding true_cls_mset_def true_cls_def true_lit_def by (meson mset_subset_eqD) lemma true_clss_set_mset[iff]: "I \s set_mset CC \ I \m CC" unfolding true_clss_def true_cls_mset_def by auto lemma true_clss_mset_set[simp]: "finite CC \ I \m mset_set CC \ I \s CC" unfolding true_clss_def true_cls_mset_def by auto lemma true_cls_mset_true_cls: "I \m CC \ C \# CC \ I \ C" using true_cls_mset_def by auto end diff --git a/thys/Ordered_Resolution_Prover/Lazy_List_Liminf.thy b/thys/Ordered_Resolution_Prover/Lazy_List_Liminf.thy --- a/thys/Ordered_Resolution_Prover/Lazy_List_Liminf.thy +++ b/thys/Ordered_Resolution_Prover/Lazy_List_Liminf.thy @@ -1,161 +1,165 @@ (* Title: Liminf of Lazy Lists Author: Jasmin Blanchette , 2014, 2017 Author: Dmitriy Traytel , 2014 Maintainer: Jasmin Blanchette *) section \Liminf of Lazy Lists\ theory Lazy_List_Liminf imports Coinductive.Coinductive_List begin text \ Lazy lists, as defined in the \emph{Archive of Formal Proofs}, provide finite and infinite lists in one type, defined coinductively. The present theory introduces the concept of the union of all elements of a lazy list of sets and the limit of such a lazy list. The definitions are stated more generally in terms of lattices. The basis for this theory is Section 4.1 (``Theorem Proving Processes'') of Bachmair and Ganzinger's chapter. \ definition Sup_llist :: "'a set llist \ 'a set" where "Sup_llist Xs = (\i \ {i. enat i < llength Xs}. lnth Xs i)" lemma lnth_subset_Sup_llist: "enat i < llength xs \ lnth xs i \ Sup_llist xs" unfolding Sup_llist_def by auto lemma Sup_llist_LNil[simp]: "Sup_llist LNil = {}" unfolding Sup_llist_def by auto lemma Sup_llist_LCons[simp]: "Sup_llist (LCons X Xs) = X \ Sup_llist Xs" unfolding Sup_llist_def proof (intro subset_antisym subsetI) fix x assume "x \ (\i \ {i. enat i < llength (LCons X Xs)}. lnth (LCons X Xs) i)" then obtain i where len: "enat i < llength (LCons X Xs)" and nth: "x \ lnth (LCons X Xs) i" by blast from nth have "x \ X \ i > 0 \ x \ lnth Xs (i - 1)" by (metis lnth_LCons' neq0_conv) then have "x \ X \ (\i. enat i < llength Xs \ x \ lnth Xs i)" by (metis len Suc_pred' eSuc_enat iless_Suc_eq less_irrefl llength_LCons not_less order_trans) then show "x \ X \ (\i \ {i. enat i < llength Xs}. lnth Xs i)" by blast qed ((auto)[], metis i0_lb lnth_0 zero_enat_def, metis Suc_ile_eq lnth_Suc_LCons) lemma lhd_subset_Sup_llist: "\ lnull Xs \ lhd Xs \ Sup_llist Xs" by (cases Xs) simp_all definition Sup_upto_llist :: "'a set llist \ nat \ 'a set" where "Sup_upto_llist Xs j = (\i \ {i. enat i < llength Xs \ i \ j}. lnth Xs i)" lemma Sup_upto_llist_0[simp]: "Sup_upto_llist Xs 0 = (if 0 < llength Xs then lnth Xs 0 else {})" unfolding Sup_upto_llist_def image_def by (simp add: enat_0) lemma Sup_upto_llist_Suc[simp]: "Sup_upto_llist Xs (Suc j) = Sup_upto_llist Xs j \ (if enat (Suc j) < llength Xs then lnth Xs (Suc j) else {})" unfolding Sup_upto_llist_def image_def by (auto intro: le_SucI elim: le_SucE) lemma Sup_upto_llist_mono: "j \ k \ Sup_upto_llist Xs j \ Sup_upto_llist Xs k" unfolding Sup_upto_llist_def by auto lemma Sup_upto_llist_subset_Sup_llist: "j \ k \ Sup_upto_llist Xs j \ Sup_llist Xs" unfolding Sup_llist_def Sup_upto_llist_def by auto lemma elem_Sup_llist_imp_Sup_upto_llist: "x \ Sup_llist Xs \ \j < llength Xs. x \ Sup_upto_llist Xs j" unfolding Sup_llist_def Sup_upto_llist_def by blast lemma lnth_subset_Sup_upto_llist: "enat j < llength Xs \ lnth Xs j \ Sup_upto_llist Xs j" unfolding Sup_upto_llist_def by auto lemma finite_Sup_llist_imp_Sup_upto_llist: assumes "finite X" and "X \ Sup_llist Xs" shows "\k. X \ Sup_upto_llist Xs k" using assms proof induct case (insert x X) then have x: "x \ Sup_llist Xs" and X: "X \ Sup_llist Xs" by simp+ from x obtain k where k: "x \ Sup_upto_llist Xs k" using elem_Sup_llist_imp_Sup_upto_llist by fast from X obtain k' where k': "X \ Sup_upto_llist Xs k'" using insert.hyps(3) by fast have "insert x X \ Sup_upto_llist Xs (max k k')" using k k' by (metis insert_absorb insert_subset Sup_upto_llist_mono max.cobounded2 max.commute order.trans) then show ?case by fast qed simp definition Liminf_llist :: "'a set llist \ 'a set" where "Liminf_llist Xs = (\i \ {i. enat i < llength Xs}. \j \ {j. i \ j \ enat j < llength Xs}. lnth Xs j)" lemma Liminf_llist_LNil[simp]: "Liminf_llist LNil = {}" unfolding Liminf_llist_def by simp lemma Liminf_llist_LCons: "Liminf_llist (LCons X Xs) = (if lnull Xs then X else Liminf_llist Xs)" (is "?lhs = ?rhs") proof (cases "lnull Xs") case nnull: False show ?thesis proof { fix x assume "\i. enat i \ llength Xs \ (\j. i \ j \ enat j \ llength Xs \ x \ lnth (LCons X Xs) j)" then have "\i. enat (Suc i) \ llength Xs \ (\j. Suc i \ j \ enat j \ llength Xs \ x \ lnth (LCons X Xs) j)" by (cases "llength Xs", metis not_lnull_conv[THEN iffD1, OF nnull] Suc_le_D eSuc_enat eSuc_ile_mono llength_LCons not_less_eq_eq zero_enat_def zero_le, metis Suc_leD enat_ord_code(3)) then have "\i. enat i < llength Xs \ (\j. i \ j \ enat j < llength Xs \ x \ lnth Xs j)" by (metis Suc_ile_eq Suc_n_not_le_n lift_Suc_mono_le lnth_Suc_LCons nat_le_linear) } then show "?lhs \ ?rhs" by (simp add: Liminf_llist_def nnull) (rule subsetI, simp) { fix x assume "\i. enat i < llength Xs \ (\j. i \ j \ enat j < llength Xs \ x \ lnth Xs j)" then obtain i where i: "enat i < llength Xs" and j: "\j. i \ j \ enat j < llength Xs \ x \ lnth Xs j" by blast have "enat (Suc i) \ llength Xs" using i by (simp add: Suc_ile_eq) moreover have "\j. Suc i \ j \ enat j \ llength Xs \ x \ lnth (LCons X Xs) j" using Suc_ile_eq Suc_le_D j by force ultimately have "\i. enat i \ llength Xs \ (\j. i \ j \ enat j \ llength Xs \ x \ lnth (LCons X Xs) j)" by blast } then show "?rhs \ ?lhs" by (simp add: Liminf_llist_def nnull) (rule subsetI, simp) qed qed (simp add: Liminf_llist_def enat_0_iff(1)) lemma lfinite_Liminf_llist: "lfinite Xs \ Liminf_llist Xs = (if lnull Xs then {} else llast Xs)" proof (induction rule: lfinite_induct) case (LCons xs) then obtain y ys where xs: "xs = LCons y ys" by (meson not_lnull_conv) show ?case unfolding xs by (simp add: Liminf_llist_LCons LCons.IH[unfolded xs, simplified] llast_LCons) qed (simp add: Liminf_llist_def) lemma Liminf_llist_ltl: "\ lnull (ltl Xs) \ Liminf_llist Xs = Liminf_llist (ltl Xs)" by (metis Liminf_llist_LCons lhd_LCons_ltl lnull_ltlI) lemma Liminf_llist_subset_Sup_llist: "Liminf_llist Xs \ Sup_llist Xs" unfolding Liminf_llist_def Sup_llist_def by fast lemma image_Liminf_llist_subset: "f ` Liminf_llist Ns \ Liminf_llist (lmap ((`) f) Ns)" unfolding Liminf_llist_def by auto +lemma Liminf_llist_imp_exists_index: + "x \ Liminf_llist Xs \ \i. enat i < llength Xs \ x \ lnth Xs i" + unfolding Liminf_llist_def by auto + end