QuotList.thy
author Cezary Kaliszyk <kaliszyk@in.tum.de>
Fri, 04 Dec 2009 16:12:40 +0100
changeset 539 8287fb5b8d7a
parent 537 57073b0b8fac
child 540 c0b13fb70d6d
permissions -rw-r--r--
Cleaning & Renaming coming from QuotList

theory QuotList
imports QuotScript List
begin

fun
  list_rel
where
  "list_rel R [] [] = True"
| "list_rel R (x#xs) [] = False"
| "list_rel R [] (x#xs) = False"
| "list_rel R (x#xs) (y#ys) = (R x y \<and> list_rel R xs ys)"

lemma list_equivp:
  assumes a: "equivp R"
  shows "equivp (list_rel R)"
  unfolding equivp_def
  apply(rule allI)+
  apply(induct_tac x y rule: list_induct2')
  apply(simp_all add: expand_fun_eq)
  apply(metis list_rel.simps(1) list_rel.simps(2))
  apply(metis list_rel.simps(1) list_rel.simps(2))
  apply(rule iffI)
  apply(rule allI)
  apply(case_tac x)
  apply(simp_all)
  using a
  apply(unfold equivp_def)
  apply(auto)[1]
  apply(metis list_rel.simps(4))
  done

lemma list_rel_rel:
  assumes q: "Quotient R Abs Rep"
  shows "list_rel R r s = (list_rel R r r \<and> list_rel R s s \<and> (map Abs r = map Abs s))"
  apply(induct r s rule: list_induct2')
  apply(simp_all)
  using Quotient_rel[OF q]
  apply(metis)
  done

lemma list_quotient:
  assumes q: "Quotient R Abs Rep"
  shows "Quotient (list_rel R) (map Abs) (map Rep)"
  unfolding Quotient_def
  apply(rule conjI)
  apply(rule allI)
  apply(induct_tac a)
  apply(simp)
  apply(simp add: Quotient_ABS_REP[OF q])
  apply(rule conjI)
  apply(rule allI)
  apply(induct_tac a)
  apply(simp)
  apply(simp)
  apply(simp add: Quotient_REP_reflp[OF q])
  apply(rule allI)+
  apply(rule list_rel_rel[OF q])
  done






(* Rest is not used *)


lemma CONS_PRS:
  assumes q: "Quotient R Abs Rep"
  shows "(h#t) = (map Abs) ((Rep h)#(map Rep t))"
by (induct t) (simp_all add: Quotient_ABS_REP[OF q])

lemma CONS_RSP:
  assumes q: "Quotient R Abs Rep"
  and     a: "R h1 h2" "list_rel R t1 t2"
  shows "list_rel R (h1#t1) (h2#t2)"
using a by (auto)

lemma NIL_PRS:
  assumes q: "Quotient R Abs Rep"
  shows "[] = (map Abs [])"
by (simp)

lemma NIL_RSP:
  assumes q: "Quotient R Abs Rep"
  shows "list_rel R [] []"
by simp

lemma MAP_PRS:
  assumes q1: "Quotient R1 Abs1 Rep1"
  and     q2: "Quotient R2 Abs2 Rep2"
  shows "map f l = (map Abs2) (map ((Abs1 ---> Rep2) f) (map Rep1 l))"
by (induct l)
   (simp_all add: Quotient_ABS_REP[OF q1] Quotient_ABS_REP[OF q2])

lemma MAP_RSP:
  assumes q1: "Quotient R1 Abs1 Rep1"
  and     q2: "Quotient R2 Abs2 Rep2"
  and     a: "(R1 ===> R2) f1 f2"
  and     b: "list_rel R1 l1 l2"
  shows "list_rel R2 (map f1 l1) (map f2 l2)"
using b a
by (induct l1 l2 rule: list_induct2')
   (simp_all)



lemma LIST_map_id:
  shows "map (\<lambda>x. x) = (\<lambda>x. x)"
  by simp

lemma list_rel_EQ:
  shows "list_rel (op =) \<equiv> (op =)"
apply(rule eq_reflection)
unfolding expand_fun_eq
apply(rule allI)+
apply(induct_tac x xa rule: list_induct2')
apply(simp_all)
done

lemma list_rel_REFL:
  assumes a: "\<And>x y. R x y = (R x = R y)"
  shows "list_rel R x x"
by (induct x) (auto simp add: a)


end