Theory Set_Proc
theory Set_Proc
imports Realisation HF_Extras Set_Semantics Typing
begin
chapter βΉA Decision Procedure for MLSSβΊ
text βΉ
This theory proves the soundness and completeness of the
tableau calculus defined in πβΉ./Set_Calculus.thyβΊ
It then lifts those properties to a recursive procedure
that applies the rules of the calculus exhaustively.
To obtain a decision procedure, we also prove termination.
βΊ
section βΉBasic DefinitionsβΊ
definition "lin_sat b β‘ βb'. lexpands b' b βΆ set b' β set b"
lemma lin_satD:
assumes "lin_sat b"
assumes "lexpands b' b"
assumes "x β set b'"
shows "x β set b"
using assms unfolding lin_sat_def by auto
lemma not_lin_satD: "Β¬ lin_sat b βΉ βb'. lexpands b' b β§ set b β set (b' @ b)"
unfolding lin_sat_def by auto
definition "sat b β‘ lin_sat b β§ (βbs'. bexpands bs' b)"
lemma satD:
assumes "sat b"
shows "lin_sat b" "βbs'. bexpands bs' b"
using assms unfolding sat_def by auto
definition wits :: "'a branch β 'a set" where
"wits b β‘ vars b - vars (last b)"
definition pwits :: "'a branch β 'a set" where
"pwits b β‘ {c β wits b. βt β subterms (last b).
AT (Var c =β©s t) β set b β§ AT (t =β©s Var c) β set b}"
lemma wits_singleton[simp]: "wits [Ο] = {}"
unfolding wits_def vars_branch_simps by simp
lemma pwits_singleton[simp]: "pwits [Ο] = {}"
unfolding pwits_def by auto
lemma pwitsD:
assumes "c β pwits b"
shows "c β wits b"
"t β subterms (last b) βΉ AT (Var c =β©s t) β set b"
"t β subterms (last b) βΉ AT (t =β©s Var c) β set b"
using assms unfolding pwits_def by auto
lemma pwitsI:
assumes "c β wits b"
assumes "βt. t β subterms (last b) βΉ AT (Var c =β©s t) β set b"
assumes "βt. t β subterms (last b) βΉ AT (t =β©s Var c) β set b"
shows "c β pwits b"
using assms unfolding pwits_def by blast
lemma finite_wits: "finite (wits b)"
unfolding wits_def using finite_vars_branch by auto
lemma finite_pwits: "finite (pwits b)"
proof -
have "pwits b β wits b"
unfolding pwits_def by simp
then show ?thesis using finite_wits finite_subset by blast
qed
lemma lexpands_subterms_branch_eq:
"lexpands b' b βΉ b β [] βΉ subterms (b' @ b) = subterms b"
proof(induction rule: lexpands.induct)
case (1 b' b)
then show ?case
apply(induction rule: lexpands_fm.induct)
apply(auto simp: subterms_branch_def)
done
next
case (2 b' b)
then show ?case
apply(induction rule: lexpands_un.induct)
using subterms_branch_subterms_subterms_fm_trans[OF _ subterms_refl]
apply(auto simp: subterms_branch_simps
intro: subterms_term_subterms_branch_trans
dest: subterms_branchD AT_mem_subterms_branchD AF_mem_subterms_branchD)
done
next
case (3 b' b)
then show ?case
apply(induction rule: lexpands_int.induct)
using subterms_branch_subterms_subterms_fm_trans[OF _ subterms_refl]
apply(auto simp: subterms_branch_simps
intro: subterms_term_subterms_branch_trans
dest: subterms_branchD AT_mem_subterms_branchD AF_mem_subterms_branchD)
done
next
case (4 b' b)
then show ?case
apply(induction rule: lexpands_diff.induct)
using subterms_branch_subterms_subterms_fm_trans[OF _ subterms_refl]
apply(auto simp: subterms_branch_simps
intro: subterms_term_subterms_branch_trans
dest: subterms_branchD AT_mem_subterms_branchD AF_mem_subterms_branchD)
done
next
case (5 b' b)
then show ?case
proof(induction rule: lexpands_single.induct)
case (1 t1 b)
then show ?case
using subterms_branch_subterms_subterms_fm_trans[OF _ subterms_refl]
apply(auto simp: subterms_branch_simps
dest: subterms_fmD intro: subterms_term_subterms_branch_trans)
done
qed (auto simp: subterms_branch_simps subterms_term_subterms_atom_Atom_trans
dest: subterms_branchD AF_mem_subterms_branchD
intro: subterms_term_subterms_branch_trans)
next
case (6 b' b)
have *: "subterms_atom (subst_tlvl t1 t2 a) β subterms t2 βͺ subterms_atom a"
for t1 t2 and a :: "'a pset_atom"
by (cases "(t1, t2, a)" rule: subst_tlvl.cases) auto
from 6 show ?case
by (induction rule: lexpands_eq.induct)
(auto simp: subterms_branch_def subterms_term_subterms_atom_Atom_trans
dest!: subsetD[OF *])
qed
lemma lexpands_vars_branch_eq:
"lexpands b' b βΉ b β [] βΉ vars (b' @ b) = vars b"
using lexpands_subterms_branch_eq subterms_branch_eq_if_vars_branch_eq by metis
lemma bexpands_nowit_subterms_branch_eq:
"bexpands_nowit bs' b βΉ b' β bs' βΉ b β [] βΉ subterms (b' @ b) = subterms b"
proof(induction rule: bexpands_nowit.induct)
case (3 s t1 t2 b)
then show ?case
by (auto simp: subterms_term_subterms_atom_Atom_trans subterms_branch_simps)
next
case (4 s t1 b t2)
then show ?case
using subterms_branch_subterms_subterms_fm_trans[OF _ _ "4"(2)]
by (auto simp: subterms_term_subterms_atom_Atom_trans subterms_branch_simps)
next
case (5 s t1 b t2)
then show ?case
using subterms_branch_subterms_subterms_fm_trans[OF _ _ "5"(2)]
by (auto simp: subterms_term_subterms_atom_Atom_trans subterms_branch_simps)
qed (use subterms_branch_def in βΉ(fastforce simp: subterms_branch_simps)+βΊ)
lemma bexpands_nowit_vars_branch_eq:
"bexpands_nowit bs' b βΉ b' β bs' βΉ b β [] βΉ vars (b' @ b) = vars b"
using bexpands_nowit_subterms_branch_eq subterms_branch_eq_if_vars_branch_eq by metis
lemma lexpands_wits_eq:
"lexpands b' b βΉ b β [] βΉ wits (b' @ b) = wits b"
using lexpands_vars_branch_eq unfolding wits_def by force
lemma bexpands_nowit_wits_eq:
assumes "bexpands_nowit bs' b" "b' β bs'" "b β []"
shows "wits (b' @ b) = wits b"
using bexpands_nowit_vars_branch_eq[OF assms] assms(3)
unfolding wits_def by simp
lemma bexpands_wit_vars_branch_eq:
assumes "bexpands_wit t1 t2 x bs' b" "b' β bs'" "b β []"
shows "vars (b' @ b) = insert x (vars b)"
using assms bexpands_witD[OF assms(1)]
by (auto simp: mem_vars_fm_if_mem_subterms_fm vars_branch_simps vars_fm_vars_branchI)
lemma bexpands_wit_wits_eq:
assumes "bexpands_wit t1 t2 x bs' b" "b' β bs'" "b β []"
shows "wits (b' @ b) = insert x (wits b)"
using assms bexpands_witD[OF assms(1)]
unfolding wits_def
by (auto simp: mem_vars_fm_if_mem_subterms_fm vars_branch_simps vars_branch_def)
lemma lexpands_pwits_subs:
assumes "lexpands b' b" "b β []"
shows "pwits (b' @ b) β pwits b"
using assms lexpands_wits_eq[OF assms]
by (induction rule: lexpands_induct) (auto simp: pwits_def)
subsection βΉβΉno_new_subtermsβΊβΊ
definition "no_new_subterms b β‘
βt β subterms b. t β Var ` wits b βΆ t β subterms (last b)"
lemma no_new_subtermsI:
assumes "βt. t β subterms b βΉ t β Var ` wits b βΉ t β subterms (last b)"
shows "no_new_subterms b"
using assms unfolding no_new_subterms_def by blast
lemma Var_mem_subterms_branch_and_not_in_wits:
assumes "Var v β subterms b" "v β wits b"
shows "v β vars (last b)"
using assms unfolding wits_def no_new_subterms_def
by (auto simp: image_set_diff[unfolded inj_on_def] image_UN
Un_vars_term_subterms_branch_eq_vars_branch[symmetric])
lemma subterms_branch_cases:
assumes "t β subterms b" "t β Var ` wits b"
obtains
(Empty) n where "t = β
n"
| (Union) t1 t2 where "t = t1 ββ©s t2"
| (Inter) t1 t2 where "t = t1 ββ©s t2"
| (Diff) t1 t2 where "t = t1 -β©s t2"
| (Single) t1 where "t = Single t1"
| (Var) v where "t = Var v" "v β vars (last b)"
proof(cases t)
case (Var x)
with assms have "x β vars (last b)"
using Var_mem_subterms_branch_and_not_in_wits by (metis imageI)
with Var that show ?thesis by blast
qed (use assms that in auto)
lemma no_new_subterms_casesI[case_names Empty Union Inter Diff Single]:
assumes "βn. β
n β subterms b βΉ β
n β subterms (last b)"
assumes "βt1 t2. t1 ββ©s t2 β subterms b βΉ t1 ββ©s t2 β subterms (last b)"
assumes "βt1 t2. t1 ββ©s t2 β subterms b βΉ t1 ββ©s t2 β subterms (last b)"
assumes "βt1 t2. t1 -β©s t2 β subterms b βΉ t1 -β©s t2 β subterms (last b)"
assumes "βt. Single t β subterms b βΉ Single t β subterms (last b)"
shows "no_new_subterms b"
proof(intro no_new_subtermsI)
fix t assume "t β subterms b" "t β Var ` wits b"
with this assms show "t β subterms (last b)"
by (cases t rule: subterms_branch_cases) (auto simp: vars_fm_subs_subterms_fm)
qed
lemma no_new_subtermsD:
assumes "no_new_subterms b"
shows "βn. β
n β subterms b βΉ β
n β subterms (last b)"
"βt1 t2. t1 ββ©s t2 β subterms b βΉ t1 ββ©s t2 β subterms (last b)"
"βt1 t2. t1 ββ©s t2 β subterms b βΉ t1 ββ©s t2 β subterms (last b)"
"βt1 t2. t1 -β©s t2 β subterms b βΉ t1 -β©s t2 β subterms (last b)"
"βt. Single t β subterms b βΉ Single t β subterms (last b)"
using assms unfolding no_new_subterms_def by auto
lemma lexpands_no_new_subterms:
assumes "lexpands b' b" "b β []"
assumes "no_new_subterms b"
shows "no_new_subterms (b' @ b)"
using assms unfolding no_new_subterms_def
by (simp add: lexpands_wits_eq lexpands_subterms_branch_eq[OF assms(1,2)])
lemma subterms_branch_subterms_atomI:
assumes "Atom l β set b" "t β subterms_atom l"
shows "t β subterms_branch b"
using assms unfolding subterms_branch_def
apply (cases l rule: subterms_atom.cases)
apply (metis subterms_branch_def subterms_term_subterms_atom_Atom_trans subterms_refl)+
done
lemma bexpands_nowit_no_new_subterms:
assumes "bexpands_nowit bs' b" "b' β bs'" "b β []"
assumes "no_new_subterms b"
shows "no_new_subterms (b' @ b)"
using assms unfolding no_new_subterms_def
by (simp add: bexpands_nowit_wits_eq bexpands_nowit_subterms_branch_eq[OF assms(1,2)])
lemma bexpands_wit_no_new_subterms:
assumes "bexpands_wit t1 t2 x bs' b" "b β []" "b' β bs'"
assumes "no_new_subterms b"
shows "no_new_subterms (b' @ b)"
using assms
apply(induction rule: bexpands_wit.induct)
apply(auto simp: subterms_branch_simps
subterms_term_subterms_atom_trans subterms_term_subterms_fm_trans
elim: no_new_subtermsD
intro!: no_new_subterms_casesI)
done
lemma bexpands_no_new_subterms:
assumes "bexpands bs' b" "b β []" "b' β bs'"
assumes "no_new_subterms b"
shows "no_new_subterms (b' @ b)"
using assms
apply(cases rule: bexpands.cases)
using bexpands_nowit_no_new_subterms bexpands_wit_no_new_subterms by metis+
lemma expandss_no_new_subterms:
assumes "expandss b' b" "b β []" "no_new_subterms b"
shows "no_new_subterms b'"
using assms
apply(induction b' b rule: expandss.induct)
using expandss_suffix suffix_bot.extremum_uniqueI
using lexpands_no_new_subterms bexpands_no_new_subterms
by blast+
lemmas subterms_branch_subterms_fm_lastI =
subterms_branch_subterms_subterms_fm_trans[OF _ subterms_refl]
subsection βΉβΉwits_subtermsβΊβΊ
definition wits_subterms :: "'a branch β 'a pset_term set" where
"wits_subterms b β‘ Var ` wits b βͺ subterms (last b)"
lemma subterms_branch_eq_if_no_new_subterms:
assumes "no_new_subterms b" "b β []"
shows "subterms_branch b = wits_subterms b"
using assms no_new_subtermsD[OF assms(1)]
proof -
note simps = wits_def no_new_subterms_def wits_subterms_def
subterms_branch_simps vars_branch_simps
with assms show ?thesis
by (auto simp: simps vars_fm_subs_subterms_fm
vars_branch_subs_subterms_branch[unfolded image_subset_iff]
intro: subterms_branch_subterms_fm_lastI)
qed
lemma wits_subterms_last_disjnt: "Var ` wits b β© subterms (last b) = {}"
by (auto simp: wits_def intro!: mem_vars_fm_if_mem_subterms_fm)
section βΉCompleteness of the CalculusβΊ
subsection βΉProof of Lemma 2βΊ
fun is_literal :: "'a fm β bool" where
"is_literal (Atom _) = True"
| "is_literal (Neg (Atom _)) = True"
| "is_literal _ = False"
lemma lexpands_no_wits_if_not_literal:
defines "P β‘ (Ξ»b. βΟ β set b. Β¬ is_literal Ο βΆ vars Ο β© wits b = {})"
assumes "lexpands b' b" "b β []"
assumes "P b"
shows "P (b' @ b)"
using assms(2-) lexpands_wits_eq[OF assms(2,3)]
by (induction rule: lexpands_induct) (auto simp: disjoint_iff P_def)
lemma bexpands_nowit_no_wits_if_not_literal:
defines "P β‘ (Ξ»b. βΟ β set b. Β¬ is_literal Ο βΆ vars Ο β© wits b = {})"
assumes "bexpands_nowit bs' b" "b' β bs'" "b β []"
assumes "P b"
shows "P (b' @ b)"
using assms(2-)
by (induction rule: bexpands_nowit.induct)
(auto simp: Int_def P_def wits_def vars_fm_vars_branchI)
lemma bexpands_wit_no_wits_if_not_literal:
defines "P β‘ (Ξ»b. βΟ β set b. Β¬ is_literal Ο βΆ vars Ο β© wits b = {})"
assumes "bexpands_wit t1 t2 x bs' b" "b' β bs'" "b β []"
assumes "P b"
shows "P (b' @ b)"
using assms(2-)
by (induction rule: bexpands_wit.induct)
(auto simp: Int_def P_def wits_def vars_fm_vars_branchI)
lemma bexpands_no_wits_if_not_literal:
defines "P β‘ (Ξ»b. βΟ β set b. Β¬ is_literal Ο βΆ vars Ο β© wits b = {})"
assumes "bexpands bs' b" "b' β bs'" "b β []"
assumes "P b"
shows "P (b' @ b)"
using assms(2-)
apply(cases bs' b rule: bexpands_cases)
using bexpands_wit_no_wits_if_not_literal bexpands_nowit_no_wits_if_not_literal
using P_def by fast+
lemma expandss_no_wits_if_not_literal:
defines "P β‘ (Ξ»b. βΟ β set b. Β¬ is_literal Ο βΆ vars Ο β© wits b = {})"
assumes "expandss b' b" "b β []"
assumes "P b"
shows "P b'"
using assms(2-)
apply (induction rule: expandss.induct)
using lexpands_no_wits_if_not_literal bexpands_no_wits_if_not_literal
apply (metis P_def expandss_suffix suffix_bot.extremum_uniqueI)+
done
lemma lexpands_fm_pwits_eq:
assumes "lexpands_fm b' b" "b β []"
assumes "βΟ β set b. Β¬ is_literal Ο βΆ vars Ο β© wits b = {}"
shows "pwits (b' @ b) = pwits b"
using assms
apply(induction rule: lexpands_fm.induct)
apply(fastforce simp: pwits_def wits_def vars_branch_def)+
done
lemma lexpands_un_pwits_eq:
assumes "lexpands_un b' b" "b β []"
assumes "βc β pwits b. βt β wits_subterms b.
AT (Var c =β©s t) β set b β§ AT (t =β©s Var c) β set b β§ AT (t ββ©s Var c) β set b"
shows "pwits (b' @ b) = pwits b"
proof -
note lexpands.intros(2)[OF assms(1)]
note lexpands_wits_eq[OF this βΉb β []βΊ]
from assms this have "x β pwits (b' @ b)" if "x β pwits b" for x
using that
by (induction rule: lexpands_un.induct)
(auto simp: wits_subterms_def pwitsD intro!: pwitsI)
with lexpands_pwits_subs[OF βΉlexpands b' bβΊ βΉb β []βΊ] show ?thesis
by auto
qed
lemma lexpands_int_pwits_eq:
assumes "lexpands_int b' b" "b β []"
assumes "βc β pwits b. βt β wits_subterms b.
AT (Var c =β©s t) β set b β§ AT (t =β©s Var c) β set b β§ AT (t ββ©s Var c) β set b"
shows "pwits (b' @ b) = pwits b"
proof -
note lexpands.intros(3)[OF assms(1)]
note lexpands_wits_eq[OF this βΉb β []βΊ]
from assms this have "x β pwits (b' @ b)" if "x β pwits b" for x
using that
by (induction rule: lexpands_int.induct)
(auto simp: wits_subterms_def pwitsD intro!: pwitsI)
with lexpands_pwits_subs[OF βΉlexpands b' bβΊ βΉb β []βΊ] show ?thesis
by auto
qed
lemma lexpands_diff_pwits_eq:
assumes "lexpands_diff b' b" "b β []"
assumes "βc β pwits b. βt β wits_subterms b.
AT (Var c =β©s t) β set b β§ AT (t =β©s Var c) β set b β§ AT (t ββ©s Var c) β set b"
shows "pwits (b' @ b) = pwits b"
proof -
note lexpands.intros(4)[OF assms(1)]
note lexpands_wits_eq[OF this βΉb β []βΊ]
from assms this have "x β pwits (b' @ b)" if "x β pwits b" for x
using that
by (induction rule: lexpands_diff.induct)
(auto simp: wits_subterms_def pwitsD intro!: pwitsI)
with lexpands_pwits_subs[OF βΉlexpands b' bβΊ βΉb β []βΊ] show ?thesis
by auto
qed
lemma bexpands_nowit_pwits_eq:
assumes "bexpands_nowit bs' b" "b' β bs'" "b β []"
assumes "βΟ β set b. Β¬ is_literal Ο βΆ vars Ο β© wits b = {}"
shows "pwits (b' @ b) = pwits b"
using assms
proof -
from assms have "x β pwits (b' @ b)" if "x β pwits b" for x
using that bexpands_nowit_wits_eq[OF assms(1-3)]
by (induction rule: bexpands_nowit.induct)
(intro pwitsI; fastforce simp: pwitsD)+
moreover from assms have "pwits (b' @ b) β pwits b"
unfolding pwits_def
using bexpands_nowit_wits_eq by fastforce
ultimately show ?thesis by blast
qed
lemma bexpands_wit_pwits_eq:
assumes "bexpands_wit t1 t2 x bs' b" "b' β bs'" "b β []"
shows "pwits (b' @ b) = insert x (pwits b)"
using assms(2,3) bexpands_witD[OF assms(1)]
unfolding pwits_def bexpands_wit_wits_eq[OF assms]
by (auto simp: vars_fm_vars_branchI)
lemma lemma_2_lexpands:
defines "P β‘ (Ξ»b c t. AT (Var c =β©s t) β set b β§ AT (t =β©s Var c) β set b β§ AT (t ββ©s Var c) β set b)"
assumes "lexpands b' b" "b β []"
assumes "no_new_subterms b"
assumes "βΟ β set b. Β¬ is_literal Ο βΆ vars Ο β© wits b = {}"
assumes "βc β pwits b. βt β wits_subterms b. P b c t"
shows "βc β pwits (b' @ b). βt β wits_subterms (b' @ b). P (b' @ b) c t"
using assms(2-6)
using lexpands_wits_eq[OF assms(2,3)]
lexpands_pwits_subs[OF assms(2,3)]
proof(induction rule: lexpands.induct)
case (1 b' b)
have "P (b' @ b) c t"
if "βΟ β set b'. vars Ο β© wits (b' @ b) = {}"
and "c β pwits b" "t β wits_subterms (b' @ b)" for c t
proof -
from that "1.prems"(5)
have "βΟ β set b'. Ο β AT (Var c =β©s t) β§ Ο β AT (t =β©s Var c) β§ Ο β AT (t ββ©s Var c)"
by (auto simp: pwits_def disjoint_iff)
with 1 that show ?thesis
unfolding P_def wits_subterms_def
by (metis Un_iff last_appendR set_append)
qed
moreover from "1"(1,4,6) have "βΟ β set b'. vars Ο β© wits (b' @ b) = {}"
by (induction rule: lexpands_fm.induct) (auto simp: disjoint_iff)
ultimately show ?case
using 1 lexpands_fm_pwits_eq by blast
next
case (2 b' b)
then show ?case
using lexpands_un_pwits_eq[OF "2"(1,2,5)[unfolded P_def]]
proof(induction rule: lexpands_un.induct)
case (4 s t1 t2 b)
then have "t1 ββ©s t2 β subterms b"
unfolding subterms_branch_def
by (metis UN_iff UnI2 subterms_fm_simps(1) subterms_atom.simps(1) subterms_refl)
with βΉno_new_subterms bβΊ have "t1 ββ©s t2 β subterms (last b)"
using no_new_subtermsD by blast
then have "t1 β Var ` wits b" "t2 β Var ` wits b"
by (meson disjoint_iff wits_subterms_last_disjnt subterms_fmD)+
with 4 show ?case
by (auto simp: wits_subterms_def P_def subterms_branch_simps pwitsD(1))
next
case (5 s t1 t2 b)
then have "t1 ββ©s t2 β subterms b"
unfolding subterms_branch_def
by (metis UN_iff UnI2 subterms_fm_simps(1) subterms_atom.simps(1) subterms_refl)
with βΉno_new_subterms bβΊ have "t1 ββ©s t2 β subterms (last b)"
using no_new_subtermsD by blast
then have "t1 β Var ` wits b" "t2 β Var ` wits b"
by (meson disjoint_iff wits_subterms_last_disjnt subterms_fmD)+
with 5 show ?case
by (auto simp: wits_subterms_def P_def subterms_branch_simps pwitsD(1))
qed (auto simp: wits_subterms_def P_def)
next
case (3 b' b)
then show ?case
using lexpands_int_pwits_eq[OF "3"(1,2,5)[unfolded P_def]]
proof(induction rule: lexpands_int.induct)
case (1 s t1 t2 b)
then have "t1 ββ©s t2 β subterms b"
unfolding subterms_branch_def
by (metis UN_iff UnI2 subterms_fm_simps(1) subterms_atom.simps(1) subterms_refl)
with βΉno_new_subterms bβΊ have "t1 ββ©s t2 β subterms (last b)"
using no_new_subtermsD by blast
then have "t1 β Var ` wits b" "t2 β Var ` wits b"
by (meson disjoint_iff wits_subterms_last_disjnt subterms_fmD)+
with 1 show ?case
by (auto simp: wits_subterms_def P_def subterms_branch_simps pwitsD(1))
next
case (6 s t1 b t2)
then have "t1 β Var ` wits b" "t2 β Var ` wits b"
by (meson disjoint_iff wits_subterms_last_disjnt subterms_fmD)+
with 6 show ?case
by (auto simp: wits_subterms_def P_def subterms_branch_simps pwitsD(1))
qed (auto simp: wits_subterms_def P_def)
next
case (4 b' b)
then show ?case
using lexpands_diff_pwits_eq[OF "4"(1,2,5)[unfolded P_def]]
proof(induction rule: lexpands_diff.induct)
case (1 s t1 t2 b)
then have "t1 -β©s t2 β subterms b"
unfolding subterms_branch_def
by (metis UN_iff UnI2 subterms_fm_simps(1) subterms_atom.simps(1) subterms_refl)
with βΉno_new_subterms bβΊ have "t1 -β©s t2 β subterms (last b)"
using no_new_subtermsD by blast
then have "t1 β Var ` wits b" "t2 β Var ` wits b"
by (meson disjoint_iff wits_subterms_last_disjnt subterms_fmD)+
with 1 show ?case
by (auto simp: wits_subterms_def P_def subterms_branch_simps dest: pwitsD(1))
next
case (4 s t1 t2 b)
then have "t1 -β©s t2 β subterms b"
unfolding subterms_branch_def
by (metis AF_mem_subterms_branchD(2) subterms_branch_def)
with βΉno_new_subterms bβΊ have "t1 -β©s t2 β subterms (last b)"
using no_new_subtermsD by blast
then have "t1 β Var ` wits b" "t2 β Var ` wits b"
by (meson disjoint_iff wits_subterms_last_disjnt subterms_fmD)+
with 4 show ?case
by (auto simp: wits_subterms_def P_def subterms_branch_simps dest: pwitsD(1))
qed (auto simp: wits_subterms_def P_def)
next
case (5 b' b)
then show ?case
proof(induction rule: lexpands_single.induct)
case (2 s t b)
then have "Single t β subterms b"
by (auto intro: subterms_branch_subterms_atomI)
with 2 have "t β subterms (last b)"
by (metis subterms_fmD(7) no_new_subtermsD(5))
then have "βc β pwits b. Var c β t"
unfolding pwits_def wits_def
using wits_def wits_subterms_last_disjnt by fastforce
with βΉt β subterms (last b)βΊ show ?case
using 2
unfolding P_def
by (auto simp: wits_subterms_last_disjnt[unfolded disjoint_iff] wits_subterms_def subsetD
dest: pwitsD(2))
qed (auto simp: wits_subterms_def P_def)
next
case (6 b' b)
then have "no_new_subterms (b' @ b)" "b' @ b β []"
using lexpands_no_new_subterms[OF lexpands.intros(6)] by blast+
note subterms_branch_eq_if_no_new_subterms[OF this]
with 6 show ?case
proof(induction rule: lexpands_eq_induct')
case (subst t1 t2 t1' t2' p l b)
then have "t1' β subterms b"
using AT_eq_subterms_branchD by blast
then show ?case unfolding P_def
proof(safe, goal_cases)
case (1 c x)
with subst have [simp]: "p"
by (cases p) (simp add: P_def wits_subterms_def; blast)+
from 1 subst have "(Var c =β©s x) = subst_tlvl t1' t2' l"
by (simp add: P_def wits_subterms_def; blast)
with 1 subst consider
(refl) "l = (t1' =β©s t1')" "t2' = Var c" "x = Var c"
| (t1'_left) "l = (Var c =β©s t1')" "t2' = x"
| (t1'_right) "l = (t1' =β©s x)" "t2' = Var c"
apply(cases "(t1', t2', l)" rule: subst_tlvl.cases)
by (auto split: if_splits)
then show ?case
apply(cases)
by (use 1 subst subterms_branch_eq_if_no_new_subterms in βΉ(simp add: P_def; blast)+βΊ)
next
case (2 c x)
with subst have [simp]: "p"
by (cases p) (simp add: P_def wits_subterms_def; blast)+
from 2 subst have "(x =β©s Var c) = subst_tlvl t1' t2' l"
by (simp add: P_def wits_subterms_def; blast)
with 2 subst consider
(refl) "l = (t1' =β©s t1')" "t2' = Var c" "x = Var c"
| (t1_left) "l = (t1' =β©s Var c)" "t2' = x"
| (t1_right) "l = (x =β©s t1')" "t2' = Var c"
apply(cases "(t1', t2', l)" rule: subst_tlvl.cases)
by (auto split: if_splits)
then show ?case
apply(cases)
by (use 2 subst subterms_branch_eq_if_no_new_subterms in βΉ(simp add: P_def; blast)+βΊ)
next
case (3 c x)
with subst have [simp]: "p"
by (cases p) (simp add: P_def wits_subterms_def; blast)+
from 3 subst have "(x ββ©s Var c) = subst_tlvl t1' t2' l"
by (simp add: P_def wits_subterms_def; blast)
with 3 subst consider
(refl) "l = (t1' ββ©s t1')" "t2' = Var c" "x = Var c"
| (t1_left) "l = (t1' ββ©s Var c)" "t2' = x"
| (t1_right) "l = (x ββ©s t1')" "t2' = Var c"
apply(cases "(t1', t2', l)" rule: subst_tlvl.cases)
by (auto split: if_splits)
then show ?case
apply(cases)
by (use 3 subst subterms_branch_eq_if_no_new_subterms in βΉ(simp add: P_def; blast)+βΊ)
qed
next
case (neq s t s' b)
then show ?case
using P_def by (simp add: wits_subterms_def) blast
qed
qed
lemma lemma_2_bexpands:
defines "P β‘ (Ξ»b c t. AT (Var c =β©s t) β set b β§ AT (t =β©s Var c) β set b
β§ AT (t ββ©s Var c) β set b)"
assumes "bexpands bs' b" "b' β bs'" "b β []"
assumes "no_new_subterms b"
assumes "βΟ β set b. Β¬ is_literal Ο βΆ vars Ο β© wits b = {}"
assumes "βc β pwits b. βt β wits_subterms b. P b c t"
shows "βc β pwits (b' @ b). βt β wits_subterms (b' @ b). P (b' @ b) c t"
using assms(2-) bexpands_no_new_subterms[OF assms(2,4,3,5)]
proof(induction rule: bexpands.induct)
case (1 bs' b)
then show ?case
using bexpands_nowit_wits_eq[OF "1"(1-3)] bexpands_nowit_pwits_eq[OF "1"(1-3,5)]
proof(induction rule: bexpands_nowit.induct)
case (1 p q b)
then show ?case
unfolding P_def wits_subterms_def
by (fastforce dest: pwitsD)
next
case (2 p q b)
then show ?case
unfolding P_def wits_subterms_def
by (fastforce dest: pwitsD)
next
case (3 s t1 t2 b)
then have "t1 β Var ` wits b"
by (meson disjoint_iff wits_subterms_last_disjnt subterms_fmD)+
with 3 show ?case
unfolding P_def wits_subterms_def
by (fastforce simp: vars_branch_simps dest: pwitsD)
next
case (4 s t1 b t2)
then have "t2 β Var ` wits b"
by (meson disjoint_iff wits_subterms_last_disjnt subterms_fmD)+
with 4 show ?case
unfolding P_def wits_subterms_def
by (fastforce simp: vars_branch_simps dest: pwitsD)
next
case (5 s t1 b t2)
then have "t2 β Var ` wits b"
by (meson disjoint_iff wits_subterms_last_disjnt subterms_fmD)+
with 5 show ?case
unfolding P_def wits_subterms_def
by (fastforce simp: vars_branch_simps dest: pwitsD)
qed
next
case (2 t1 t2 x bs b)
from bexpands_witD[OF "2"(1)] have "t1 β Var ` wits b" "t2 β Var ` wits b"
by (meson disjoint_iff_not_equal wits_subterms_last_disjnt)+
then have not_in_pwits: "t1 β Var ` pwits b" "t2 β Var ` pwits b"
unfolding pwits_def by auto
with bexpands_witD[OF "2"(1)] "2"(2-) show ?case
unfolding P_def wits_subterms_def
unfolding bexpands_wit_pwits_eq[OF "2"(1-3)] bexpands_wit_wits_eq[OF "2"(1-3)]
by safe (auto simp: vars_fm_vars_branchI[where ?x=x and ?b=b])
qed
lemma subterms_branch_eq_if_wf_branch:
assumes "wf_branch b"
shows "subterms_branch b = wits_subterms b"
proof -
from assms obtain Ο where "expandss b [Ο]"
unfolding wf_branch_def by blast
then have "no_new_subterms [Ο]"
unfolding no_new_subterms_def wits_def
by (simp add: subterms_branch_simps)
with βΉexpandss b [Ο]βΊ have "no_new_subterms b"
using expandss_no_new_subterms by blast
with βΉexpandss b [Ο]βΊ assms show ?thesis
by (intro subterms_branch_eq_if_no_new_subterms) simp_all
qed
lemma
assumes "wf_branch b"
shows no_new_subterms_if_wf_branch: "no_new_subterms b"
and no_wits_if_not_literal_if_wf_branch:
"βΟ β set b. Β¬ is_literal Ο βΆ vars Ο β© wits b = {}"
proof -
from assms obtain Ο where "expandss b [Ο]"
unfolding wf_branch_def by blast
then have "no_new_subterms [Ο]"
by (auto simp: no_new_subterms_def wits_def vars_branch_simps subterms_branch_simps)
from expandss_no_new_subterms[OF βΉexpandss b [Ο]βΊ _ this] show "no_new_subterms b"
by simp
from expandss_no_wits_if_not_literal[OF βΉexpandss b [Ο]βΊ]
show "βΟ β set b. Β¬ is_literal Ο βΆ vars Ο β© wits b = {}"
unfolding wits_def by simp
qed
lemma lemma_2:
assumes "wf_branch b"
assumes "c β pwits b"
shows "AT (Var c =β©s t) β set b" "AT (t =β©s Var c) β set b" "AT (t ββ©s Var c) β set b"
proof -
from βΉwf_branch bβΊ obtain Ο where "expandss b [Ο]"
using wf_branch_def by blast
have no_wits_if_not_literal: "βΟ β set b'. Β¬ is_literal Ο βΆ vars Ο β© wits b' = {}"
if "expandss b' [Ο]" for b'
using no_wits_if_not_literal_if_wf_branch that unfolding wf_branch_def by blast
have no_new_subterms: "no_new_subterms b'" if "expandss b' [Ο]" for b'
using no_new_subterms_if_wf_branch that unfolding wf_branch_def by blast
have "AT (Var c =β©s t) β set b β§ AT (t =β©s Var c) β set b β§ AT (t ββ©s Var c) β set b"
using βΉexpandss b [Ο]βΊ assms(2)
proof(induction b "[Ο]" arbitrary: c t rule: expandss.induct)
case 1
then show ?case by simp
next
case (2 b1 b2)
note lemma_2_lexpands[OF this(1) _
no_new_subterms[OF this(3)] no_wits_if_not_literal[OF this(3)]]
with 2 show ?case
using wf_branch_def wf_branch_not_Nil subterms_branch_eq_if_wf_branch
by (metis AT_eq_subterms_branchD(1,2) AT_mem_subterms_branchD(1) expandss.intros(2))
next
case (3 bs b2 b1)
note lemma_2_bexpands[OF "3"(1) _ _
no_new_subterms[OF "3"(3)] no_wits_if_not_literal[OF "3"(3)]]
with 3 show ?case
using wf_branch_def wf_branch_not_Nil subterms_branch_eq_if_wf_branch
by (metis AT_eq_subterms_branchD(1,2) AT_mem_subterms_branchD(1) expandss.intros(3))
qed
then show "AT (Var c =β©s t) β set b" "AT (t =β©s Var c) β set b" "AT (t ββ©s Var c) β set b"
by safe
qed
subsection βΉUrelementsβΊ
definition "urelems b β‘ {x β subterms b. βv. βΟ β set b. urelem' v Ο x}"
lemma finite_urelems: "finite (urelems b)"
proof -
have "urelems b β subterms b"
unfolding urelems_def urelem_def by blast
with finite_subset finite_subterms_branch show ?thesis
by blast
qed
lemma urelems_subs_subterms: "urelems b β subterms b"
unfolding urelems_def by blast
lemma is_Var_if_mem_urelems: "t β urelems b βΉ is_Var t"
unfolding urelems_def subterms_branch_def
using is_Var_if_urelem' by auto
lemma urelems_subs_vars: "urelems b β Var ` vars b"
proof
fix t assume "t β urelems b"
with urelems_subs_subterms have "t β subterms b"
by blast
moreover note is_Var_if_mem_urelems[OF βΉt β urelems bβΊ]
then obtain x where "t = Var x"
by (meson is_Var_def)
ultimately have "x β vars b"
unfolding Un_vars_term_subterms_branch_eq_vars_branch[symmetric]
by force
with βΉt = Var xβΊ show "t β Var ` vars b"
by blast
qed
lemma types_term_inf:
assumes "v1 β’ t : l1" "v2 β’ t : l2"
shows "inf v1 v2 β’ t : inf l1 l2"
using assms
apply(induction t arbitrary: l1 l2)
apply(auto simp: inf_min elim!: types_pset_term_cases
intro: types_pset_term_intros' types_pset_term.intros(4-))
done
lemma types_pset_atom_inf:
fixes a :: "'a pset_atom"
assumes "v1 β’ a" "v2 β’ a"
shows "inf v1 v2 β’ a"
using assms
by (auto simp: types_pset_atom.simps) (metis inf_min min_Suc_Suc types_term_inf)+
lemma types_pset_fm_inf:
fixes Ο :: "'a pset_fm"
assumes "v1 β’ Ο" "v2 β’ Ο"
shows "inf v1 v2 β’ Ο"
using assms types_pset_atom_inf
unfolding types_pset_fm_def by blast
lemma types_urelems:
fixes b :: "'a branch"
assumes "wf_branch b" "v β’ last b"
obtains v' where "βΟ β set b. v' β’ Ο" "βu β urelems b. v' β’ u : 0"
proof -
from assms have "expandss b [last b]"
unfolding wf_branch_def by force
define V where "V β‘ {v. (βΟ β set b. v β’ Ο) β§ (βx. x β vars b βΆ v x = 0)}"
have "V β {}"
proof -
from types_expandss[OF βΉexpandss b [last b]βΊ, simplified] βΉv β’ last bβΊ
obtain v where v: "βΟ β set b. v β’ Ο"
unfolding vars_branch_simps by metis
define v' where "v' β‘ Ξ»x. if x β vars b then v x else 0"
have "v' β’ Ο β· v β’ Ο" if "Ο β set b" for Ο :: "'a pset_fm"
apply(intro types_pset_fm_if_on_vars_eq)
using that vars_fm_vars_branchI unfolding v'_def by metis
with v have "βΟ β set b. v' β’ Ο"
by blast
then have "v' β V"
unfolding V_def v'_def by simp
then show ?thesis
by blast
qed
define m_x where "m_x β‘ Ξ»x. ARG_MIN (Ξ»v. v x) v. v β V"
with βΉV β {}βΊ have m_x: "βv β V. m_x x x β€ v x" "m_x x β V" for x
using arg_min_nat_le arg_min_natI by (metis ex_in_conv)+
define M where "M β‘ Finite_Set.fold inf (SOME v. v β V) (m_x ` vars b)"
note finite_imageI[where ?h=m_x, OF finite_vars_branch[of b]]
note M_inf_eq = Inf_fin.eq_fold[symmetric, OF this, of "SOME v. v β V"]
have M_leq: "M x β€ v x" if "x β vars b" "v β V" for x v
proof -
from that have "m_x x β m_x ` vars b"
by blast
then have "M = inf (m_x x) (β¨
β©fβ©iβ©n insert (SOME v. v β V) (m_x ` vars b))"
unfolding M_def M_inf_eq
by (simp add: Inf_fin.in_idem finite_vars_branch)
with m_x that show ?thesis
by (simp add: inf.coboundedI1)
qed
moreover have "M β V"
unfolding M_def M_inf_eq using finite_vars_branch[of b]
proof(induction rule: finite_induct)
case empty
with βΉV β {}βΊ show ?case
by (simp add: some_in_eq)
next
case (insert x F)
then have M'_eq: "β¨
β©fβ©iβ©n insert (SOME v. v β V) (m_x ` insert x F)
= inf (m_x x) (β¨
β©fβ©iβ©n insert (SOME v. v β V) (m_x ` F))" (is "_ = ?M'")
by (simp add: insert_commute)
from types_pset_fm_inf insert have "βΟ β set b. ?M' β’ Ο"
using V_def m_x(2) by blast
moreover have "(inf w v) x = 0" if "x β vars b" "w β V" "v β V" for w v
using that by (simp add: V_def)
with "insert.IH" m_x(2) have "βx. x β vars b βΆ ?M' x = 0"
by (simp add: V_def)
ultimately have "?M' β V"
using V_def by blast
with M'_eq show ?case
by metis
qed
moreover have "M β’ u : 0" if "u β urelems b" for u
proof -
from that obtain v where v: "βΟ β set b. urelem' v Ο u"
unfolding urelems_def by blast
define v' where "v' β‘ Ξ»x. if x β vars b then v x else 0"
have "v' β’ Ο β· v β’ Ο" if "Ο β set b" for Ο :: "'a pset_fm"
apply(intro types_pset_fm_if_on_vars_eq)
using that vars_fm_vars_branchI unfolding v'_def by metis
with v have "βΟ β set b. v' β’ Ο"
by blast
then have "v' β V"
unfolding V_def v'_def by auto
moreover obtain uv where uv: "u = Var uv"
using v is_Var_if_urelem' wf_branch_not_Nil[OF βΉwf_branch bβΊ]
by (metis is_Var_def last_in_set)
then have "v' β’ u : 0"
using v wf_branch_not_Nil[OF βΉwf_branch bβΊ, THEN last_in_set]
unfolding v'_def
by (auto elim!: types_pset_term_cases(2) intro!: types_pset_term_intros'(2))
ultimately show "M β’ u : 0"
using M_leq[where ?v=v'] βΉM β VβΊ[unfolded V_def] unfolding uv
by (fastforce elim!: types_pset_term_cases(2) intro!: types_pset_term_intros'(2))
qed
ultimately show ?thesis
using that unfolding V_def by auto
qed
lemma mem_urelems_if_urelem_last:
assumes "wf_branch b"
assumes "urelem (last b) x" "x β subterms (last b)"
shows "x β urelems b"
proof -
from assms have "x β subterms b"
unfolding subterms_branch_def by auto
moreover note urelem_invar_if_wf_branch[OF assms]
ultimately show ?thesis
unfolding urelems_def urelem_def by blast
qed
lemma not_urelem_comps_if_compound:
assumes "f t1 t2 β subterms b" "f β {(ββ©s), (ββ©s), (-β©s)}"
shows "t1 β urelems b" "t2 β urelems b"
proof -
from assms obtain Ο where "Ο β set b" "f t1 t2 β subterms Ο"
unfolding subterms_branch_def by auto
note not_urelem_comps_if_compound[of f t1 t2, OF this(2) assms(2)]
with βΉΟ β set bβΊ show "t1 β urelems b" "t2 β urelems b"
unfolding urelems_def urelem_def by auto
qed
subsection βΉRealization of an Open BranchβΊ
definition "base_vars b β‘ Var ` pwits b βͺ urelems b"
lemma finite_base_vars: "finite (base_vars b)"
unfolding base_vars_def finite_Un
using finite_pwits[THEN finite_imageI] finite_urelems by blast
lemma pwits_subs_base_vars:
shows "Var ` pwits b β base_vars b"
unfolding base_vars_def
by blast
lemma base_vars_subs_vars: "base_vars b β Var ` vars b"
unfolding base_vars_def pwits_def wits_def
using urelems_subs_vars by blast
definition subterms' :: "'a branch β 'a pset_term set" where
"subterms' b β‘ subterms b - base_vars b"
definition bgraph :: "'a branch β ('a pset_term, 'a pset_term Γ 'a pset_term) pre_digraph" where
"bgraph b β‘
let
vs = base_vars b βͺ subterms' b
in
β¦ verts = vs,
arcs = {(s, t). AT (s ββ©s t) β set b},
tail = fst,
head = snd β¦"
lemma base_vars_Un_subterms'_eq_subterms:
"base_vars b βͺ subterms' b = subterms b"
unfolding subterms'_def
using base_vars_subs_vars vars_branch_subs_subterms_branch by fastforce
lemma finite_base_vars_Un_subterms': "finite (base_vars b βͺ subterms' b)"
unfolding base_vars_Un_subterms'_eq_subterms
using finite_subterms_branch .
lemma verts_bgraph: "verts (bgraph b) = base_vars b βͺ subterms' b"
unfolding bgraph_def Let_def by simp
lemma verts_bgraph_eq_subterms: "verts (bgraph b) = subterms b"
unfolding verts_bgraph base_vars_Un_subterms'_eq_subterms ..
lemma finite_subterms': "finite (subterms' b)"
unfolding subterms'_def using finite_base_vars finite_subterms_branch
by auto
lemma base_vars_subterms'_disjnt: "base_vars b β© subterms' b = {}"
unfolding subterms'_def by fastforce
lemma wits_subterms_eq_base_vars_Un_subterms':
assumes "wf_branch b"
shows "wits_subterms b = base_vars b βͺ subterms' b"
unfolding subterms_branch_eq_if_wf_branch[OF assms, symmetric] subterms'_def
using base_vars_subs_vars vars_branch_subs_subterms_branch
by fastforce
lemma in_subterms'_if_AT_mem_in_branch:
assumes "wf_branch b"
assumes "AT (s ββ©s t) β set b"
shows "s β base_vars b βͺ subterms' b"
and "t β base_vars b βͺ subterms' b"
using assms
using wits_subterms_eq_base_vars_Un_subterms' AT_mem_subterms_branchD
using subterms_branch_eq_if_wf_branch
by blast+
lemma in_subterms'_if_AF_mem_in_branch:
assumes "wf_branch b"
assumes "AF (s ββ©s t) β set b"
shows "s β base_vars b βͺ subterms' b"
and "t β base_vars b βͺ subterms' b"
using assms
using wits_subterms_eq_base_vars_Un_subterms' AF_mem_subterms_branchD
using subterms_branch_eq_if_wf_branch
by blast+
lemma in_subterms'_if_AT_eq_in_branch:
assumes "wf_branch b"
assumes "AT (s =β©s t) β set b"
shows "s β base_vars b βͺ subterms' b"
and "t β base_vars b βͺ subterms' b"
using assms
using wits_subterms_eq_base_vars_Un_subterms' AT_eq_subterms_branchD
using subterms_branch_eq_if_wf_branch
by blast+
lemma in_subterms'_if_AF_eq_in_branch:
assumes "wf_branch b"
assumes "AF (s =β©s t) β set b"
shows "s β base_vars b βͺ subterms' b"
and "t β base_vars b βͺ subterms' b"
using assms
using wits_subterms_eq_base_vars_Un_subterms' AF_eq_subterms_branchD
using subterms_branch_eq_if_wf_branch
by blast+
lemma mem_subterms_fm_last_if_mem_subterms_branch:
assumes "wf_branch b"
assumes "t β subterms b" "Β¬ is_Var t"
shows "t β subterms (last b)"
using assms
unfolding subterms_branch_eq_if_wf_branch[OF βΉwf_branch bβΊ]
unfolding subterms'_def wits_subterms_def by force
locale open_branch =
fixes b :: "'a branch"
assumes wf_branch: "wf_branch b" and bopen: "bopen b" and types: "βv. v β’ last b"
and infinite_vars: "infinite (UNIV :: 'a set)"
begin
sublocale fin_digraph_bgraph: fin_digraph "bgraph b"
proof
show "finite (verts (bgraph b))"
using finite_base_vars finite_subterms'
by (auto simp: bgraph_def Let_def)
show "finite (arcs (bgraph b))"
using [[simproc add: finite_Collect]]
by (auto simp: bgraph_def Let_def inj_on_def intro!: finite_vimageI)
qed (use in_subterms'_if_AT_mem_in_branch[OF wf_branch]
in βΉ(fastforce simp: bgraph_def Let_def)+βΊ)
lemma member_seq_if_cas:
"fin_digraph_bgraph.cas t1 is t2
βΉ member_seq t1 (map (Ξ»e. tail (bgraph b) e ββ©s head (bgraph b) e) is) t2"
by (induction "is" arbitrary: t1 t2) auto
lemma member_cycle_if_cycle:
"fin_digraph_bgraph.cycle c
βΉ member_cycle (map (Ξ»e. tail (bgraph b) e ββ©s head (bgraph b) e) c)"
unfolding pre_digraph.cycle_def
by (cases c) (auto simp: member_seq_if_cas)
sublocale dag_bgraph: dag "bgraph b"
proof(unfold_locales, goal_cases)
case (1 e)
show ?case
proof
assume "tail (bgraph b) e = head (bgraph b) e"
then obtain t where "AT (t ββ©s t) β set b"
using 1 unfolding bgraph_def Let_def by auto
then have "member_cycle [(t ββ©s t)]" "(t ββ©s t) β Atoms (set b)"
by (auto simp: Atoms_def)
then have "bclosed b"
using memberCycle by (metis empty_iff empty_set set_ConsD subsetI)
with bopen show "False"
by blast
qed
next
case (2 e1 e2)
then show ?case
by (auto simp: bgraph_def Let_def arc_to_ends_def)
next
case 3
show ?case
proof
assume "βc. fin_digraph_bgraph.cycle c"
then obtain c where "fin_digraph_bgraph.cycle c"
by blast
then have "member_cycle (map (Ξ»e. (tail (bgraph b) e ββ©s head (bgraph b) e)) c)"
using member_cycle_if_cycle by blast
moreover
from βΉfin_digraph_bgraph.cycle cβΊ have "set c β arcs (bgraph b)"
by (meson fin_digraph_bgraph.cycle_def pre_digraph.awalk_def)
then have "set (map (Ξ»e. (tail (bgraph b) e ββ©s head (bgraph b) e)) c) β Atoms (set b)"
unfolding bgraph_def Let_def Atoms_def by auto
ultimately have "bclosed b"
using memberCycle by blast
with bopen show False by blast
qed
qed
definition I :: "'a pset_term β hf" where
"I β‘ SOME f. inj_on f (subterms b)
β§ (βp. hcard (f p) > 2 * card (base_vars b βͺ subterms' b))"
lemma (in -) Ex_set_family:
assumes "finite P"
shows "βI. inj_on I P β§ (βp. hcard (I p) β₯ n)"
proof -
from βΉfinite PβΊ obtain ip where ip: "bij_betw ip P {..<card P}"
using to_nat_on_finite by blast
let ?I = "ord_of o ((+) n) o ip"
from ip have "inj_on ?I P"
by (auto simp: inj_on_def bij_betw_def)
moreover have "hcard (?I p) β₯ n" for p
by simp
ultimately show ?thesis
by auto
qed
lemma
shows inj_on_I: "inj_on I (subterms b)"
and card_I: "hcard (I p) > 2 * card (base_vars b βͺ subterms' b)"
proof -
have "βf. inj_on f (subterms b)
β§ (βp. hcard (f p) > 2 * card (base_vars b βͺ subterms' b))"
using Ex_set_family finite_subterms_branch by (metis less_eq_Suc_le)
from someI_ex[OF this]
show "inj_on I (subterms b)"
"hcard (I p) > 2 * card (base_vars b βͺ subterms' b)"
unfolding I_def by blast+
qed
lemma
shows inj_on_base_vars_I: "inj_on I (base_vars b)"
and inj_on_subterms'_I: "inj_on I (subterms' b)"
proof -
from base_vars_Un_subterms'_eq_subterms have
"base_vars b β subterms b" "subterms' b β subterms b"
using wf_branch_not_Nil[OF wf_branch] by blast+
with inj_on_I show "inj_on I (base_vars b)" "inj_on I (subterms' b)"
unfolding inj_on_def by blast+
qed
definition "eq β‘ symcl ({(s, t). AT (s =β©s t) β set b}β§=)"
lemma refl_eq: "refl eq"
unfolding eq_def symcl_def refl_on_def by auto
lemma trans_eq:
assumes "lin_sat b" shows "trans eq"
proof
fix s t u assume assms: "(s, t) β eq" "(t, u) β eq"
have "(s, u) β eq" if "s β t" "t β u"
proof -
from that assms have
s_t: "AT (s =β©s t) β set b β¨ AT (t =β©s s) β set b" and
t_u: "AT (t =β©s u) β set b β¨ AT (u =β©s t) β set b"
unfolding eq_def symcl_def by fastforce+
note intros = lexpands_eq.intros(1,3)[
THEN lexpands.intros(6), THEN βΉlin_sat bβΊ[THEN lin_satD]]
note intros' = intros[where ?x="AT (s =β©s u)"] intros[where ?x="AT (u =β©s s)"]
from s_t t_u that have "AT (s =β©s u) β set b β¨ AT (u =β©s s) β set b"
by safe (simp_all add: intros')
then show ?thesis
unfolding eq_def symcl_def by auto
qed
with assms show "(s, u) β eq"
by (cases "s β t β§ t β u") (auto simp: eq_def)
qed
lemma sym_eq: "sym eq"
unfolding eq_def symcl_def sym_def by auto
lemma equiv_eq: "lin_sat b βΉ equiv UNIV eq"
by (rule equivI) (use refl_eq trans_eq sym_eq in safe)
lemma not_dominated_if_pwits:
assumes "x β Var ` pwits b" shows "Β¬ s ββbgraph bβ x"
proof -
from assms obtain x' where "x = Var x'" "x' β pwits b"
by blast
from lemma_2(3)[OF wf_branch this(2)] this(1) show "Β¬ s ββbgraph bβ x"
unfolding arcs_ends_def arc_to_ends_def by (auto simp: bgraph_def)
qed
lemma parents_empty_if_pwits:
assumes "x β Var ` pwits b" shows "parents (bgraph b) x = {}"
using not_dominated_if_pwits[OF assms] unfolding bgraph_def by simp
lemma not_AT_mem_if_urelem:
assumes "t β urelems b"
shows "AT (s ββ©s t) β set b"
proof
assume "AT (s ββ©s t) β set b"
with assms urelem_invar_if_wf_branch[OF wf_branch] have "urelem (AT (s ββ©s t)) t"
by (meson types types_urelems urelem_def wf_branch)
then show False
unfolding urelem_def
by (auto dest!: types_fmD simp: types_pset_atom.simps dest: types_term_unique)
qed
lemma not_dominated_if_urelems:
assumes "t β urelems b"
shows "Β¬ s ββbgraph bβ t"
using not_AT_mem_if_urelem[OF assms] unfolding bgraph_def by auto
lemma parents_empty_if_urelems:
assumes "t β urelems b"
shows "parents (bgraph b) t = {}"
using not_dominated_if_urelems[OF assms] by simp
lemma not_dominated_if_base_vars:
assumes "x β base_vars b"
shows "Β¬ s ββbgraph bβ x"
using assms not_dominated_if_urelems not_dominated_if_pwits
unfolding base_vars_def by blast
lemma parents_empty_if_base_vars:
assumes "x β base_vars b"
shows "parents (bgraph b) x = {}"
using not_dominated_if_base_vars[OF assms] by blast
lemma eq_class_subs_subterms: "eq `` {t} β {t} βͺ subterms b"
proof -
have "eq - Id β subterms b Γ subterms b"
by (auto simp: AT_eq_subterms_branchD eq_def symcl_def)
then show "eq `` {t} β {t} βͺ subterms b"
by blast
qed
lemma finite_eq_class: "finite (eq `` {x})"
using eq_class_subs_subterms finite_subterms_branch
using finite_subset by fastforce
lemma finite_I_image_eq_class: "finite (I ` eq `` {x})"
using finite_eq_class by blast
context
begin
interpretation realisation "bgraph b" "base_vars b" "subterms' b" I eq
proof(unfold_locales)
from base_vars_subterms'_disjnt show "base_vars b β© subterms' b = {}" .
show "verts (bgraph b) = base_vars b βͺ subterms' b"
unfolding bgraph_def by simp
from not_dominated_if_base_vars show "βp t. p β base_vars b βΉ Β¬ t ββbgraph bβ p" .
qed
lemmas realisation = realisation_axioms
lemma card_realisation:
"hcard (realise t) β€ 2 * card (subterms b)"
proof(induction t rule: realise.induct)
case (1 x)
then have "hcard (realise x) = card (realise ` parents (bgraph b) x βͺ I ` eq_class x)"
using hcard_HF Zero_hf_def parents_empty_if_base_vars
using finite_I_image_eq_class by force
also have "β¦ β€ card (realise ` parents (bgraph b) x) + card (I ` eq_class x)"
using card_Un_le by blast
also have "β¦ β€ card (parents (bgraph b) x) + card (eq_class x)"
using card_image_le[OF fin_digraph_bgraph.finite_parents]
using card_image_le[OF finite_eq_class]
by (metis add_le_mono)
also have "β¦ β€ card (subterms b) + card (eq_class x)"
using fin_digraph_bgraph.parents_subs_verts[unfolded verts_bgraph_eq_subterms]
using card_mono[OF finite_subterms_branch]
by (simp add: "1.hyps" not_dominated_if_base_vars)
also have "β¦ β€ card (subterms b) + card ({x} βͺ subterms b)"
apply (intro add_le_mono card_mono[where ?B="{x} βͺ subterms b"])
using eq_class_subs_subterms finite_subterms_branch by auto
also have "β¦ β€ 2 * card (subterms b)"
proof -
from 1 have "x β subterms b"
using "1.prems" verts_bgraph verts_bgraph_eq_subterms wf_branch_not_Nil[OF wf_branch]
by blast
then show ?thesis
unfolding mult_2 by (metis insert_absorb insert_is_Un order_refl)
qed
finally show ?case .
next
case (2 t)
then have "hcard (realise t) = card (realise ` parents (bgraph b) t)"
using hcard_HF[OF finite_realisation_parents] by simp
also have "β¦ β€ card (parents (bgraph b) t)"
using card_image_le by blast
also have "β¦ β€ card (subterms b)"
using fin_digraph_bgraph.parents_subs_verts wf_branch_not_Nil[OF wf_branch]
unfolding verts_bgraph_eq_subterms
by (metis card_mono fin_digraph_bgraph.finite_verts verts_bgraph_eq_subterms)
finally show ?case
unfolding base_vars_Un_subterms'_eq_subterms by auto
next
case (3 t)
then show ?case by simp
qed
lemma I_neq_realise: "I x β realise y"
proof -
note card_realisation[of y]
moreover have "hcard (I x) > 2 * card (subterms b)"
using card_I wf_branch
by (simp add: subterms_branch_eq_if_wf_branch wits_subterms_eq_base_vars_Un_subterms')
ultimately show ?thesis
by (metis linorder_not_le)
qed
end
sublocale realisation "bgraph b" "base_vars b" "subterms' b" I eq
rewrites "(βx y. I x β realise y) β‘ Trueprop True"
and "βP. (True βΉ P) β‘ Trueprop P"
and "βP Q. (True βΉ PROP P βΉ PROP Q) β‘ (PROP P βΉ True βΉ PROP Q)"
using realisation I_neq_realise by simp_all
lemma eq_class_singleton_if_pwits:
assumes "x β Var ` pwits b" shows "eq_class x = {x}"
proof -
from assms obtain x' where "x = Var x'" "x' β pwits b"
by blast
have False if "eq_class x β {x}"
proof -
have "x β eq_class x"
by (simp add: eq_def symcl_def)
with that obtain y where "y β eq_class x" "y β x"
by auto
then have "AT (y =β©s x) β set b β¨ AT (x =β©s y) β set b"
unfolding eq_def symcl_def by auto
with lemma_2(1,2)[OF wf_branch βΉx' β pwits bβΊ] βΉx = Var x'βΊ show False
by blast
qed
with assms show ?thesis by blast
qed
lemma realise_pwits:
"x β Var ` pwits b βΉ realise x = HF {I x}"
unfolding realise.simps(1)[OF pwits_subs_base_vars[THEN subsetD]]
by (auto simp: eq_class_singleton_if_pwits parents_empty_if_pwits)
lemma I_in_realise_if_base_vars[simp]:
"s β base_vars b βΉ I s ββ realise s"
using refl_eq by (simp add: finite_I_image_eq_class refl_on_def)
lemma realise_neq_if_base_vars_and_subterms':
assumes "s β base_vars b" "t β subterms' b"
shows "realise s β realise t"
proof -
from assms have "I s ββ realise t"
using I_neq_realise by auto
with I_in_realise_if_base_vars assms(1) show ?thesis
by metis
qed
lemma AT_mem_branch_wits_subtermsD:
assumes "AT (s ββ©s t) β set b"
shows "s β wits_subterms b" "t β wits_subterms b"
using assms AT_mem_subterms_branchD subterms_branch_eq_if_wf_branch wf_branch by blast+
lemma AF_mem_branch_wits_subtermsD:
assumes "AF (s ββ©s t) β set b"
shows "s β wits_subterms b" "t β wits_subterms b"
using assms AF_mem_subterms_branchD subterms_branch_eq_if_wf_branch wf_branch by blast+
lemma AT_eq_branch_wits_subtermsD:
assumes "AT (s =β©s t) β set b"
shows "s β wits_subterms b" "t β wits_subterms b"
using assms AT_eq_subterms_branchD subterms_branch_eq_if_wf_branch wf_branch by blast+
lemma AF_eq_branch_wits_subtermsD:
assumes "AF (s =β©s t) β set b"
shows "s β wits_subterms b" "t β wits_subterms b"
using assms AF_eq_subterms_branchD subterms_branch_eq_if_wf_branch wf_branch by blast+
lemma realisation_if_AT_mem:
assumes "AT (s ββ©s t) β set b"
shows "realise s ββ realise t"
proof -
from assms have "t β base_vars b βͺ subterms' b"
using in_subterms'_if_AT_mem_in_branch(2) wf_branch by blast
moreover from assms have "s ββbgraph bβ t"
unfolding arcs_ends_def arc_to_ends_def by (simp add: bgraph_def)
ultimately show ?thesis
by (cases t rule: realise.cases) auto
qed
lemma AT_eq_urelems_subterms'_cases:
assumes "AT (s =β©s t) β set b"
obtains (urelems) "s β urelems b" "t β urelems b" |
(subterms') "s β subterms' b" "t β subterms' b"
proof -
from types obtain v where "v β’ last b"
by blast
with types_urelems wf_branch obtain v'
where v': "βΟ β set b. v' β’ Ο" "βu β urelems b. v' β’ u : 0"
by blast
with assms have "v' β’ AT (s =β©s t)"
by blast
then obtain lst where lst: "v' β’ s : lst" "v' β’ t : lst"
by (auto dest!: types_fmD(6) simp: types_pset_atom.simps)
note mem_subterms = AT_eq_subterms_branchD[OF assms]
with v' have "t β urelems b" if "s β urelems b"
using that lst types_term_unique urelems_def by fastforce
moreover from assms have "s β Var ` pwits b" "t β Var ` pwits b"
using lemma_2(1,2)[OF wf_branch] by blast+
moreover have "t β subterms' b" if "s β subterms' b"
proof -
have "s β urelems b"
using that B_T_partition_verts(1) unfolding base_vars_def by blast
with v'(1) mem_subterms(1) have "Β¬ v' β’ s : 0"
using urelems_def by blast
with lst v'(2) have "t β urelems b"
using types_term_unique by metis
with βΉt β Var ` pwits bβΊ βΉt β subterms bβΊ show "t β subterms' b"
by (simp add: base_vars_def subterms'_def)
qed
ultimately show ?thesis
using that mem_subterms
by (cases "s β subterms' b") (auto simp: base_vars_def subterms'_def)
qed
lemma realisation_if_AT_eq:
assumes "lin_sat b"
assumes "AT (s =β©s t) β set b"
shows "realise s = realise t"
proof -
from assms(2) show ?thesis
proof(cases rule: AT_eq_urelems_subterms'_cases)
case urelems
then have "s β base_vars b" "t β base_vars b"
by (simp_all add: base_vars_def)
moreover from assms have "(s, t) β eq"
unfolding eq_def symcl_def by blast
then have "I ` eq_class s = I ` eq_class t"
using equiv_eq[OF assms(1)] by (simp add: equiv_class_eq_iff)
ultimately show ?thesis
using urelems by (simp add: parents_empty_if_urelems)
next
case subterms'
have "False" if "realise s β realise t"
proof -
from that have "hfset (realise s) β hfset (realise t)"
by (metis HF_hfset)
then obtain a s' t' where
a: "a β realise ` parents (bgraph b) s'"
"a β realise ` parents (bgraph b) t'"
and s'_t': "s' = s β§ t' = t β¨ s' = t β§ t' = s"
using subterms' by auto blast+
with subterms' have "s' β subterms' b" "t' β subterms' b"
by auto
with a obtain u where u: "a = realise u" "u ββbgraph bβ s'"
using subterms' dominates_if_mem_realisation by auto
then have "u β s'"
using dag_bgraph.adj_not_same by blast
from u have "AT (u ββ©s s') β set b"
unfolding bgraph_def Let_def using dag_bgraph.adj_not_same by auto
note lexpands_eq.intros(1,3)[OF assms(2) this, THEN lexpands.intros(6)]
with βΉlin_sat bβΊ s'_t' βΉu β s'βΊ have "AT (u ββ©s t') β set b"
unfolding lin_sat_def by (auto split: if_splits)
from realisation_if_AT_mem[OF this] βΉa = realise uβΊ have "a ββ realise t'"
by blast
with a show False
using βΉt' β subterms' bβΊ by simp
qed
then show ?thesis by blast
qed
qed
lemma realise_base_vars_if_AF_eq:
assumes "sat b"
assumes "AF (x =β©s y) β set b"
assumes "x β base_vars b β¨ y β base_vars b"
shows "realise x β realise y"
proof(cases "x β base_vars b β§ y β base_vars b")
case False
with assms(3) show ?thesis
using realise_neq_if_base_vars_and_subterms' I_in_realise_if_base_vars
by (metis hempty_iff realise.elims)
next
case True
from assms bopen have "x β y"
using neqSelf by blast
moreover from assms bopen have "AT (x =β©s y) β set b"
using contr by blast
moreover have "AT (y =β©s x) β set b"
proof
assume "AT (y =β©s x) β set b"
note lexpands_eq.intros(2)[OF this assms(2), THEN lexpands.intros(6)]
with βΉsat bβΊ[THEN satD(1), THEN lin_satD] have "AF (x =β©s x) β set b"
by auto
with bopen neqSelf show False
by blast
qed
ultimately have "(x, y) β eq"
unfolding eq_def symcl_def by auto
then have "x β eq_class y"
by (meson Image_singleton_iff symE sym_eq)
then have "I x β I ` eq_class y"
using inj_on_I AF_eq_subterms_branchD[OF assms(2)]
using eq_class_subs_subterms inj_onD by fastforce
then have "I ` eq_class x β I ` eq_class y"
using refl_eq
by (metis Image_singleton_iff UNIV_I imageI refl_onD)
with βΉx β base_vars b β§ y β base_vars bβΊ show "realise x β realise y"
using hunion_hempty_left[unfolded Zero_hf_def]
using inj_on_HF[THEN inj_onD] finite_I_image_eq_class
by (force simp: parents_empty_if_base_vars)
qed
lemma Ex_AT_eq_mem_subterms_last_if_subterms':
assumes "t β subterms' b"
obtains "t β subterms (last b) - base_vars b"
| t' where "t' β subterms (last b) - base_vars b"
"AT (t =β©s t') β set b β¨ AT (t' =β©s t) β set b"
proof(cases "t β subterms (last b) - base_vars b")
case False
from assms have "t β subterms b"
using base_vars_Un_subterms'_eq_subterms by auto
with False consider (t_base_vars) "t β base_vars b" | (t_wits) "t β Var ` wits b"
using no_new_subterms_if_wf_branch[OF wf_branch]
by (meson DiffI no_new_subterms_def)
then show ?thesis
proof cases
case t_wits
with βΉt β subterms' bβΊ have "t β Var ` pwits b"
unfolding subterms'_def base_vars_def by blast
with t_wits obtain t' where t': "t' β subterms (last b)"
"AT (t =β©s t') β set b β¨ AT (t' =β©s t) β set b"
unfolding pwits_def by blast
with βΉt β subterms' bβΊ have "t' β base_vars b"
using AT_eq_urelems_subterms'_cases B_T_partition_verts(1)
by (metis Un_iff base_vars_def disjoint_iff)
with t' that show ?thesis
by blast
qed (use assms[unfolded subterms'_def] in blast)
qed
lemma realisation_if_AF_eq:
assumes "sat b"
assumes "AF (t1 =β©s t2) β set b"
shows "realise t1 β realise t2"
proof -
note AF_eq_branch_wits_subtermsD[OF assms(2)]
then consider
(t1_base_vars) "t1 β base_vars b" |
(t2_base_vars) "t2 β base_vars b" "t1 β base_vars b βͺ subterms' b" |
(subterms) "t1 β subterms' b" "t2 β subterms' b"
by (metis UnE wf_branch wits_subterms_eq_base_vars_Un_subterms')
then show ?thesis
proof cases
case t1_base_vars
with assms show ?thesis
using realise_base_vars_if_AF_eq by blast
next
case t2_base_vars
with assms show ?thesis
using realise_base_vars_if_AF_eq by blast
next
case subterms
define Ξ where "Ξ β‘ {(t1, t2) β subterms' b Γ subterms' b.
AF (t1 =β©s t2) β set b β§ realise t1 = realise t2}"
have "finite Ξ"
proof -
have "Ξ β subterms' b Γ subterms' b"
unfolding Ξ_def by auto
moreover note finite_cartesian_product[OF finite_subterms' finite_subterms']
ultimately show ?thesis
using finite_subset by blast
qed
let ?h = "Ξ»(t1, t2). min (height t1) (height t2)"
have False if "Ξ β {}"
proof -
obtain t1 t2 where t1_t2: "(t1, t2) = arg_min_on ?h Ξ"
by (metis surj_pair)
have "(t1, t2) β Ξ" "?h (t1, t2) = Min (?h ` Ξ)"
proof -
from arg_min_if_finite(1)[OF βΉfinite ΞβΊ that] t1_t2 show "(t1, t2) β Ξ"
by metis
have "f (arg_min_on f S) = Min (f ` S)" if "finite S" "S β {}"
for f :: "('a pset_term Γ 'a pset_term) β nat" and S
using arg_min_least[OF that] that
by (auto intro!: Min_eqI[symmetric] intro: arg_min_if_finite(1)[OF that])
from this[OF βΉfinite ΞβΊ that] t1_t2 show "?h (t1, t2) = Min (?h ` Ξ)"
by auto
qed
then have *: "t1 β subterms' b" "t2 β subterms' b"
"AF (t1 =β©s t2) β set b" "realise t1 = realise t2"
unfolding Ξ_def by auto
obtain t1' t2' where t1'_t2':
"t1' β subterms (last b) - base_vars b" "t2' β subterms (last b) - base_vars b"
"AF (t1' =β©s t2') β set b"
"realise t1' = realise t1" "realise t2' = realise t2"
proof -
note Ex_AT_eq_mem_subterms_last_if_subterms'[OF βΉt1 β subterms' bβΊ]
then obtain t1'' where
"t1'' β subterms (last b) - base_vars b" "AF (t1'' =β©s t2) β set b"
"realise t1'' = realise t1"
proof cases
case (2 t1')
from bopen neqSelf βΉAF (t1 =β©s t2) β set bβΊ have "t1 β t2"
by blast
with 2 βΉsat bβΊ[THEN satD(1), THEN lin_satD] have "AF (t1' =β©s t2) β set b"
using lexpands_eq.intros(2,4)[OF _ βΉAF (t1 =β©s t2) β set bβΊ, THEN lexpands.intros(6)]
by fastforce
with that[OF _ this] "2"(1) βΉsat bβΊ[unfolded sat_def] show ?thesis
using realisation_if_AT_eq 2 by metis
qed (use * that[of t1] in blast)
moreover
note Ex_AT_eq_mem_subterms_last_if_subterms'[OF βΉt2 β subterms' bβΊ]
then obtain t2'' where
"t2'' β subterms (last b) - base_vars b" "AF (t1'' =β©s t2'') β set b"
"realise t2'' = realise t2"
proof cases
case (2 t2')
from bopen neqSelf βΉAF (t1'' =β©s t2) β set bβΊ have "t1'' β t2"
by blast
with 2 βΉsat bβΊ[THEN satD(1), THEN lin_satD] have "AF (t1'' =β©s t2') β set b"
using lexpands_eq.intros(2,4)[OF _ βΉAF (t1'' =β©s t2) β set bβΊ, THEN lexpands.intros(6)]
by fastforce
with that[OF _ this] "2"(1) βΉsat bβΊ[unfolded sat_def] show ?thesis
using realisation_if_AT_eq 2 by metis
qed (use βΉAF (t1'' =β©s t2) β set bβΊ that[of t2] in blast)
ultimately show ?thesis
using that * by metis
qed
with βΉrealise t1 = realise t2βΊ have "(t1', t2') β Ξ"
unfolding Ξ_def subterms'_def
by (simp add: AF_eq_subterms_branchD(1,2))
then have t1'_t2'_subterms: "t1' β subterms' b" "t2' β subterms' b"
unfolding Ξ_def by blast+
from t1'_t2' lemma1_2 "*"(3) have "?h (t1', t2') = ?h (t1, t2)"
by (metis in_subterms'_if_AF_eq_in_branch(1,2)[OF wf_branch] case_prod_conv)
from mem_urelems_if_urelem_last[OF wf_branch] t1'_t2'(1,2)
have not_urelem: "Β¬ urelem (last b) t1'" "Β¬ urelem (last b) t2'"
unfolding base_vars_def by auto
from finite_vars_branch infinite_vars obtain x where "x β vars b"
using ex_new_if_finite by blast
from bexpands_wit.intros[OF t1'_t2'(3) _ _ _ _ this not_urelem]
t1'_t2'(1,2) βΉsat bβΊ[unfolded sat_def] consider
s1 where "AT (s1 ββ©s t1') β set b" "AF (s1 ββ©s t2') β set b" |
s2 where "AF (s2 ββ©s t1') β set b" "AT (s2 ββ©s t2') β set b"
using bexpands.intros(2-) by (metis Diff_iff)
then show ?thesis
proof cases
case 1
then have "realise s1 ββ realise t2'"
using realisation_if_AT_mem
by (metis "*"(4) t1'_t2'(4) t1'_t2'(5))
with 1 t1'_t2'(3,4) obtain s2 where
"s2 ββbgraph bβ t2'" "realise s1 = realise s2"
using dominates_if_mem_realisation in_subterms'_if_AT_mem_in_branch(1)[OF wf_branch]
by metis
then have "AT (s2 ββ©s t2') β set b"
unfolding bgraph_def Let_def by auto
with βΉAF (s1 ββ©s t2') β set bβΊ βΉsat bβΊ[THEN satD(1), THEN lin_satD]
have "AF (s2 =β©s s1) β set b"
using lexpands_eq.intros(5)[THEN lexpands.intros(6)] by fastforce
then have "s1 β s2"
using neqSelf bopen by blast
from realise_base_vars_if_AF_eq[OF βΉsat bβΊ βΉAF (s2 =β©s s1) β set bβΊ]
βΉrealise s1 = realise s2βΊ
have "s1 β subterms' b" "s2 β subterms' b"
by (metis Un_iff βΉAF (s2 =β©s s1) β set bβΊ in_subterms'_if_AF_eq_in_branch wf_branch)+
with βΉrealise s1 = realise s2βΊ have "(s2, s1) β Ξ"
unfolding Ξ_def using βΉAF (s2 =β©s s1) β set bβΊ by auto
moreover
have "realise s1 ββ realise t1'" "realise s2 ββ realise t1'"
"realise s1 ββ realise t2'" "realise s2 ββ realise t2'"
using βΉrealise s1 ββ realise t2'βΊ βΉrealise s1 = realise s2βΊ
using "*"(4) t1'_t2'(4,5) by auto
with lemma1_3 have "?h (s2, s1) < ?h (t1', t2')"
using βΉs1 β subterms' bβΊ βΉs2 β subterms' bβΊ t1'_t2'_subterms
by (auto simp: min_def)
ultimately show ?thesis
using arg_min_least[OF βΉfinite ΞβΊ βΉΞ β {}βΊ]
using βΉ(t1', t2') β ΞβΊ βΉ?h (t1', t2') = ?h (t1, t2)βΊ t1_t2
by (metis (mono_tags, lifting) le_antisym le_eq_less_or_eq nat_neq_iff)
next
case 2
then have "realise s2 ββ realise t1'"
using realisation_if_AT_mem
by (metis "*"(4) t1'_t2'(4) t1'_t2'(5))
with 2 t1'_t2'(3,4) obtain s1 where
"s1 ββbgraph bβ t1'" "realise s1 = realise s2"
using dominates_if_mem_realisation by metis
then have "AT (s1 ββ©s t1') β set b"
unfolding bgraph_def Let_def by auto
with βΉAF (s2 ββ©s t1') β set bβΊ βΉsat bβΊ[unfolded sat_def]
have "AF (s1 =β©s s2) β set b"
using lexpands_eq.intros(5)[THEN lexpands.intros(6)]
using lin_satD by fastforce
then have "s1 β s2"
using neqSelf bopen by blast
from realise_base_vars_if_AF_eq[OF βΉsat bβΊ βΉAF (s1 =β©s s2) β set bβΊ]
βΉrealise s1 = realise s2βΊ
have "s1 β subterms' b" "s2 β subterms' b"
by (metis Un_iff βΉAF (s1 =β©s s2) β set bβΊ in_subterms'_if_AF_eq_in_branch wf_branch)+
with βΉrealise s1 = realise s2βΊ have "(s1, s2) β Ξ"
unfolding Ξ_def using βΉAF (s1 =β©s s2) β set bβΊ by auto
moreover
have "realise s1 ββ realise t1'" "realise s2 ββ realise t1'"
"realise s1 ββ realise t2'" "realise s2 ββ realise t2'"
using βΉrealise s2 ββ realise t1'βΊ βΉrealise s1 = realise s2βΊ
using "*"(4) t1'_t2'(4,5) by auto
with lemma1_3 have "?h (s1, s2) < ?h (t1', t2')"
using βΉs1 β subterms' bβΊ βΉs2 β subterms' bβΊ t1'_t2'_subterms
by (auto simp: min_def)
ultimately show ?thesis
using arg_min_least[OF βΉfinite ΞβΊ βΉΞ β {}βΊ]
using βΉ(t1', t2') β ΞβΊ βΉ?h (t1', t2') = ?h (t1, t2)βΊ t1_t2
by (metis (mono_tags, lifting) le_antisym le_eq_less_or_eq nat_neq_iff)
qed
qed
with assms subterms show ?thesis
unfolding Ξ_def by blast
qed
qed
lemma realisation_if_AF_mem:
assumes "sat b"
assumes "AF (s ββ©s t) β set b"
shows "realise s ββ realise t"
proof
assume "realise s ββ realise t"
from assms have "s β base_vars b βͺ subterms' b"
"t β base_vars b βͺ subterms' b"
using in_subterms'_if_AF_mem_in_branch[OF wf_branch] by blast+
from dominates_if_mem_realisation[OF βΉrealise s ββ realise tβΊ]
obtain s' where "s' ββbgraph bβ t" "realise s = realise s'"
by blast
then have "AT (s' ββ©s t) β set b"
unfolding bgraph_def Let_def by auto
with assms lexpands_eq.intros(5)[THEN lexpands.intros(6)] have "AF (s' =β©s s) β set b"
unfolding sat_def using lin_satD by fastforce
from realisation_if_AF_eq[OF βΉsat bβΊ this] βΉrealise s = realise s'βΊ show False
by simp
qed
lemma realisation_Empty: "realise (β
n) = 0"
proof -
from bopen have "AT (s ββ©s β
n) β set b" for s
using bclosed.intros by blast
then have "parents (bgraph b) (β
n) = {}"
unfolding bgraph_def Let_def by auto
moreover
have "(β
n) β base_vars b"
proof -
have "(β
n) β Var ` pwits b"
using pwits_def wits_def by blast
moreover have "(β
n) β urelems b"
unfolding urelems_def using wf_branch[THEN wf_branch_not_Nil] last_in_set
using is_Var_if_urelem' by fastforce
ultimately show ?thesis
unfolding base_vars_def by blast
qed
then have "(β
n) β subterms' b β¨ (β
n) β verts (bgraph b)"
by (simp add: verts_bgraph)
ultimately show "realise (β
n) = 0"
by (auto simp: verts_bgraph)
qed
lemma realisation_Union:
assumes "sat b"
assumes "t1 ββ©s t2 β subterms b"
shows "realise (t1 ββ©s t2) = realise t1 β realise t2"
using assms
proof -
from assms have mem_subterms_last: "t1 ββ©s t2 β subterms (last b)"
using mem_subterms_fm_last_if_mem_subterms_branch[OF wf_branch]
by simp
note not_urelem_comps_if_compound[where ?f="(ββ©s)", OF assms(2), simplified]
moreover note subterms_fmD(1,2)[OF mem_subterms_last]
then have "t1 β Var ` pwits b" "t2 β Var ` pwits b"
unfolding pwits_def wits_def
using pset_term.set_intros(1) mem_vars_fm_if_mem_subterms_fm by fastforce+
ultimately have "t1 β subterms' b" "t2 β subterms' b"
unfolding subterms'_def base_vars_def
using assms(2) by (auto dest: subterms_branchD)
from assms(2) have "t1 ββ©s t2 β subterms' b"
using base_vars_subs_vars base_vars_Un_subterms'_eq_subterms by blast
have "realise (t1 ββ©s t2) β€ realise t1 β realise t2"
proof
fix e assume "e ββ realise (t1 ββ©s t2)"
then obtain s where s: "e = realise s" "s ββbgraph bβ (t1 ββ©s t2)"
using dominates_if_mem_realisation βΉt1 ββ©s t2 β subterms' bβΊ
by auto
then have "AT (s ββ©s t1 ββ©s t2) β set b"
unfolding bgraph_def Let_def by auto
with βΉsat bβΊ consider "AT (s ββ©s t1) β set b" | "AF (s ββ©s t1) β set b"
unfolding sat_def using bexpands_nowit.intros(3)[OF _ mem_subterms_last, THEN bexpands.intros(1)]
by blast
then show "e ββ realise t1 β realise t2"
proof(cases)
case 1
with s show ?thesis using realisation_if_AT_mem by auto
next
case 2
from βΉsat bβΊ lexpands_un.intros(4)[OF βΉAT (s ββ©s t1 ββ©s t2) β set bβΊ this]
have "AT (s ββ©s t2) β set b"
unfolding sat_def using lin_satD lexpands.intros(2) by force
with s show ?thesis using realisation_if_AT_mem by auto
qed
qed
moreover have "realise t1 β realise t2 β€ realise (t1 ββ©s t2)"
proof
fix e assume "e ββ realise t1 β realise t2"
with βΉt1 β subterms' bβΊ βΉt2 β subterms' bβΊ consider
s1 where "e = realise s1" "s1 ββbgraph bβ t1" |
s2 where "e = realise s2" "s2 ββbgraph bβ t2"
using dominates_if_mem_realisation by force
then show "e ββ realise (t1 ββ©s t2)"
proof(cases)
case 1
then have "AT (s1 ββ©s t1) β set b"
unfolding bgraph_def Let_def by auto
from βΉsat bβΊ lexpands_un.intros(2)[OF this mem_subterms_last, THEN lexpands.intros(2)]
have "AT (s1 ββ©s t1 ββ©s t2) β set b"
unfolding sat_def using lin_satD by force
with 1 realisation_if_AT_mem[OF this] show ?thesis
by blast
next
case 2
then have "AT (s2 ββ©s t2) β set b"
unfolding bgraph_def Let_def by auto
from βΉsat bβΊ lexpands_un.intros(3)[OF this mem_subterms_last, THEN lexpands.intros(2)]
have "AT (s2 ββ©s t1 ββ©s t2) β set b"
unfolding sat_def using lin_satD by force
with 2 realisation_if_AT_mem[OF this] show ?thesis
by blast
qed
qed
ultimately show ?thesis by blast
qed
lemma realisation_Inter:
assumes "sat b"
assumes "t1 ββ©s t2 β subterms b"
shows "realise (t1 ββ©s t2) = realise t1 β realise t2"
using assms
proof -
from assms have mem_subterms_last: "t1 ββ©s t2 β subterms (last b)"
using mem_subterms_fm_last_if_mem_subterms_branch[OF wf_branch]
by simp
note not_urelem_comps_if_compound[where ?f="(ββ©s)", OF assms(2), simplified]
moreover note subterms_fmD(3,4)[OF mem_subterms_last]
then have "t1 β Var ` pwits b" "t2 β Var ` pwits b"
unfolding pwits_def wits_def
using pset_term.set_intros(1) mem_vars_fm_if_mem_subterms_fm by fastforce+
ultimately have t1_t2_subterms': "t1 β subterms' b" "t2 β subterms' b"
unfolding subterms'_def base_vars_def
using assms(2) by (auto dest: subterms_branchD)
from assms(2) have "t1 ββ©s t2 β subterms' b"
using base_vars_subs_vars base_vars_Un_subterms'_eq_subterms by blast
have "realise (t1 ββ©s t2) β€ realise t1 β realise t2"
proof
fix e assume "e ββ realise (t1 ββ©s t2)"
with βΉt1 ββ©s t2 β subterms' bβΊ obtain s
where s: "e = realise s" "s ββbgraph bβ (t1 ββ©s t2)"
using dominates_if_mem_realisation by auto
then have "AT (s ββ©s t1 ββ©s t2) β set b"
unfolding bgraph_def Let_def by auto
with βΉsat bβΊ lexpands_int.intros(1)[OF this, THEN lexpands.intros(3)]
have "AT (s ββ©s t1) β set b" "AT (s ββ©s t2) β set b"
unfolding sat_def using lin_satD by force+
from this[THEN realisation_if_AT_mem] s show "e ββ realise t1 β realise t2"
by auto
qed
moreover have "realise t1 β realise t2 β€ realise (t1 ββ©s t2)"
proof
fix e assume "e ββ realise t1 β realise t2"
with βΉt1 β subterms' bβΊ βΉt2 β subterms' bβΊ obtain s1 s2 where s1_s2:
"e = realise s1" "s1 ββbgraph bβ t1"
"e = realise s2" "s2 ββbgraph bβ t2"
using dominates_if_mem_realisation by auto metis
then have "AT (s1 ββ©s t1) β set b" "AT (s2 ββ©s t2) β set b"
unfolding bgraph_def Let_def by auto
moreover have "AT (s1 ββ©s t2) β set b"
proof -
from βΉsat bβΊ have "AT (s1 ββ©s t2) β set b β¨ AF (s1 ββ©s t2) β set b"
unfolding sat_def
using bexpands_nowit.intros(4)[OF βΉAT (s1 ββ©s t1) β set bβΊ mem_subterms_last]
using bexpands.intros(1) by blast
moreover from βΉsat bβΊ s1_s2 have False if "AF (s1 ββ©s t2) β set b"
proof -
note lexpands_eq.intros(5)[OF βΉAT (s2 ββ©s t2) β set bβΊ that, THEN lexpands.intros(6)]
with realisation_if_AF_eq[OF βΉsat bβΊ, of s2 s1] have "realise s2 β realise s1"
using βΉsat bβΊ by (auto simp: sat_def lin_satD)
with βΉe = realise s1βΊ βΉe = realise s2βΊ show False by simp
qed
ultimately show "AT (s1 ββ©s t2) β set b" by blast
qed
ultimately have "AT (s1 ββ©s t1 ββ©s t2) β set b"
using βΉsat bβΊ lexpands_int.intros(6)[OF _ _ mem_subterms_last, THEN lexpands.intros(3)]
unfolding sat_def by (fastforce simp: lin_satD)
from realisation_if_AT_mem[OF this] show "e ββ realise (t1 ββ©s t2)"
unfolding βΉe = realise s1βΊ
by simp
qed
ultimately show ?thesis by blast
qed
lemma realisation_Diff:
assumes "sat b"
assumes "s -β©s t β subterms b"
shows "realise (s -β©s t) = realise s - realise t"
using assms
proof -
from assms have mem_subterms_last: "s -β©s t β subterms (last b)"
using mem_subterms_fm_last_if_mem_subterms_branch[OF wf_branch]
by simp
note not_urelem_comps_if_compound[where ?f="(-β©s)", OF assms(2), simplified]
moreover note subterms_fmD(5,6)[OF mem_subterms_last]
then have "s β Var ` pwits b" "t β Var ` pwits b"
unfolding pwits_def wits_def
using pset_term.set_intros(1) mem_vars_fm_if_mem_subterms_fm by fastforce+
ultimately have "s β subterms' b" "t β subterms' b"
unfolding subterms'_def base_vars_def
using assms(2) by (auto dest: subterms_branchD)
from assms(2) have "s -β©s t β subterms' b"
using base_vars_subs_vars base_vars_Un_subterms'_eq_subterms by blast
have "realise (s -β©s t) β€ realise s - realise t"
proof
fix e assume "e ββ realise (s -β©s t)"
then obtain u where u: "e = realise u" "u ββbgraph bβ (s -β©s t)"
using dominates_if_mem_realisation βΉs -β©s t β subterms' bβΊ by auto
then have "AT (u ββ©s s -β©s t) β set b"
unfolding bgraph_def Let_def by auto
with βΉsat bβΊ lexpands_diff.intros(1)[OF this, THEN lexpands.intros(4)]
have "AT (u ββ©s s) β set b" "AF (u ββ©s t) β set b"
unfolding sat_def using lin_satD by force+
with u show "e ββ realise s - realise t"
using βΉsat bβΊ realisation_if_AT_mem realisation_if_AF_mem
by auto
qed
moreover have "realise s - realise t β€ realise (s -β©s t)"
proof
fix e assume "e ββ realise s - realise t"
then obtain u where u:
"e = realise u" "u ββbgraph bβ s" "Β¬ u ββbgraph bβ t"
using dominates_if_mem_realisation βΉs β subterms' bβΊ βΉt β subterms' bβΊ by auto
then have "AT (u ββ©s s) β set b"
unfolding bgraph_def Let_def by auto
moreover have "AF (u ββ©s t) β set b"
proof -
from βΉsat bβΊ have "AT (u ββ©s t) β set b β¨ AF (u ββ©s t) β set b"
unfolding sat_def using bexpands_nowit.intros(5)[OF βΉAT (u ββ©s s) β set bβΊ mem_subterms_last]
using bexpands.intros(1) by blast
moreover from u(3) have False if "AT (u ββ©s t) β set b"
using that unfolding Let_def bgraph_def by (auto simp: arcs_ends_def arc_to_ends_def)
ultimately show "AF (u ββ©s t) β set b"
by blast
qed
ultimately have "AT (u ββ©s s -β©s t) β set b"
using βΉsat bβΊ lexpands_diff.intros(6)[OF _ _ mem_subterms_last, THEN lexpands.intros(4)]
unfolding sat_def by (fastforce simp: lin_satD)
from realisation_if_AT_mem[OF this] show "e ββ realise (s -β©s t)"
unfolding βΉe = realise uβΊ
by simp
qed
ultimately show ?thesis by blast
qed
lemma realisation_Single:
assumes "sat b"
assumes "Single t β subterms b"
shows "realise (Single t) = HF {realise t}"
using assms
proof -
from assms have mem_subterms_last: "Single t β subterms (last b)"
using mem_subterms_fm_last_if_mem_subterms_branch[OF wf_branch]
by simp
have "Single t β subterms' b"
proof -
from urelems_subs_vars have "Single t β base_vars b"
unfolding base_vars_def by blast
then show ?thesis
by (simp add: assms(2) subterms'_def)
qed
have "realise (Single t) β€ HF {realise t}"
proof
fix e assume "e ββ realise (Single t)"
then obtain s where s: "e = realise s" "s ββbgraph bβ Single t"
using dominates_if_mem_realisation βΉSingle t β subterms' bβΊ by auto
then have "AT (s ββ©s Single t) β set b"
unfolding bgraph_def Let_def by auto
with βΉsat bβΊ lexpands_single.intros(2)[OF this, THEN lexpands.intros(5)]
have "AT (s =β©s t) β set b"
unfolding sat_def using lin_satD by fastforce
with s show "e ββ HF {realise t}"
using realisation_if_AT_eq βΉsat bβΊ[unfolded sat_def]
by auto
qed
moreover have "HF {realise t} β€ realise (Single t)"
proof
fix e assume "e ββ HF {realise t}"
then have "e = realise t"
by simp
from lexpands_single.intros(1)[OF mem_subterms_last, THEN lexpands.intros(5)] βΉsat bβΊ
have "AT (t ββ©s Single t) β set b"
unfolding sat_def using lin_satD by fastforce
from realisation_if_AT_mem[OF this] βΉe = realise tβΊ
show "e ββ realise (Single t)"
by simp
qed
ultimately show ?thesis by blast
qed
lemmas realisation_simps =
realisation_Empty realisation_Union realisation_Inter realisation_Diff realisation_Single
end
subsection βΉCoherenceβΊ
lemma (in open_branch) Iβ©sβ©t_realisation_eq_realisation:
assumes "sat b" "t β subterms b"
shows "Iβ©sβ©t (Ξ»x. realise (Var x)) t = realise t"
using assms
by (induction t) (force simp: realisation_simps dest: subterms_branchD)+
lemma (in open_branch) coherence:
assumes "sat b" "Ο β set b"
shows "interp Iβ©sβ©a (Ξ»x. realise (Var x)) Ο"
using assms
proof(induction "size Ο" arbitrary: Ο rule: less_induct)
case less
then show ?case
proof(cases Ο)
case (Atom a)
then show ?thesis
proof(cases a)
case (Elem s t)
with Atom less have "s β subterms b" "t β subterms b"
using AT_mem_subterms_branchD by blast+
with Atom Elem less show ?thesis
using Iβ©sβ©t_realisation_eq_realisation[OF βΉsat bβΊ] realisation_if_AT_mem by auto
next
case (Equal s t)
with Atom less have "s β subterms b" "t β subterms b"
using AT_eq_subterms_branchD by blast+
with Atom Equal less satD(1)[OF βΉsat bβΊ] show ?thesis
using Iβ©sβ©t_realisation_eq_realisation[OF βΉsat bβΊ] realisation_if_AT_eq by auto
qed
next
case (And Ο1 Ο2)
with βΉΟ β set bβΊ βΉsat bβΊ[THEN satD(1), THEN lin_satD] have "Ο1 β set b" "Ο2 β set b"
using lexpands_fm.intros(1)[THEN lexpands.intros(1)] by fastforce+
with And less show ?thesis by simp
next
case (Or Ο1 Ο2)
with βΉΟ β set bβΊ βΉsat bβΊ[THEN satD(2)] have "Ο1 β set b β¨ Neg Ο1 β set b"
using bexpands_nowit.intros(1)[THEN bexpands.intros(1)]
by blast
with less Or βΉsat bβΊ[THEN satD(1), THEN lin_satD] have "Ο1 β set b β¨ Ο2 β set b"
using lexpands_fm.intros(3)[THEN lexpands.intros(1)] by fastforce
with Or less show ?thesis
by force
next
case (Neg Ο')
show ?thesis
proof(cases Ο')
case (Atom a)
then show ?thesis
proof(cases a)
case (Elem s t)
with Atom Neg less have "s β subterms b" "t β subterms b"
using AF_mem_subterms_branchD by blast+
with Neg Atom Elem less show ?thesis
using Iβ©sβ©t_realisation_eq_realisation realisation_if_AF_mem βΉsat bβΊ by auto
next
case (Equal s t)
with Atom Neg less have "s β subterms b" "t β subterms b"
using AF_eq_subterms_branchD by blast+
with Neg Atom Equal less show ?thesis
using Iβ©sβ©t_realisation_eq_realisation realisation_if_AF_eq βΉsat bβΊ by auto
qed
next
case (And Ο1 Ο2)
with Neg βΉsat bβΊ[THEN satD(2)] less have "Ο1 β set b β¨ Neg Ο1 β set b"
using bexpands_nowit.intros(2)[THEN bexpands.intros(1)] by blast
with βΉsat bβΊ[THEN satD(1), THEN lin_satD] Neg And less
have "Neg Ο2 β set b β¨ Neg Ο1 β set b"
using lexpands_fm.intros(5)[THEN lexpands.intros(1)] by fastforce
with Neg And less show ?thesis by force
next
case (Or Ο1 Ο2)
with βΉΟ β set bβΊ Neg βΉsat bβΊ[THEN satD(1), THEN lin_satD]
have "Neg Ο1 β set b" "Neg Ο2 β set b"
using lexpands_fm.intros(2)[THEN lexpands.intros(1)] by fastforce+
moreover have "size (Neg Ο1) < size Ο" "size (Neg Ο2) < size Ο"
using Neg Or by simp_all
ultimately show ?thesis using Neg Or less by force
next
case Neg': (Neg Ο'')
with βΉΟ β set bβΊ Neg βΉsat bβΊ[THEN satD(1), THEN lin_satD] have "Ο'' β set b"
using lexpands_fm.intros(7)[THEN lexpands.intros(1)] by fastforce+
with Neg Neg' less show ?thesis by simp
qed
qed
qed
section βΉSoundness of the CalculusβΊ
subsection βΉSoundness of ClosednessβΊ
lemmas wf_trancl_hmem_rel = wf_trancl[OF wf_hmem_rel]
lemma trancl_hmem_rel_not_refl: "(x, x) β hmem_relβ§+"
using wf_trancl_hmem_rel by simp
lemma mem_trancl_elts_rel_if_member_seq:
assumes "member_seq s cs t"
assumes "cs β []"
assumes "βa β set cs. Iβ©sβ©a M a"
shows "(Iβ©sβ©t M s, Iβ©sβ©t M t) β hmem_relβ§+"
using assms
proof(induction rule: member_seq.induct)
case (2 s s' u cs t)
show ?case
proof(cases cs)
case Nil
with 2 show ?thesis
unfolding hmem_rel_def by auto
next
case (Cons c cs')
with 2 have "(Iβ©sβ©t M u, Iβ©sβ©t M t) β hmem_relβ§+"
by simp
moreover from 2 have "Iβ©sβ©a M (s ββ©s u)"
by simp
ultimately show ?thesis
unfolding hmem_rel_def by (simp add: trancl_into_trancl2)
qed
qed simp_all
lemma bclosed_sound:
assumes "bclosed b"
shows "βΟ β set b. Β¬ interp Iβ©sβ©a M Ο"
using assms
proof -
have False if "βΟ β set b. interp Iβ©sβ©a M Ο"
using assms that
proof(induction rule: bclosed.induct)
case (memberCycle cs b)
then have "βa β set cs. Iβ©sβ©a M a"
unfolding Atoms_def by fastforce
from memberCycle obtain s where "member_seq s cs s"
using member_cycle.elims(2) by blast
with memberCycle βΉβa β set cs. Iβ©sβ©a M aβΊ have "(Iβ©sβ©t M s, Iβ©sβ©t M s) β hmem_relβ§+"
using mem_trancl_elts_rel_if_member_seq member_cycle.simps(2) by blast
with trancl_hmem_rel_not_refl show ?case
by blast
qed (use interp.simps(4) in βΉfastforce+βΊ)
then show ?thesis
by blast
qed
lemma types_term_lt_if_member_seq:
fixes cs :: "'a pset_atom list"
assumes "βa β set cs. v β’ a"
assumes "member_seq s cs t" "cs β []"
shows "βls lt. v β’ s : ls β§ v β’ t : lt β§ ls < lt"
using assms
proof(induction s cs t rule: member_seq.induct)
case (2 s s' u cs t)
then show ?case
proof(cases cs)
case (Cons c cs')
with 2 obtain lu lt where "v β’ u : lu" "v β’ t : lt" "lu < lt"
by auto
moreover from 2 obtain ls where "v β’ s : ls" "ls < lu"
using βΉv β’ u : luβΊ by (auto simp: types_pset_atom.simps dest: types_term_unique)
ultimately show ?thesis
by fastforce
qed (fastforce simp: types_pset_atom.simps)
qed auto
lemma no_member_cycle_if_types_last:
fixes b :: "'a branch"
assumes "wf_branch b"
assumes "βv. v β’ last b"
shows "Β¬ (member_cycle cs β§ set cs β Atoms (set b))"
proof
presume "member_cycle cs" "set cs β Atoms (set b)"
then obtain s where "member_seq s cs s" "cs β []"
using member_cycle.elims(2) by blast
moreover from assms obtain v where "βΟ β set b. v β’ Ο"
using types_urelems by blast
with βΉset cs β Atoms (set b)βΊ have "βa β set cs. v β’ a"
unfolding Atoms_def by (auto dest!: types_fmD(6))
ultimately show False
using types_term_lt_if_member_seq types_term_unique by blast
qed simp_all
subsection βΉSoundness of the Expansion RulesβΊ
lemma lexpands_sound:
assumes "lexpands b' b"
assumes "Ο β set b'"
assumes "βΟ. Ο β set b βΉ interp Iβ©sβ©a M Ο"
shows "interp Iβ©sβ©a M Ο"
using assms
proof(induction rule: lexpands.induct)
case (1 b' b)
then show ?case
by (induction rule: lexpands_fm.induct)
(metis empty_iff empty_set interp.simps(2,3,4) set_ConsD)+
next
case (2 b' b)
then show ?case
proof(induction rule: lexpands_un.induct)
case (4 s t1 t2 branch)
with this(1)[THEN this(4)] show ?case
by force
next
case (5 s t1 t2 branch)
with this(1)[THEN this(4)] show ?case
by force
qed force+
next
case (3 b' b)
then show ?case
proof(induction rule: lexpands_int.induct)
case (4 s t1 t2 branch)
with this(1)[THEN this(4)] show ?case
by force
next
case (5 s t1 t2 branch)
with this(1)[THEN this(4)] show ?case
by force
qed force+
next
case (4 b' b)
then show ?case
proof(induction rule: lexpands_diff.induct)
case (4 s t1 t2 branch)
with this(1)[THEN this(4)] show ?case by force
next
case (5 s t1 t2 branch)
with this(1)[THEN this(4)] show ?case by force
qed force+
next
case (5 b' b)
then show ?case
by (induction rule: lexpands_single.induct) force+
next
case (6 b' b)
then show ?case
proof(induction rule: lexpands_eq_induct')
case (subst t1 t2 t1' t2' p l b)
with this(1,2)[THEN this(6)] show ?case
by (cases l; cases p) auto
next
case (neq s t s' b)
with this(1,2)[THEN this(4)] show ?case by force
qed
qed
lemma bexpands_nowit_sound:
assumes "bexpands_nowit bs' b"
assumes "βΟ. Ο β set b βΉ interp Iβ©sβ©a M Ο"
shows "βb' β bs'. βΟ β set b'. interp Iβ©sβ©a M Ο"
using assms
by (induction rule: bexpands_nowit.induct) force+
lemma Iβ©sβ©t_upd_eq_if_not_mem_vars_term:
assumes "x β vars t"
shows "Iβ©sβ©t (M(x := y)) t = Iβ©sβ©t M t"
using assms by (induction t) auto
lemma Iβ©sβ©a_upd_eq_if_not_mem_vars_atom:
assumes "x β vars a"
shows "Iβ©sβ©a (M(x := y)) a = Iβ©sβ©a M a"
using assms
by (cases a) (auto simp: Iβ©sβ©t_upd_eq_if_not_mem_vars_term)
lemma interp_upd_eq_if_not_mem_vars_fm:
assumes "x β vars Ο"
shows "interp Iβ©sβ©a (M(x := y)) Ο = interp Iβ©sβ©a M Ο"
using assms
by (induction Ο) (auto simp: Iβ©sβ©a_upd_eq_if_not_mem_vars_atom)
lemma bexpands_wit_sound:
assumes "bexpands_wit s t x bs' b"
assumes "βΟ. Ο β set b βΉ interp Iβ©sβ©a M Ο"
shows "βM. βb' β bs'. βΟ β set (b' @ b). interp Iβ©sβ©a M Ο"
using assms
proof (induction rule: bexpands_wit.induct)
let ?bs'="{[AT (Var x ββ©s s), AF (Var x ββ©s t)],
[AT (Var x ββ©s t), AF (Var x ββ©s s)]}"
case (1 b)
with this(1)[THEN this(9)] have "Iβ©sβ©t M s β Iβ©sβ©t M t"
by auto
then obtain y where y:
"y ββ Iβ©sβ©t M s β§ y ββ Iβ©sβ©t M t β¨
y ββ Iβ©sβ©t M t β§ y ββ Iβ©sβ©t M s"
by auto
have "x β vars s" "x β vars t"
using 1 by (auto simp: vars_fm_vars_branchI)
then have "Iβ©sβ©t (M(x := y)) s = Iβ©sβ©t M s" "Iβ©sβ©t (M(x := y)) t = Iβ©sβ©t M t"
using Iβ©sβ©t_upd_eq_if_not_mem_vars_term by metis+
then have "βb' β ?bs'. βΟ β set b'. interp Iβ©sβ©a (M(x := y)) Ο"
using 1 y by auto
moreover have "βΟ β set b. interp Iβ©sβ©a (M(x := y)) Ο"
using "1"(9) βΉx β vars bβΊ interp_upd_eq_if_not_mem_vars_fm
by (metis vars_fm_vars_branchI)
ultimately show ?case
by auto (metis fun_upd_same)+
qed
lemma bexpands_sound:
assumes "bexpands bs' b"
assumes "βΟ. Ο β set b βΉ interp Iβ©sβ©a M Ο"
shows "βM. βb' β bs'. βΟ β set (b' @ b). interp Iβ©sβ©a M Ο"
using assms
proof(induction rule: bexpands.induct)
case (1 bs' b)
with bexpands_nowit_sound[OF this(1)] have "βb' β bs'. βΟ β set b'. interp Iβ©sβ©a M Ο"
by blast
with 1 show ?case
by auto
next
case (2 t1 t2 x bs b)
then show ?case using bexpands_wit_sound by metis
qed
section βΉUpper Bounding the Cardinality of a BranchβΊ
lemma Ex_bexpands_wits_if_in_wits:
assumes "wf_branch b"
assumes "x β wits b"
obtains t1 t2 bs b2 b1 where
"expandss b (b2 @ b1)" "bexpands_wit t1 t2 x bs b1" "b2 β bs" "expandss b1 [last b]"
"x β wits b1" "wits (b2 @ b1) = insert x (wits b1)"
proof -
from assms obtain Ο where "expandss b [Ο]"
unfolding wf_branch_def by blast
then have "last b = Ο"
by simp
from βΉexpandss b [Ο]βΊ βΉx β wits bβΊ that show ?thesis
unfolding βΉlast b = ΟβΊ
proof(induction b "[Ο]" rule: expandss.induct)
case 1
then show ?case by simp
next
case (2 b2 b1)
with expandss_mono have "b1 β []"
by fastforce
with lexpands_wits_eq[OF βΉlexpands b2 b1βΊ this] 2 show ?case
by (metis (no_types, lifting) expandss.intros(2))
next
case (3 bs _ b2)
then show ?case
proof(induction rule: bexpands.induct)
case (1 bs b1)
with expandss_mono have "b1 β []"
by fastforce
with bexpands_nowit_wits_eq[OF βΉbexpands_nowit bs b1βΊ βΉb2 β bsβΊ this] 1 show ?case
by (metis bexpands.intros(1) expandss.intros(3))
next
case (2 t1 t2 y bs b1)
show ?case
proof(cases "x β wits b1")
case True
from 2 have "expandss (b2 @ b1) b1"
using expandss.intros(3)[OF _ "2.prems"(1)] bexpands.intros(2)[OF "2.hyps"]
by (metis expandss.intros(1))
with True 2 show ?thesis
using expandss_trans by blast
next
case False
from 2 have "b1 β []"
using expandss_mono by fastforce
with bexpands_witD[OF "2"(1)] "2"(2-) have "wits (b2 @ b1) = insert y (wits b1)"
unfolding wits_def
by (metis "2.hyps" bexpands_wit_wits_eq wits_def)
moreover from βΉy β vars_branch b1βΊ have "y β wits b1"
unfolding wits_def by simp
moreover from calculation have "y = x"
using False 2 by simp
ultimately show ?thesis
using 2 by (metis expandss.intros(1))
qed
qed
qed
qed
lemma card_wits_ub_if_wf_branch:
assumes "wf_branch b"
shows "card (wits b) β€ (card (subterms (last b)))β§2"
proof -
from assms obtain Ο where "expandss b [Ο]"
unfolding wf_branch_def by blast
with wf_branch_not_Nil[OF assms] have [simp]: "last b = Ο"
using expandss_last_eq by force
have False if card_gt: "card (wits b) > (card (subterms Ο))β§2"
proof -
define ts where "ts β‘ (Ξ»x. SOME t1_t2. βbs b2 b1.
expandss b (b2 @ b1) β§ b2 β bs β§ bexpands_wit (fst t1_t2) (snd t1_t2) x bs b1 β§ expandss b1 [Ο])"
from βΉexpandss b [Ο]βΊ βΉlast b = ΟβΊ
have *: "βt1_t2 bs b2 b1.
expandss b (b2 @ b1) β§ b2 β bs β§ bexpands_wit (fst t1_t2) (snd t1_t2) x bs b1 β§ expandss b1 [Ο]"
if "x β wits b" for x
using that Ex_bexpands_wits_if_in_wits[OF βΉwf_branch bβΊ that] by (metis fst_conv snd_conv)
have ts_wd:
"βbs b2 b1. expandss b (b2 @ b1) β§ b2 β bs β§ bexpands_wit t1 t2 x bs b1 β§ expandss b1 [Ο]"
if "ts x = (t1, t2)" "x β wits b" for t1 t2 x
using exE_some[OF * that(1)[THEN eq_reflection, symmetric, unfolded ts_def], OF that(2)]
by simp
with βΉlast b = ΟβΊ βΉexpandss b [Ο]βΊ have in_subterms_fm:
"t1 β subterms Ο" "t2 β subterms Ο"
if "ts x = (t1, t2)" "x β wits b" for t1 t2 x
using that bexpands_witD
by (metis expandss_last_eq list.discI)+
have "Β¬ inj_on ts (wits b)"
proof -
from in_subterms_fm have "ts ` wits b β subterms Ο Γ subterms Ο"
by (intro subrelI) (metis imageE mem_Sigma_iff)
then have "card (ts ` wits b) β€ card (subterms Ο Γ subterms Ο)"
by (intro card_mono) (simp_all add: finite_subterms_fm)
moreover have "card (subterms Ο Γ subterms Ο) = (card (subterms Ο))β§2"
unfolding card_cartesian_product by algebra
ultimately show "Β¬ inj_on ts (wits b)"
using card_gt by (metis card_image linorder_not_less)
qed
from βΉΒ¬ inj_on ts (wits b)βΊ obtain x t1 t2 xb1 xbs2 xb2 y yb1 ybs2 yb2 where x_y:
"x β y" "x β wits b" "y β wits b"
"expandss xb1 [Ο]" "bexpands_wit t1 t2 x xbs2 xb1" "xb2 β xbs2" "expandss b (xb2 @ xb1)"
"expandss yb1 [Ο]" "bexpands_wit t1 t2 y ybs2 yb1" "yb2 β ybs2" "expandss b (yb2 @ yb1)"
unfolding inj_on_def by (metis ts_wd prod.exhaust)
have "xb2 β yb2"
using x_y(5)[THEN bexpands_witD(1)] x_y(9)[THEN bexpands_witD(1)] x_y(1,6,10)
by auto
moreover from x_y have "suffix (xb2 @ xb1) (yb2 @ yb1) β¨ suffix (yb2 @ yb1) (xb2 @ xb1)"
using expandss_suffix suffix_same_cases by blast
then have "suffix (xb2 @ xb1) yb1 β¨ suffix (yb2 @ yb1) xb1"
using x_y(5)[THEN bexpands_witD(1)] x_y(9)[THEN bexpands_witD(1)] x_y(1,6,10)
by (auto simp: suffix_Cons)
ultimately show False
using bexpands_witD(1,5,6)[OF x_y(5)] bexpands_witD(1,5,6)[OF x_y(9)] x_y(6,10)
by (auto dest!: set_mono_suffix)
qed
then show ?thesis
using linorder_not_le βΉlast b = ΟβΊ by blast
qed
lemma card_subterms_branch_ub_if_wf_branch:
assumes "wf_branch b"
shows "card (subterms b) β€ card (subterms (last b)) + card (wits b)"
unfolding subterms_branch_eq_if_wf_branch[OF assms, unfolded wits_subterms_def]
by (simp add: assms card_Un_disjoint card_image_le finite_wits finite_subterms_fm
wits_subterms_last_disjnt)
lemma card_literals_branch_if_wf_branch:
assumes "wf_branch b"
shows "card {a β set b. is_literal a}
β€ 2 * (2 * (card (subterms (last b)) + card (wits b))β§2)"
proof -
have "card {a β set b. is_literal a}
β€ card (pset_atoms_branch b) + card (pset_atoms_branch b)" (is "card ?A β€ _")
proof -
have "?A = {AT a |a. AT a β set b}
βͺ {AF a |a. AF a β set b}" (is "_ = ?ATs βͺ ?AFs")
by auto (metis is_literal.elims(2))
moreover have
"?ATs β AT ` pset_atoms_branch b" "?AFs β AF ` pset_atoms_branch b"
by force+
moreover from calculation have "finite ?ATs" "finite ?AFs"
by (simp_all add: finite_surj[OF finite_pset_atoms_branch])
moreover have "?ATs β© ?AFs = {}"
by auto
ultimately show ?thesis
by (simp add: add_mono card_Un_disjoint finite_pset_atoms_branch surj_card_le)
qed
then have "card ?A β€ 2 * card (pset_atoms_branch b)"
by simp
moreover
have "atoms Ο β
case_prod Elem ` (subterms Ο Γ subterms Ο)
βͺ case_prod Equal ` (subterms Ο Γ subterms Ο)" for Ο :: "'a pset_fm"
proof(induction Ο)
case (Atom x)
then show ?case by (cases x) auto
qed auto
then have "pset_atoms_branch b β
case_prod Elem ` (subterms b Γ subterms b)
βͺ case_prod Equal ` (subterms b Γ subterms b)" (is "_ β ?Els βͺ ?Eqs")
unfolding subterms_branch_def
by force
have "card (pset_atoms_branch b)
β€ (card (subterms b))β§2 + (card (subterms b))β§2"
proof -
from finite_subterms_branch have "finite (subterms b Γ subterms b)"
using finite_cartesian_product by auto
then have "finite ?Els" "finite ?Eqs"
by blast+
moreover have "inj_on (case_prod Elem) A" "inj_on (case_prod Equal) A"
for A :: "('a pset_term Γ 'a pset_term) set"
unfolding inj_on_def by auto
ultimately have "card ?Els = (card (subterms b))β§2" "card ?Eqs = (card (subterms b))β§2"
using card_image[where ?A="subterms b Γ subterms b"] card_cartesian_product
unfolding power2_eq_square by metis+
with card_mono[OF _ βΉpset_atoms_branch b β ?Els βͺ ?EqsβΊ] show ?thesis
using βΉfinite ?ElsβΊ βΉfinite ?EqsβΊ
by (metis card_Un_le finite_UnI sup.boundedE sup_absorb2)
qed
then have "card (pset_atoms_branch b) β€ 2 * (card (subterms b))β§2"
by simp
ultimately show ?thesis
using card_subterms_branch_ub_if_wf_branch[OF assms]
by (meson dual_order.trans mult_le_mono2 power2_nat_le_eq_le)
qed
lemma lexpands_not_literal_mem_subfms_last:
defines "P β‘ (Ξ»b. βΟ β set b. Β¬ is_literal Ο
βΆ Ο β subfms (last b) β¨ Ο β Neg ` subfms (last b))"
assumes "lexpands b' b" "b β []"
assumes "P b"
shows "P (b' @ b)"
using assms(2-)
by (induction b' b rule: lexpands_induct) (fastforce simp: P_def dest: subfmsD)+
lemma bexpands_not_literal_mem_subfms_last:
defines "P β‘ (Ξ»b. βΟ β set b. Β¬ is_literal Ο
βΆ Ο β subfms (last b) β¨ Ο β Neg ` subfms (last b))"
assumes "bexpands bs b" "b' β bs" "b β []"
assumes "P b"
shows "P (b' @ b)"
using assms(2-)
proof(induction bs b rule: bexpands.induct)
case (1 bs' b)
then show ?case
apply(induction rule: bexpands_nowit.induct)
apply(fastforce simp: P_def dest: subfmsD)+
done
next
case (2 t1 t2 x bs' b)
then show ?case
apply(induction rule: bexpands_wit.induct)
apply(fastforce simp: P_def dest: subfmsD)+
done
qed
lemma expandss_not_literal_mem_subfms_last:
defines "P β‘ (Ξ»b. βΟ β set b. Β¬ is_literal Ο
βΆ Ο β subfms (last b) β¨ Ο β Neg ` subfms (last b))"
assumes "expandss b' b" "b β []"
assumes "P b"
shows "P b'"
using assms(2-)
proof(induction b' b rule: expandss.induct)
case (2 b3 b2 b1)
then have "b2 β []"
using expandss_suffix suffix_bot.extremum_uniqueI by blast
with 2 show ?case
using lexpands_not_literal_mem_subfms_last unfolding P_def by blast
next
case (3 bs b2 b3 b1)
then have "b2 β []"
using expandss_suffix suffix_bot.extremum_uniqueI by blast
with 3 show ?case
using bexpands_not_literal_mem_subfms_last unfolding P_def by blast
qed simp
lemma card_not_literal_branch_if_wf_branch:
assumes "wf_branch b"
shows "card {Ο β set b. Β¬ is_literal Ο} β€ 2 * card (subfms (last b))"
proof -
from assms obtain Ο where "expandss b [Ο]"
unfolding wf_branch_def by blast
then have [simp]: "last b = Ο"
by simp
have "{Ο β set b. Β¬ is_literal Ο} β subfms Ο βͺ Neg ` subfms Ο"
using expandss_not_literal_mem_subfms_last[OF βΉexpandss b [Ο]βΊ]
by auto
from card_mono[OF _ this] have
"card {Ο β set b. Β¬ is_literal Ο} β€ card (subfms Ο βͺ Neg ` subfms Ο)"
using finite_subfms finite_imageI by fast
also have "β¦ β€ card (subfms Ο) + card (Neg ` subfms Ο)"
using card_Un_le by blast
also have "β¦ β€ 2 * card (subfms Ο)"
unfolding mult_2 by (simp add: card_image_le finite_subfms)
finally show ?thesis
by simp
qed
lemma card_wf_branch_ub:
assumes "wf_branch b"
shows "card (set b)
β€ 2 * card (subfms (last b)) + 16 * (card (subterms (last b)))^4"
proof -
let ?csts = "card (subterms (last b))"
have "set b = {Ο β set b. Β¬ is_literal Ο} βͺ {Ο β set b. is_literal Ο}"
by auto
then have "card (set b)
= card ({Ο β set b. Β¬ is_literal Ο}) + card ({Ο β set b. is_literal Ο})"
using card_Un_disjoint finite_Un
by (metis (no_types, lifting) List.finite_set disjoint_iff mem_Collect_eq)
also have "β¦ β€ 2 * card (subfms (last b)) + 4 * (?csts + card (wits b))β§2"
using assms card_literals_branch_if_wf_branch card_not_literal_branch_if_wf_branch
by fastforce
also have "β¦ β€ 2 * card (subfms (last b)) + 4 * (?csts + ?cstsβ§2)β§2"
using assms card_wits_ub_if_wf_branch by auto
also have "β¦ β€ 2 * card (subfms (last b)) + 16 * ?csts^4"
proof -
have "1 β€ ?csts"
using finite_subterms_fm[THEN card_0_eq]
by (auto intro: Suc_leI)
then have "(?csts + ?cstsβ§2)β§2 = ?cstsβ§2 + 2 * ?csts^3 + ?csts^4"
by algebra
also have "β¦ β€ ?cstsβ§2 + 2 * ?csts^4 + ?csts^4"
using power_increasing[OF _ βΉ1 β€ ?cstsβΊ] by simp
also have "β¦ β€ ?csts^4 + 2 * ?csts^4 + ?csts^4"
using power_increasing[OF _ βΉ1 β€ ?cstsβΊ] by simp
also have "β¦ β€ 4 * ?csts^4"
by simp
finally show ?thesis
by simp
qed
finally show ?thesis .
qed
section βΉThe Decision ProcedureβΊ
locale mlss_proc =
fixes lexpand :: "'a branch β 'a branch"
assumes lexpands_lexpand:
"Β¬ lin_sat b βΉ lexpands (lexpand b) b β§ set b β set (lexpand b @ b)"
fixes bexpand :: "'a branch β 'a branch set"
assumes bexpands_bexpand:
"Β¬ sat b βΉ lin_sat b βΉ bexpands (bexpand b) b"
begin
function (domintros) mlss_proc_branch :: "'a branch β bool" where
"Β¬ lin_sat b
βΉ mlss_proc_branch b = mlss_proc_branch (lexpand b @ b)"
| "β¦ lin_sat b; bclosed b β§ βΉ mlss_proc_branch b = True"
| "β¦ Β¬ sat b; bopen b; lin_sat b β§
βΉ mlss_proc_branch b = (βb' β bexpand b. mlss_proc_branch (b' @ b))"
| "β¦ lin_sat b; sat b β§ βΉ mlss_proc_branch b = bclosed b"
by auto
lemma mlss_proc_branch_dom_if_wf_branch:
assumes "wf_branch b"
shows "mlss_proc_branch_dom b"
proof -
define card_ub :: "'a branch β nat" where
"card_ub β‘ Ξ»b. 2 * card (subfms (last b)) + 16 * (card (subterms (last b)))^4"
from assms show ?thesis
proof(induction "card_ub b - card (set b)"
arbitrary: b rule: less_induct)
case less
have less': "mlss_proc_branch_dom b'" if "set b β set b'" "expandss b' b" for b'
proof -
note expandss_last_eq[OF βΉexpandss b' bβΊ wf_branch_not_Nil[OF βΉwf_branch bβΊ]]
then have "card_ub b' = card_ub b"
unfolding card_ub_def by simp
moreover from that βΉwf_branch bβΊ have "wf_branch b'"
by (meson expandss_trans wf_branch_def)
ultimately have "mlss_proc_branch_dom b'" if "card (set b') > card (set b)"
using less(1)[OF _ βΉwf_branch b'βΊ] card_wf_branch_ub that
by (metis (no_types, lifting) card_ub_def diff_less_mono2 order_less_le_trans)
with that show ?thesis
by (simp add: psubset_card_mono)
qed
then show ?case
proof(cases "sat b")
case False
then consider
b' where "Β¬ lin_sat b" "lexpands b' b" "set b β set (b' @ b)" |
bs' where "lin_sat b" "Β¬ sat b" "bexpands bs' b" "bs' β {}"
"βb' β bs'. set b β set (b' @ b)"
unfolding sat_def lin_sat_def
using bexpands_strict_mono bexpands_nonempty
by (metis (no_types, opaque_lifting) inf_sup_aci(5) psubsetI set_append sup_ge1)
then show ?thesis
proof(cases)
case 1
with less' show ?thesis
using mlss_proc_branch.domintros(1)
by (metis expandss.intros(1,2) lexpands_lexpand)
next
case 2
then show ?thesis
using less' bexpands_bexpand mlss_proc_branch.domintros(2,3)
by (metis bexpands_strict_mono expandss.intros(1,3))
qed
qed (use mlss_proc_branch.domintros(4) sat_def in metis)
qed
qed
definition mlss_proc :: "'a pset_fm β bool" where
"mlss_proc Ο β‘ mlss_proc_branch [Ο]"
lemma mlss_proc_branch_complete:
fixes b :: "'a branch"
assumes "wf_branch b" "βv. v β’ last b"
assumes "Β¬ mlss_proc_branch b"
assumes "infinite (UNIV :: 'a set)"
shows "βM. interp Iβ©sβ©a M (last b)"
proof -
from mlss_proc_branch_dom_if_wf_branch[OF assms(1)] assms(1,2,3)
show ?thesis
proof(induction rule: mlss_proc_branch.pinduct)
case (1 b)
let ?b' = "lexpand b"
from 1 lexpands_lexpand have "wf_branch (?b' @ b)"
using wf_branch_lexpands by blast
moreover from 1 lexpands_lexpand have "Β¬ mlss_proc_branch (?b' @ b)"
by (simp add: mlss_proc_branch.psimps)
ultimately obtain M where "interp Iβ©sβ©a M (last (?b' @ b))"
using 1 by auto
with 1 show ?case
using wf_branch_not_Nil by auto
next
case (2 b)
then show ?case by (simp add: mlss_proc_branch.psimps)
next
case (3 b)
let ?bs' = "bexpand b"
from 3 bexpands_bexpand obtain b' where b': "b' β ?bs'" "Β¬ mlss_proc_branch (b' @ b)"
using mlss_proc_branch.psimps(3) by metis
with 3 bexpands_bexpand have "wf_branch (b' @ b)"
using wf_branch_expandss[OF βΉwf_branch bβΊ expandss.intros(3)]
using expandss.intros(1) by blast
with 3 b' obtain M where "interp Iβ©sβ©a M (last (b' @ b))"
by auto
with 3 show ?case
by auto
next
case (4 b)
then have "bopen b"
by (simp add: mlss_proc_branch.psimps)
interpret open_branch b
using βΉwf_branch bβΊ βΉβv. v β’ last bβΊ βΉbopen bβΊ βΉinfinite UNIVβΊ
by unfold_locales assumption+
from coherence[OF βΉsat bβΊ last_in_set] show ?case
using wf_branch wf_branch_not_Nil by blast
qed
qed
lemma mlss_proc_branch_sound:
assumes "wf_branch b"
assumes "βΟ β set b. interp Iβ©sβ©a M Ο"
shows "Β¬ mlss_proc_branch b"
proof
assume "mlss_proc_branch b"
with mlss_proc_branch_dom_if_wf_branch[OF βΉwf_branch bβΊ]
have "βb'. expandss b' b β§ (βM. βΟ β set b'. interp Iβ©sβ©a M Ο) β§ bclosed b'"
using assms
proof(induction arbitrary: M rule: mlss_proc_branch.pinduct)
case (1 b)
let ?b' = "lexpand b"
from 1 lexpands_lexpand βΉwf_branch bβΊ have "wf_branch (?b' @ b)"
using wf_branch_lexpands by metis
with 1 lexpands_sound lexpands_lexpand obtain b'' where
"expandss b'' (?b' @ b)" "βM. βΟ β set b''. interp Iβ©sβ©a M Ο" "bclosed b''"
by (fastforce simp: mlss_proc_branch.psimps)
with 1 lexpands_lexpand show ?case
using expandss_trans expandss.intros(1,2) by meson
next
case (3 b)
let ?bs' = "bexpand b"
from 3 βΉwf_branch bβΊ bexpands_bexpand have wf_branch_b':
"wf_branch (b' @ b)" if "b' β ?bs'" for b'
using that expandss.intros(3) wf_branch_def by metis
from bexpands_sound bexpands_bexpand 3 obtain M' b' where
"b' β ?bs'" "βΟ β set (b' @ b). interp Iβ©sβ©a M' Ο"
by metis
with "3.IH" βΉmlss_proc_branch bβΊ wf_branch_b' obtain b'' where
"b' β ?bs'" "expandss b'' (b' @ b)"
"βM. βΟ β set b''. interp Iβ©sβ©a M Ο" "bclosed b''"
using mlss_proc_branch.psimps(3)[OF "3.hyps"(2-4,1)] by blast
with 3 bexpands_bexpand show ?case
using expandss_trans expandss.intros(1,3) by metis
qed (use expandss.intros(1) mlss_proc_branch.psimps(4) in βΉblast+βΊ)
with bclosed_sound show False by blast
qed
theorem mlss_proc_complete:
fixes Ο :: "'a pset_fm"
assumes "Β¬ mlss_proc Ο"
assumes "βv. v β’ Ο"
assumes "infinite (UNIV :: 'a set)"
shows "βM. interp Iβ©sβ©a M Ο"
using assms mlss_proc_branch_complete[of "[Ο]"]
unfolding mlss_proc_def by simp
theorem mlss_proc_sound:
assumes "interp Iβ©sβ©a M Ο"
shows "Β¬ mlss_proc Ο"
using assms mlss_proc_branch_sound[of "[Ο]"]
unfolding mlss_proc_def by simp
end
end