src/HOL/MicroJava/DFA/LBVSpec.thy
changeset 68249 949d93804740
parent 63258 576fb8068ba6
child 68386 98cf1c823c48
equal deleted inserted replaced
68248:ef1e0cb80fde 68249:949d93804740
   111 
   111 
   112 
   112 
   113 lemma (in Semilat) pp_ub1':
   113 lemma (in Semilat) pp_ub1':
   114   assumes S: "snd`set S \<subseteq> A" 
   114   assumes S: "snd`set S \<subseteq> A" 
   115   assumes y: "y \<in> A" and ab: "(a, b) \<in> set S" 
   115   assumes y: "y \<in> A" and ab: "(a, b) \<in> set S" 
   116   shows "b <=_r map snd [(p', t') \<leftarrow> S . p' = a] ++_f y"
   116   shows "b <=_r map snd (filter (\<lambda>(p', t'). p' = a) S) ++_f y"
   117 proof -
   117 proof -
   118   from S have "\<forall>(x,y) \<in> set S. y \<in> A" by auto
   118   from S have "\<forall>(x,y) \<in> set S. y \<in> A" by auto
   119   with semilat y ab show ?thesis by - (rule ub1')
   119   with semilat y ab show ?thesis by - (rule ub1')
   120 qed 
   120 qed 
   121 
   121 
   170 lemma (in lbv) merge_def:
   170 lemma (in lbv) merge_def:
   171   shows 
   171   shows 
   172   "\<And>x. x \<in> A \<Longrightarrow> snd`set ss \<subseteq> A \<Longrightarrow>
   172   "\<And>x. x \<in> A \<Longrightarrow> snd`set ss \<subseteq> A \<Longrightarrow>
   173   merge c pc ss x = 
   173   merge c pc ss x = 
   174   (if \<forall>(pc',s') \<in> set ss. pc'\<noteq>pc+1 \<longrightarrow> s' <=_r c!pc' then
   174   (if \<forall>(pc',s') \<in> set ss. pc'\<noteq>pc+1 \<longrightarrow> s' <=_r c!pc' then
   175     map snd [(p',t') \<leftarrow> ss. p'=pc+1] ++_f x
   175     map snd (filter (\<lambda>(p',t'). p'=pc+1) ss) ++_f x
   176   else \<top>)" 
   176   else \<top>)" 
   177   (is "\<And>x. _ \<Longrightarrow> _ \<Longrightarrow> ?merge ss x = ?if ss x" is "\<And>x. _ \<Longrightarrow> _ \<Longrightarrow> ?P ss x")
   177   (is "\<And>x. _ \<Longrightarrow> _ \<Longrightarrow> ?merge ss x = ?if ss x" is "\<And>x. _ \<Longrightarrow> _ \<Longrightarrow> ?P ss x")
   178 proof (induct ss)
   178 proof (induct ss)
   179   fix x show "?P [] x" by simp
   179   fix x show "?P [] x" by simp
   180 next 
   180 next 
   200     proof (cases "\<forall>(pc', s')\<in>set (l#ls). pc'\<noteq>pc+1 \<longrightarrow> s' <=_r c!pc'")
   200     proof (cases "\<forall>(pc', s')\<in>set (l#ls). pc'\<noteq>pc+1 \<longrightarrow> s' <=_r c!pc'")
   201       case True
   201       case True
   202       hence "\<forall>(pc', s')\<in>set ls. pc'\<noteq>pc+1 \<longrightarrow> s' <=_r c!pc'" by auto
   202       hence "\<forall>(pc', s')\<in>set ls. pc'\<noteq>pc+1 \<longrightarrow> s' <=_r c!pc'" by auto
   203       moreover
   203       moreover
   204       from True have 
   204       from True have 
   205         "map snd [(p',t')\<leftarrow>ls . p'=pc+1] ++_f ?if' = 
   205         "map snd (filter (\<lambda>(p',t'). p'=pc+1) ls) ++_f ?if' = 
   206         (map snd [(p',t')\<leftarrow>l#ls . p'=pc+1] ++_f x)"
   206         (map snd (filter (\<lambda>(p',t'). p'=pc+1) (l#ls)) ++_f x)"
   207         by simp
   207         by simp
   208       ultimately
   208       ultimately
   209       show ?thesis using True by simp
   209       show ?thesis using True by simp
   210     next
   210     next
   211       case False 
   211       case False 
   212       moreover
   212       moreover
   213       from ls have "set (map snd [(p', t')\<leftarrow>ls . p' = Suc pc]) \<subseteq> A" by auto
   213       from ls have "set (map snd (filter (\<lambda>(p', t'). p' = Suc pc) ls)) \<subseteq> A" by auto
   214       ultimately show ?thesis by auto
   214       ultimately show ?thesis by auto
   215     qed
   215     qed
   216   finally show "?P (l#ls) x" .
   216   finally show "?P (l#ls) x" .
   217 qed
   217 qed
   218 
   218 
   219 lemma (in lbv) merge_not_top_s:
   219 lemma (in lbv) merge_not_top_s:
   220   assumes x:  "x \<in> A" and ss: "snd`set ss \<subseteq> A"
   220   assumes x:  "x \<in> A" and ss: "snd`set ss \<subseteq> A"
   221   assumes m:  "merge c pc ss x \<noteq> \<top>"
   221   assumes m:  "merge c pc ss x \<noteq> \<top>"
   222   shows "merge c pc ss x = (map snd [(p',t') \<leftarrow> ss. p'=pc+1] ++_f x)"
   222   shows "merge c pc ss x = (map snd (filter (\<lambda>(p',t'). p'=pc+1) ss) ++_f x)"
   223 proof -
   223 proof -
   224   from ss m have "\<forall>(pc',s') \<in> set ss. (pc' \<noteq> pc+1 \<longrightarrow> s' <=_r c!pc')" 
   224   from ss m have "\<forall>(pc',s') \<in> set ss. (pc' \<noteq> pc+1 \<longrightarrow> s' <=_r c!pc')" 
   225     by (rule merge_not_top)
   225     by (rule merge_not_top)
   226   with x ss m show ?thesis by - (drule merge_def, auto split: if_split_asm)
   226   with x ss m show ?thesis by - (drule merge_def, auto split: if_split_asm)
   227 qed
   227 qed
   305 
   305 
   306 lemma (in lbv) merge_pres:
   306 lemma (in lbv) merge_pres:
   307   assumes s0: "snd`set ss \<subseteq> A" and x: "x \<in> A"
   307   assumes s0: "snd`set ss \<subseteq> A" and x: "x \<in> A"
   308   shows "merge c pc ss x \<in> A"
   308   shows "merge c pc ss x \<in> A"
   309 proof -
   309 proof -
   310   from s0 have "set (map snd [(p', t')\<leftarrow>ss . p'=pc+1]) \<subseteq> A" by auto
   310   from s0 have "set (map snd (filter (\<lambda>(p', t'). p'=pc+1) ss)) \<subseteq> A" by auto
   311   with x  have "(map snd [(p', t')\<leftarrow>ss . p'=pc+1] ++_f x) \<in> A"
   311   with x  have "(map snd (filter (\<lambda>(p', t'). p'=pc+1) ss) ++_f x) \<in> A"
   312     by (auto intro!: plusplus_closed semilat)
   312     by (auto intro!: plusplus_closed semilat)
   313   with s0 x show ?thesis by (simp add: merge_def T_A)
   313   with s0 x show ?thesis by (simp add: merge_def T_A)
   314 qed
   314 qed
   315   
   315   
   316 
   316