diff -r ed54ec416bb3 -r 5c816239deaa Unification/Disagreement.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Unification/Disagreement.thy Sun Apr 29 11:29:56 2012 +0100 @@ -0,0 +1,147 @@ + +theory Disagreement = Main + Swap + Atoms: + +consts + ds :: "(string \ string) list \ (string \ string) list \ string set" +defs + ds_def: "ds xs ys \ { a . a \ (atms xs \ atms ys) \ (swapas xs a \ swapas ys a) }" + +lemma + ds_elem: "\swapas pi a\a\\a\ds [] pi" +apply(simp add: ds_def) +apply(auto simp add: swapas_pi_ineq_a) +done + +lemma + elem_ds: "\a\ds [] pi\\a\swapas pi a" +apply(simp add: ds_def) +done + +lemma + ds_sym: "ds pi1 pi2 = ds pi2 pi1" +apply(simp only: ds_def) +apply(auto) +done + +lemma + ds_trans: "c\ds pi1 pi3\(c\ds pi1 pi2 \ c\ds pi2 pi3)" +apply(auto) +apply(simp only: ds_def) +apply(auto) +apply(drule a_not_in_atms[THEN mp])+ +apply(simp) +apply(drule a_not_in_atms[THEN mp]) +apply(simp) +apply(drule swapas_pi_ineq_a[THEN mp]) +apply(assumption) +done + +lemma ds_cancel_pi_left: + "(c\ ds (pi1@pi) (pi2@pi)) \ (swapas pi c\ ds pi1 pi2)" +apply(simp only: ds_def) +apply(auto) +apply(simp_all add: swapas_append) +apply(rule a_ineq_swapas_pi[THEN mp], clarify, drule a_not_in_atms[THEN mp], simp)+ +done + +lemma ds_cancel_pi_right: + "(swapas pi c\ ds pi1 pi2) \ (c\ ds (pi1@pi) (pi2@pi))" +apply(simp only: ds_def) +apply(auto) +apply(simp_all add: swapas_append) +apply(rule a_ineq_swapas_pi[THEN mp],clarify, + drule a_not_in_atms[THEN mp],drule a_not_in_atms[THEN mp],simp)+ +done + +lemma ds_equality: + "(ds [] pi)-{a,swapas pi a} = (ds [] ((a,swapas pi a)#pi))-{swapas pi a}" +apply(simp only: ds_def) +apply(auto) +done + +lemma ds_7: + "\b\ swapas pi b;a\ds [] ((b,swapas pi b)#pi)\\a\ds [] pi" +apply(simp only: ds_def) +apply(case_tac "b=a") +apply(auto) +apply(rule swapas_pi_in_atms) +apply(drule a_ineq_swapas_pi[THEN mp]) +apply(assumption) +apply(drule sym) +apply(drule swapas_rev_pi_a) +apply(simp) +apply(case_tac "swapas pi b = a") +apply(auto) +apply(drule sym) +apply(drule swapas_rev_pi_a) +apply(simp) +done + +lemma ds_cancel_pi_front: + "ds (pi@pi1) (pi@pi2) = ds pi1 pi2" +apply(simp only: ds_def) +apply(auto) +apply(simp_all add: swapas_append) +apply(rule swapas_pi_ineq_a[THEN mp], clarify, drule a_not_in_atms[THEN mp], simp)+ +apply(drule swapas_rev_pi_a, simp)+ +done + +lemma ds_rev_pi_pi: + "ds ((rev pi1)@pi1) pi2 = ds [] pi2" +apply(simp only: ds_def) +apply(auto) +apply(simp_all add: swapas_append) +apply(drule a_ineq_swapas_pi[THEN mp], assumption)+ +done + +lemma ds_rev: + "ds [] ((rev pi1)@pi2) = ds pi1 pi2" +apply(subgoal_tac "ds pi1 pi2 = ds ((rev pi1)@pi1) ((rev pi1)@pi2)") +apply(simp add: ds_rev_pi_pi) +apply(simp only: ds_cancel_pi_front) +done + +lemma ds_acabbc: + "\a\b;b\c;c\a\\ds [] [(a, c), (a, b), (b, c)] = {a, b}" +apply(simp only: ds_def) +apply(auto) +done + +lemma ds_baab: + "\a\b\\ds [] [(b, a), (a, b)] = {}" +apply(simp only: ds_def) +apply(auto) +done + +lemma ds_abab: + "\a\b\\ds [] [(a, b), (a, b)] = {}" +apply(simp only: ds_def) +apply(auto) +done + +(* disagreement set as list *) + +consts flatten :: "(string \ string)list \ string list" +primrec +"flatten [] = []" +"flatten (x#xs) = (fst x)#(snd x)#(flatten xs)" + +consts ds_list :: "(string \ string)list \ (string \ string)list \ string list" +defs ds_list_def: "ds_list pi1 pi2 \ remdups ([x:(flatten (pi1@pi2)). x\ds pi1 pi2])" + +lemma set_flatten_eq_atms: + "set (flatten pi) = atms pi" +apply(induct_tac pi) +apply(auto) +done + +lemma ds_list_equ_ds: + "set (ds_list pi1 pi2) = ds pi1 pi2" +apply(auto) +apply(simp add: ds_list_def) +apply(simp add: ds_list_def) +apply(simp add: set_flatten_eq_atms) +apply(simp add: ds_def) +done + +end \ No newline at end of file