src/CCL/Wfd.thy
changeset 58976 b38a54bbfbd6
parent 58975 762ee71498fa
child 58977 9576b510f6a2
equal deleted inserted replaced
58975:762ee71498fa 58976:b38a54bbfbd6
   409 
   409 
   410 
   410 
   411 subsection {* Typechecking *}
   411 subsection {* Typechecking *}
   412 
   412 
   413 ML {*
   413 ML {*
   414 
       
   415 local
   414 local
   416 
   415 
   417 val type_rls =
   416 val type_rls =
   418   @{thms canTs} @ @{thms icanTs} @ @{thms applyT2} @ @{thms ncanTs} @ @{thms incanTs} @
   417   @{thms canTs} @ @{thms icanTs} @ @{thms applyT2} @ @{thms ncanTs} @ @{thms incanTs} @
   419   @{thms precTs} @ @{thms letrecTs} @ @{thms letT} @ @{thms Subtype_canTs};
   418   @{thms precTs} @ @{thms letrecTs} @ @{thms letT} @ @{thms Subtype_canTs};
   442       fun try_IHs [] = no_tac
   441       fun try_IHs [] = no_tac
   443         | try_IHs ((x,y)::xs) = tac [(("g", 0), x)] (nth rls (y - 1)) i ORELSE (try_IHs xs)
   442         | try_IHs ((x,y)::xs) = tac [(("g", 0), x)] (nth rls (y - 1)) i ORELSE (try_IHs xs)
   444   in try_IHs rnames end)
   443   in try_IHs rnames end)
   445 
   444 
   446 fun is_rigid_prog t =
   445 fun is_rigid_prog t =
   447      case (Logic.strip_assums_concl t) of
   446   (case (Logic.strip_assums_concl t) of
   448         (Const(@{const_name Trueprop},_) $ (Const(@{const_name mem},_) $ a $ _)) => null (Term.add_vars a [])
   447     (Const(@{const_name Trueprop},_) $ (Const(@{const_name mem},_) $ a $ _)) =>
   449        | _ => false
   448       null (Term.add_vars a [])
       
   449   | _ => false)
       
   450 
   450 in
   451 in
   451 
   452 
   452 fun rcall_tac ctxt i =
   453 fun rcall_tac ctxt i =
   453   let fun tac ps rl i = res_inst_tac ctxt ps rl i THEN atac i
   454   let fun tac ps rl i = res_inst_tac ctxt ps rl i THEN atac i
   454   in IHinst tac @{thms rcallTs} i end
   455   in IHinst tac @{thms rcallTs} i end
   459   rcall_tac ctxt i ORELSE
   460   rcall_tac ctxt i ORELSE
   460   ematch_tac ctxt [@{thm SubtypeE}] i ORELSE
   461   ematch_tac ctxt [@{thm SubtypeE}] i ORELSE
   461   match_tac ctxt [@{thm SubtypeI}] i
   462   match_tac ctxt [@{thm SubtypeI}] i
   462 
   463 
   463 fun tc_step_tac ctxt prems = SUBGOAL (fn (Bi,i) =>
   464 fun tc_step_tac ctxt prems = SUBGOAL (fn (Bi,i) =>
   464           if is_rigid_prog Bi then raw_step_tac ctxt prems i else no_tac)
   465     if is_rigid_prog Bi then raw_step_tac ctxt prems i else no_tac)
   465 
   466 
   466 fun typechk_tac ctxt rls i = SELECT_GOAL (REPEAT_FIRST (tc_step_tac ctxt rls)) i
   467 fun typechk_tac ctxt rls i = SELECT_GOAL (REPEAT_FIRST (tc_step_tac ctxt rls)) i
   467 
   468 
   468 fun tac ctxt = typechk_tac ctxt [] 1
       
   469 
   469 
   470 (*** Clean up Correctness Condictions ***)
   470 (*** Clean up Correctness Condictions ***)
   471 
   471 
   472 fun clean_ccs_tac ctxt =
   472 fun clean_ccs_tac ctxt =
   473   let fun tac ps rl i = eres_inst_tac ctxt ps rl i THEN atac i in
   473   let fun tac ps rl i = eres_inst_tac ctxt ps rl i THEN atac i in