src/HOL/MicroJava/BV/SemilatAlg.thy
changeset 13074 96bf406fd3e5
parent 13069 3ccbd3a97bcb
child 13077 c2e4d9990162
equal deleted inserted replaced
13073:cc9d7f403a4b 13074:96bf406fd3e5
    60   apply (unfold Listn.le_def lesub_def semilat_def)
    60   apply (unfold Listn.le_def lesub_def semilat_def)
    61   apply (simp add: list_all2_conv_all_nth nth_list_update)
    61   apply (simp add: list_all2_conv_all_nth nth_list_update)
    62   done
    62   done
    63 
    63 
    64 
    64 
    65 lemma plusplus_closed: 
    65 lemma plusplus_closed: includes semilat shows
    66   "\<And>y. \<lbrakk>semilat (A, r, f); set x \<subseteq> A; y \<in> A\<rbrakk> \<Longrightarrow> x ++_f y \<in> A"
    66   "\<And>y. \<lbrakk> set x \<subseteq> A; y \<in> A\<rbrakk> \<Longrightarrow> x ++_f y \<in> A"
    67 proof (induct x)
    67 proof (induct x)
    68   show "\<And>y. y \<in> A \<Longrightarrow> [] ++_f y \<in> A" by simp
    68   show "\<And>y. y \<in> A \<Longrightarrow> [] ++_f y \<in> A" by simp
    69   fix y x xs
    69   fix y x xs
    70   assume sl: "semilat (A, r, f)" and y: "y \<in> A" and xs: "set (x#xs) \<subseteq> A"
    70   assume y: "y \<in> A" and xs: "set (x#xs) \<subseteq> A"
    71   assume IH: "\<And>y. \<lbrakk>semilat (A, r, f); set xs \<subseteq> A; y \<in> A\<rbrakk> \<Longrightarrow> xs ++_f y \<in> A"
    71   assume IH: "\<And>y. \<lbrakk> set xs \<subseteq> A; y \<in> A\<rbrakk> \<Longrightarrow> xs ++_f y \<in> A"
    72   from xs obtain x: "x \<in> A" and "set xs \<subseteq> A" by simp  
    72   from xs obtain x: "x \<in> A" and "set xs \<subseteq> A" by simp
    73   from sl x y have "(x +_f y) \<in> A" by (simp add: closedD)
    73   from semilat x y have "(x +_f y) \<in> A" by (simp add: closedD)
    74   with sl xs have "xs ++_f (x +_f y) \<in> A" by - (rule IH)
    74   with semilat xs have "xs ++_f (x +_f y) \<in> A" by - (rule IH)
    75   thus "(x#xs) ++_f y \<in> A" by simp
    75   thus "(x#xs) ++_f y \<in> A" by simp
    76 qed
    76 qed
    77 
    77 
    78 lemma ub2: "\<And>y. \<lbrakk>semilat (A, r, f); set x \<subseteq> A; y \<in> A\<rbrakk> \<Longrightarrow> y <=_r x ++_f y"
    78 lemma (in semilat) pp_ub2:
       
    79  "\<And>y. \<lbrakk> set x \<subseteq> A; y \<in> A\<rbrakk> \<Longrightarrow> y <=_r x ++_f y"
    79 proof (induct x)
    80 proof (induct x)
    80   show "\<And>y. semilat(A, r, f) \<Longrightarrow> y <=_r [] ++_f y" by simp 
    81   from semilat show "\<And>y. y <=_r [] ++_f y" by simp
    81   
    82   
    82   fix y a l
    83   fix y a l
    83   assume sl: "semilat (A, r, f)"
       
    84   assume y:  "y \<in> A"
    84   assume y:  "y \<in> A"
    85   assume "set (a#l) \<subseteq> A"
    85   assume "set (a#l) \<subseteq> A"
    86   then obtain a: "a \<in> A" and x: "set l \<subseteq> A" by simp 
    86   then obtain a: "a \<in> A" and x: "set l \<subseteq> A" by simp
    87   assume "\<And>y. \<lbrakk>semilat (A, r, f); set l \<subseteq> A; y \<in> A\<rbrakk> \<Longrightarrow> y <=_r l ++_f y"
    87   assume "\<And>y. \<lbrakk>set l \<subseteq> A; y \<in> A\<rbrakk> \<Longrightarrow> y <=_r l ++_f y"
    88   hence IH: "\<And>y. y \<in> A \<Longrightarrow> y <=_r l ++_f y" .
    88   hence IH: "\<And>y. y \<in> A \<Longrightarrow> y <=_r l ++_f y" .
    89 
    89 
    90   from sl have "order r" .. note order_trans [OF this, trans]  
    90   have "order r" .. note order_trans [OF this, trans]
    91   
    91 
    92   from sl a y have "y <=_r a +_f y" by (rule semilat_ub2)
    92   from a y have "y <=_r a +_f y" by (rule ub2)
    93   also
    93   also from a y have "a +_f y \<in> A" by (simp add: closedD)
    94   from sl a y have "a +_f y \<in> A" by (simp add: closedD)
       
    95   hence "(a +_f y) <=_r l ++_f (a +_f y)" by (rule IH)
    94   hence "(a +_f y) <=_r l ++_f (a +_f y)" by (rule IH)
    96   finally
    95   finally have "y <=_r l ++_f (a +_f y)" .
    97   have "y <=_r l ++_f (a +_f y)" .
       
    98   thus "y <=_r (a#l) ++_f y" by simp
    96   thus "y <=_r (a#l) ++_f y" by simp
    99 qed
    97 qed
   100 
    98 
   101 
    99 
   102 lemma ub1: 
   100 lemma (in semilat) pp_ub1:
   103   "\<And>y. \<lbrakk>semilat (A, r, f); set ls \<subseteq> A; y \<in> A; x \<in> set ls\<rbrakk> \<Longrightarrow> x <=_r ls ++_f y"
   101 shows "\<And>y. \<lbrakk>set ls \<subseteq> A; y \<in> A; x \<in> set ls\<rbrakk> \<Longrightarrow> x <=_r ls ++_f y"
   104 proof (induct ls)
   102 proof (induct ls)
   105   show "\<And>y. x \<in> set [] \<Longrightarrow> x <=_r [] ++_f y" by simp
   103   show "\<And>y. x \<in> set [] \<Longrightarrow> x <=_r [] ++_f y" by simp
   106   
   104 
   107   fix y s ls
   105   fix y s ls
   108   assume sl: "semilat (A, r, f)" 
   106   have "order r" .. note order_trans [OF this, trans]
   109   hence "order r" .. note order_trans [OF this, trans]
       
   110   assume "set (s#ls) \<subseteq> A"
   107   assume "set (s#ls) \<subseteq> A"
   111   then obtain s: "s \<in> A" and ls: "set ls \<subseteq> A" by simp
   108   then obtain s: "s \<in> A" and ls: "set ls \<subseteq> A" by simp
   112   assume y: "y \<in> A" 
   109   assume y: "y \<in> A" 
   113 
   110 
   114   assume 
   111   assume 
   115     "\<And>y. \<lbrakk>semilat (A, r, f); set ls \<subseteq> A; y \<in> A; x \<in> set ls\<rbrakk> \<Longrightarrow> x <=_r ls ++_f y"
   112     "\<And>y. \<lbrakk>set ls \<subseteq> A; y \<in> A; x \<in> set ls\<rbrakk> \<Longrightarrow> x <=_r ls ++_f y"
   116   hence IH: "\<And>y. x \<in> set ls \<Longrightarrow> y \<in> A \<Longrightarrow> x <=_r ls ++_f y" .
   113   hence IH: "\<And>y. x \<in> set ls \<Longrightarrow> y \<in> A \<Longrightarrow> x <=_r ls ++_f y" .
   117 
   114 
   118   assume "x \<in> set (s#ls)"
   115   assume "x \<in> set (s#ls)"
   119   then obtain xls: "x = s \<or> x \<in> set ls" by simp
   116   then obtain xls: "x = s \<or> x \<in> set ls" by simp
   120   moreover {
   117   moreover {
   121     assume xs: "x = s"
   118     assume xs: "x = s"
   122     from sl s y have "s <=_r s +_f y" by (rule semilat_ub1)
   119     from s y have "s <=_r s +_f y" by (rule ub1)
   123     also
   120     also from s y have "s +_f y \<in> A" by (simp add: closedD)
   124     from sl s y have "s +_f y \<in> A" by (simp add: closedD)
   121     with ls have "(s +_f y) <=_r ls ++_f (s +_f y)" by (rule pp_ub2)
   125     with sl ls have "(s +_f y) <=_r ls ++_f (s +_f y)" by (rule ub2)
   122     finally have "s <=_r ls ++_f (s +_f y)" .
   126     finally 
       
   127     have "s <=_r ls ++_f (s +_f y)" .
       
   128     with xs have "x <=_r ls ++_f (s +_f y)" by simp
   123     with xs have "x <=_r ls ++_f (s +_f y)" by simp
   129   } 
   124   } 
   130   moreover {
   125   moreover {
   131     assume "x \<in> set ls"
   126     assume "x \<in> set ls"
   132     hence "\<And>y. y \<in> A \<Longrightarrow> x <=_r ls ++_f y" by (rule IH)
   127     hence "\<And>y. y \<in> A \<Longrightarrow> x <=_r ls ++_f y" by (rule IH)
   133     moreover
   128     moreover from s y have "s +_f y \<in> A" by (simp add: closedD)
   134     from sl s y
   129     ultimately have "x <=_r ls ++_f (s +_f y)" .
   135     have "s +_f y \<in> A" by (simp add: closedD)
       
   136     ultimately 
       
   137     have "x <=_r ls ++_f (s +_f y)" .
       
   138   }
   130   }
   139   ultimately 
   131   ultimately 
   140   have "x <=_r ls ++_f (s +_f y)" by blast
   132   have "x <=_r ls ++_f (s +_f y)" by blast
   141   thus "x <=_r (s#ls) ++_f y" by simp
   133   thus "x <=_r (s#ls) ++_f y" by simp
   142 qed
   134 qed
   143 
   135 
   144 
   136 
   145 lemma lub:
   137 lemma (in semilat) pp_lub:
   146   assumes sl: "semilat (A, r, f)" and "z \<in> A"
   138   assumes "z \<in> A"
   147   shows 
   139   shows 
   148   "\<And>y. y \<in> A \<Longrightarrow> set xs \<subseteq> A \<Longrightarrow> \<forall>x \<in> set xs. x <=_r z \<Longrightarrow> y <=_r z \<Longrightarrow> xs ++_f y <=_r z"
   140   "\<And>y. y \<in> A \<Longrightarrow> set xs \<subseteq> A \<Longrightarrow> \<forall>x \<in> set xs. x <=_r z \<Longrightarrow> y <=_r z \<Longrightarrow> xs ++_f y <=_r z"
   149 proof (induct xs)
   141 proof (induct xs)
   150   fix y assume "y <=_r z" thus "[] ++_f y <=_r z" by simp
   142   fix y assume "y <=_r z" thus "[] ++_f y <=_r z" by simp
   151 next
   143 next
   152   fix y l ls assume y: "y \<in> A" and "set (l#ls) \<subseteq> A"
   144   fix y l ls assume y: "y \<in> A" and "set (l#ls) \<subseteq> A"
   153   then obtain l: "l \<in> A" and ls: "set ls \<subseteq> A" by auto
   145   then obtain l: "l \<in> A" and ls: "set ls \<subseteq> A" by auto
   154   assume "\<forall>x \<in> set (l#ls). x <=_r z"
   146   assume "\<forall>x \<in> set (l#ls). x <=_r z"
   155   then obtain "l <=_r z" and lsz: "\<forall>x \<in> set ls. x <=_r z" by auto
   147   then obtain "l <=_r z" and lsz: "\<forall>x \<in> set ls. x <=_r z" by auto
   156   assume "y <=_r z" have "l +_f y <=_r z" by (rule semilat_lub) 
   148   assume "y <=_r z" have "l +_f y <=_r z" by (rule lub)
   157   moreover
   149   moreover
   158   from sl l y have "l +_f y \<in> A" by (fast intro: closedD)
   150   from l y have "l +_f y \<in> A" by (fast intro: closedD)
   159   moreover
   151   moreover
   160   assume "\<And>y. y \<in> A \<Longrightarrow> set ls \<subseteq> A \<Longrightarrow> \<forall>x \<in> set ls. x <=_r z \<Longrightarrow> y <=_r z
   152   assume "\<And>y. y \<in> A \<Longrightarrow> set ls \<subseteq> A \<Longrightarrow> \<forall>x \<in> set ls. x <=_r z \<Longrightarrow> y <=_r z
   161           \<Longrightarrow> ls ++_f y <=_r z"
   153           \<Longrightarrow> ls ++_f y <=_r z"
   162   ultimately
   154   ultimately
   163   have "ls ++_f (l +_f y) <=_r z" using ls lsz by - assumption
   155   have "ls ++_f (l +_f y) <=_r z" by - (insert ls lsz)
   164   thus "(l#ls) ++_f y <=_r z" by simp
   156   thus "(l#ls) ++_f y <=_r z" by simp
   165 qed
   157 qed
   166 
   158 
   167 
   159 
   168 lemma ub1': 
   160 lemma ub1': includes semilat
   169   "\<lbrakk>semilat (A, r, f); \<forall>(p,s) \<in> set S. s \<in> A; y \<in> A; (a,b) \<in> set S\<rbrakk> 
   161 shows "\<lbrakk>\<forall>(p,s) \<in> set S. s \<in> A; y \<in> A; (a,b) \<in> set S\<rbrakk> 
   170   \<Longrightarrow> b <=_r map snd [(p', t')\<in>S. p' = a] ++_f y" 
   162   \<Longrightarrow> b <=_r map snd [(p', t')\<in>S. p' = a] ++_f y" 
   171 proof -
   163 proof -
   172   let "b <=_r ?map ++_f y" = ?thesis
   164   let "b <=_r ?map ++_f y" = ?thesis
   173 
   165 
   174   assume "semilat (A, r, f)" "y \<in> A"
   166   assume "y \<in> A"
   175   moreover
   167   moreover
   176   assume "\<forall>(p,s) \<in> set S. s \<in> A"
   168   assume "\<forall>(p,s) \<in> set S. s \<in> A"
   177   hence "set ?map \<subseteq> A" by auto
   169   hence "set ?map \<subseteq> A" by auto
   178   moreover
   170   moreover
   179   assume "(a,b) \<in> set S"
   171   assume "(a,b) \<in> set S"
   180   hence "b \<in> set ?map" by (induct S, auto)
   172   hence "b \<in> set ?map" by (induct S, auto)
   181   ultimately
   173   ultimately
   182   show ?thesis by - (rule ub1)
   174   show ?thesis by - (rule pp_ub1)
   183 qed
   175 qed
   184     
   176     
   185  
   177  
   186 
   178 
   187 lemma plusplus_empty:  
   179 lemma plusplus_empty: