src/HOL/MicroJava/Comp/CorrCompTp.thy
changeset 58263 6c907aad90ba
parent 57816 d8bbb97689d3
child 58886 8a6cac7c7247
equal deleted inserted replaced
58262:85b13d75b2e4 58263:6c907aad90ba
   234  (\<forall> ST LT Ts. 
   234  (\<forall> ST LT Ts. 
   235   E \<turnstile> exs [::] Ts \<longrightarrow>
   235   E \<turnstile> exs [::] Ts \<longrightarrow>
   236   is_inited_LT C pTs lvars LT \<longrightarrow>
   236   is_inited_LT C pTs lvars LT \<longrightarrow>
   237   sttp_of (compTpExprs jmb G exs (ST, LT)) = ((rev Ts) @ ST, LT))"
   237   sttp_of (compTpExprs jmb G exs (ST, LT)) = ((rev Ts) @ ST, LT))"
   238 
   238 
   239 apply (rule expr.induct)
   239 apply (rule compat_expr_expr_list.induct)
   240 
   240 
   241 (* expresssions *)
   241 (* expresssions *)
   242 
   242 
   243 (* NewC *) 
   243 (* NewC *) 
   244 apply (intro strip)
   244 apply (intro strip)
   260 apply (intro strip)
   260 apply (intro strip)
   261 apply (drule BinOp_invers, clarify)
   261 apply (drule BinOp_invers, clarify)
   262 apply (drule_tac x=ST in spec)
   262 apply (drule_tac x=ST in spec)
   263 apply (drule_tac x="Ta # ST" in spec)
   263 apply (drule_tac x="Ta # ST" in spec)
   264 apply ((drule spec)+, (drule mp, assumption)+)
   264 apply ((drule spec)+, (drule mp, assumption)+)
   265   apply (case_tac binop)
   265   apply (rename_tac binop x2 x3 ST LT T Ta, case_tac binop)
   266   apply (simp (no_asm_simp))
   266   apply (simp (no_asm_simp))
   267     apply (simp (no_asm_simp) add: popST_def pushST_def)
   267     apply (simp (no_asm_simp) add: popST_def pushST_def)
   268   apply (simp)
   268   apply (simp)
   269     apply (simp (no_asm_simp) add: replST_def)
   269     apply (simp (no_asm_simp) add: replST_def)
   270 
   270 
   293 apply ((drule_tac x=ST in spec), (drule spec)+, (drule mp, assumption)+)
   293 apply ((drule_tac x=ST in spec), (drule spec)+, (drule mp, assumption)+)
   294 apply (simp add: replST_def)
   294 apply (simp add: replST_def)
   295 
   295 
   296   (* show   snd (the (field (G, cname) vname)) = T *)
   296   (* show   snd (the (field (G, cname) vname)) = T *)
   297   apply (subgoal_tac "is_class G Ca")
   297   apply (subgoal_tac "is_class G Ca")
   298   apply (subgoal_tac "is_class G cname \<and> field (G, cname) vname = Some (cname, T)")
   298   apply (rename_tac cname x2 vname ST LT T Ca, subgoal_tac "is_class G cname \<and> field (G, cname) vname = Some (cname, T)")
   299   apply simp
   299   apply simp
   300 
   300 
   301   (* show is_class G cname \<and> field (G, cname) vname = Some (cname, T) *)
   301   (* show is_class G cname \<and> field (G, cname) vname = Some (cname, T) *)
   302   apply (rule field_in_fd) apply assumption+
   302   apply (rule field_in_fd) apply assumption+
   303   (* show is_class G Ca *)
   303   (* show is_class G Ca *)
   315 
   315 
   316 (* Call *)
   316 (* Call *)
   317 apply (intro strip)
   317 apply (intro strip)
   318 apply (drule Call_invers, clarify)
   318 apply (drule Call_invers, clarify)
   319 apply (drule_tac x=ST in spec)
   319 apply (drule_tac x=ST in spec)
   320 apply (drule_tac x="Class cname # ST" in spec)
   320 apply (rename_tac cname x2 x3 x4 x5 ST LT T pTsa md, drule_tac x="Class cname # ST" in spec)
   321 apply ((drule spec)+, (drule mp, assumption)+)
   321 apply ((drule spec)+, (drule mp, assumption)+)
   322 apply (simp add: replST_def)
   322 apply (simp add: replST_def)
   323 
   323 
   324 
   324 
   325 (* expression lists *)
   325 (* expression lists *)
   821 
   821 
   822 
   822 
   823 lemma length_compTpExpr_Exprs [rule_format]: "
   823 lemma length_compTpExpr_Exprs [rule_format]: "
   824   (\<forall> sttp. (length (mt_of (compTpExpr jmb G ex sttp)) = length (compExpr jmb ex)))
   824   (\<forall> sttp. (length (mt_of (compTpExpr jmb G ex sttp)) = length (compExpr jmb ex)))
   825   \<and> (\<forall> sttp. (length (mt_of (compTpExprs jmb G exs sttp)) = length (compExprs jmb exs)))"
   825   \<and> (\<forall> sttp. (length (mt_of (compTpExprs jmb G exs sttp)) = length (compExprs jmb exs)))"
   826 apply (rule  expr.induct)
   826 apply (rule compat_expr_expr_list.induct)
   827 apply simp+
   827 apply simp+
   828 apply (case_tac binop)
   828 apply (rename_tac binop a b, case_tac binop)
   829 apply simp+
   829 apply simp+
   830 apply (simp add: pushST_def split_beta)
   830 apply (simp add: pushST_def split_beta)
   831 apply simp+
   831 apply simp+
   832 done
   832 done
   833 
   833 
  1646  (\<forall> ST LT Ts.
  1646  (\<forall> ST LT Ts.
  1647   E \<turnstile> exs [::] Ts \<longrightarrow>
  1647   E \<turnstile> exs [::] Ts \<longrightarrow>
  1648   (is_inited_LT C pTs lvars LT) 
  1648   (is_inited_LT C pTs lvars LT) 
  1649   \<longrightarrow> bc_mt_corresp (compExprs jmb exs) (compTpExprs jmb G exs) (ST, LT) (comp G) rT (length LT) (length (compExprs jmb exs)))"
  1649   \<longrightarrow> bc_mt_corresp (compExprs jmb exs) (compTpExprs jmb G exs) (ST, LT) (comp G) rT (length LT) (length (compExprs jmb exs)))"
  1650 
  1650 
  1651 apply (rule  expr.induct)
  1651 apply (rule compat_expr_expr_list.induct)
  1652 
  1652 
  1653 
  1653 
  1654 (* expresssions *)
  1654 (* expresssions *)
  1655 
  1655 
  1656 (* NewC *)
  1656 (* NewC *)
  1688 (* BinOp *)
  1688 (* BinOp *)
  1689 
  1689 
  1690 apply (intro allI impI)
  1690 apply (intro allI impI)
  1691 apply (simp (no_asm_simp) only:)
  1691 apply (simp (no_asm_simp) only:)
  1692 apply (drule BinOp_invers, erule exE, (erule conjE)+)
  1692 apply (drule BinOp_invers, erule exE, (erule conjE)+)
  1693 apply (case_tac binop)
  1693 apply (rename_tac binop expr1 expr2 ST LT T bc' f' Ta, case_tac binop)
  1694 apply (simp (no_asm_simp))
  1694 apply (simp (no_asm_simp))
  1695 
  1695 
  1696   (* case Eq *)
  1696   (* case Eq *)
  1697 apply (subgoal_tac "bc_mt_corresp bc' f' (ST, LT) (comp G) rT (length LT) 0")
  1697 apply (subgoal_tac "bc_mt_corresp bc' f' (ST, LT) (comp G) rT (length LT) 0")
  1698 prefer 2
  1698 prefer 2
  1817 apply (frule wf_java_mdecl_disjoint_varnames, simp add: disjoint_varnames_def)
  1817 apply (frule wf_java_mdecl_disjoint_varnames, simp add: disjoint_varnames_def)
  1818 apply (frule wf_java_mdecl_length_pTs_pns)
  1818 apply (frule wf_java_mdecl_length_pTs_pns)
  1819 apply clarify
  1819 apply clarify
  1820 apply (simp (no_asm_use))
  1820 apply (simp (no_asm_use))
  1821 apply (rule bc_mt_corresp_comb) apply (rule HOL.refl, simp (no_asm_simp), blast)
  1821 apply (rule bc_mt_corresp_comb) apply (rule HOL.refl, simp (no_asm_simp), blast)
       
  1822 apply (rename_tac vname x2 ST LT T Ta)
  1822 apply (rule_tac ?bc1.0="[Dup]" and ?bc2.0="[Store (index (pns, lvars, blk, res) vname)]" 
  1823 apply (rule_tac ?bc1.0="[Dup]" and ?bc2.0="[Store (index (pns, lvars, blk, res) vname)]" 
  1823        and ?f1.0="dupST" and ?f2.0="popST (Suc 0)"
  1824        and ?f1.0="dupST" and ?f2.0="popST (Suc 0)"
  1824        in bc_mt_corresp_comb) 
  1825        in bc_mt_corresp_comb)
  1825   apply (simp (no_asm_simp))+
  1826   apply (simp (no_asm_simp))+
  1826   apply (rule bc_mt_corresp_Dup)
  1827   apply (rule bc_mt_corresp_Dup)
  1827   apply (simp only: compTpExpr_LT_ST)
  1828   apply (simp only: compTpExpr_LT_ST)
  1828   apply (simp add: dupST_def is_inited_LT_def)
  1829   apply (simp add: dupST_def is_inited_LT_def)
  1829   apply (rule bc_mt_corresp_Store)
  1830   apply (rule bc_mt_corresp_Store)
  1856 apply (simp (no_asm_use))
  1857 apply (simp (no_asm_use))
  1857 apply (rule bc_mt_corresp_comb) apply (rule HOL.refl) apply simp apply blast
  1858 apply (rule bc_mt_corresp_comb) apply (rule HOL.refl) apply simp apply blast
  1858   apply (simp only: compTpExpr_LT_ST)
  1859   apply (simp only: compTpExpr_LT_ST)
  1859 apply (rule bc_mt_corresp_comb, (rule HOL.refl)+) apply blast
  1860 apply (rule bc_mt_corresp_comb, (rule HOL.refl)+) apply blast
  1860   apply (simp only: compTpExpr_LT_ST)
  1861   apply (simp only: compTpExpr_LT_ST)
       
  1862 apply (rename_tac cname x2 vname x4 ST LT T Ta Ca)
  1861 apply (rule_tac ?bc1.0="[Dup_x1]" and ?bc2.0="[Putfield vname cname]" in bc_mt_corresp_comb) 
  1863 apply (rule_tac ?bc1.0="[Dup_x1]" and ?bc2.0="[Putfield vname cname]" in bc_mt_corresp_comb) 
  1862   apply (simp (no_asm_simp))+
  1864   apply (simp (no_asm_simp))+
  1863 apply (rule bc_mt_corresp_Dup_x1)
  1865 apply (rule bc_mt_corresp_Dup_x1)
  1864   apply (simp (no_asm_simp) add: dup_x1ST_def)
  1866   apply (simp (no_asm_simp) add: dup_x1ST_def)
  1865 apply (rule bc_mt_corresp_Putfield) apply assumption+
  1867 apply (rule bc_mt_corresp_Putfield) apply assumption+
  1968 prefer 2 
  1970 prefer 2 
  1969 apply (rule bc_mt_corresp_zero) 
  1971 apply (rule bc_mt_corresp_zero) 
  1970   apply (simp (no_asm_simp) add: length_compTpStmt length_compTpExpr)
  1972   apply (simp (no_asm_simp) add: length_compTpStmt length_compTpExpr)
  1971   apply (simp (no_asm_simp))
  1973   apply (simp (no_asm_simp))
  1972 
  1974 
       
  1975 apply (rename_tac expr stmt1 stmt2 ST LT bc' f')
  1973 apply (drule_tac ?bc1.0="[]" and ?bc2.0 = "[LitPush (Bool False)]" 
  1976 apply (drule_tac ?bc1.0="[]" and ?bc2.0 = "[LitPush (Bool False)]" 
  1974   and ?bc3.0="compExpr jmb expr @ Ifcmpeq (2 + int (length (compStmt jmb stmt1))) #
  1977   and ?bc3.0="compExpr jmb expr @ Ifcmpeq (2 + int (length (compStmt jmb stmt1))) #
  1975             compStmt jmb stmt1 @ Goto (1 + int (length (compStmt jmb stmt2))) #
  1978             compStmt jmb stmt1 @ Goto (1 + int (length (compStmt jmb stmt2))) #
  1976             compStmt jmb stmt2" 
  1979             compStmt jmb stmt2" 
  1977   and ?f1.0=comb_nil and ?f2.0 = "pushST [PrimT Boolean]" 
  1980   and ?f1.0=comb_nil and ?f2.0 = "pushST [PrimT Boolean]" 
  2109 prefer 2 
  2112 prefer 2 
  2110 apply (rule bc_mt_corresp_zero) 
  2113 apply (rule bc_mt_corresp_zero) 
  2111   apply (simp (no_asm_simp) add: length_compTpStmt length_compTpExpr)
  2114   apply (simp (no_asm_simp) add: length_compTpStmt length_compTpExpr)
  2112   apply (simp (no_asm_simp))
  2115   apply (simp (no_asm_simp))
  2113 
  2116 
       
  2117 apply (rename_tac expr stmt ST LT bc' f')
  2114 apply (drule_tac ?bc1.0="[]" and ?bc2.0 = "[LitPush (Bool False)]" 
  2118 apply (drule_tac ?bc1.0="[]" and ?bc2.0 = "[LitPush (Bool False)]" 
  2115   and ?bc3.0="compExpr jmb expr @ Ifcmpeq (2 + int (length (compStmt jmb stmt))) #
  2119   and ?bc3.0="compExpr jmb expr @ Ifcmpeq (2 + int (length (compStmt jmb stmt))) #
  2116             compStmt jmb stmt @ 
  2120             compStmt jmb stmt @ 
  2117             [Goto (-2 + (- int (length (compStmt jmb stmt)) - int (length (compExpr jmb expr))))]" 
  2121             [Goto (-2 + (- int (length (compStmt jmb stmt)) - int (length (compExpr jmb expr))))]" 
  2118   and ?f1.0=comb_nil and ?f2.0 = "pushST [PrimT Boolean]" 
  2122   and ?f1.0=comb_nil and ?f2.0 = "pushST [PrimT Boolean]"