src/HOL/HOLCF/Tools/Domain/domain_constructors.ML
changeset 60754 02924903a6fd
parent 59621 291934bac95e
child 60801 7664e0916eec
equal deleted inserted replaced
60753:80ca4a065a48 60754:02924903a6fd
   140         val lhs = list_ccomb (con, args)
   140         val lhs = list_ccomb (con, args)
   141         val goal = mk_equals (lhs, rhs)
   141         val goal = mk_equals (lhs, rhs)
   142         val cs = ContProc.cont_thms lam
   142         val cs = ContProc.cont_thms lam
   143         val betas = map (fn c => mk_meta_eq (c RS @{thm beta_cfun})) cs
   143         val betas = map (fn c => mk_meta_eq (c RS @{thm beta_cfun})) cs
   144       in
   144       in
   145         prove thy (def_thm::betas) goal (K [rtac reflexive_thm 1])
   145         prove thy (def_thm::betas) goal
       
   146           (fn {context = ctxt, ...} => [resolve_tac ctxt [reflexive_thm] 1])
   146       end
   147       end
   147 end
   148 end
   148 
   149 
   149 (******************************************************************************)
   150 (******************************************************************************)
   150 (************* definitions and theorems for constructor functions *************)
   151 (************* definitions and theorems for constructor functions *************)
   226           val conj = foldr1 mk_conj (eqn :: map mk_defined nonlazy)
   227           val conj = foldr1 mk_conj (eqn :: map mk_defined nonlazy)
   227         in Library.foldr mk_ex (vs, conj) end
   228         in Library.foldr mk_ex (vs, conj) end
   228       val goal = mk_trp (foldr1 mk_disj (mk_undef y :: map one_con spec'))
   229       val goal = mk_trp (foldr1 mk_disj (mk_undef y :: map one_con spec'))
   229       (* first rules replace "y = bottom \/ P" with "rep$y = bottom \/ P" *)
   230       (* first rules replace "y = bottom \/ P" with "rep$y = bottom \/ P" *)
   230       fun tacs ctxt = [
   231       fun tacs ctxt = [
   231           rtac (iso_locale RS @{thm iso.casedist_rule}) 1,
   232           resolve_tac ctxt [iso_locale RS @{thm iso.casedist_rule}] 1,
   232           rewrite_goals_tac ctxt [mk_meta_eq (iso_locale RS @{thm iso.iso_swap})],
   233           rewrite_goals_tac ctxt [mk_meta_eq (iso_locale RS @{thm iso.iso_swap})],
   233           rtac thm3 1]
   234           resolve_tac ctxt [thm3] 1]
   234     in
   235     in
   235       val nchotomy = prove thy con_betas goal (tacs o #context)
   236       val nchotomy = prove thy con_betas goal (tacs o #context)
   236       val exhaust =
   237       val exhaust =
   237           (nchotomy RS @{thm exh_casedist0})
   238           (nchotomy RS @{thm exh_casedist0})
   238           |> rewrite_rule (Proof_Context.init_global thy) @{thms exh_casedists}
   239           |> rewrite_rule (Proof_Context.init_global thy) @{thms exh_casedists}
   243     val compacts =
   244     val compacts =
   244       let
   245       let
   245         val rules = @{thms compact_sinl compact_sinr compact_spair
   246         val rules = @{thms compact_sinl compact_sinr compact_spair
   246                            compact_up compact_ONE}
   247                            compact_up compact_ONE}
   247         fun tacs ctxt =
   248         fun tacs ctxt =
   248           [rtac (iso_locale RS @{thm iso.compact_abs}) 1,
   249           [resolve_tac ctxt [iso_locale RS @{thm iso.compact_abs}] 1,
   249            REPEAT (resolve_tac ctxt rules 1 ORELSE atac 1)]
   250            REPEAT (resolve_tac ctxt rules 1 ORELSE assume_tac ctxt 1)]
   250         fun con_compact (con, args) =
   251         fun con_compact (con, args) =
   251           let
   252           let
   252             val vs = vars_of args
   253             val vs = vars_of args
   253             val con_app = list_ccomb (con, vs)
   254             val con_app = list_ccomb (con, vs)
   254             val concl = mk_trp (mk_compact con_app)
   255             val concl = mk_trp (mk_compact con_app)
   707 
   708 
   708     (* prove discriminator strictness rules *)
   709     (* prove discriminator strictness rules *)
   709     local
   710     local
   710       fun dis_strict dis =
   711       fun dis_strict dis =
   711         let val goal = mk_trp (mk_strict dis)
   712         let val goal = mk_trp (mk_strict dis)
   712         in prove thy dis_defs goal (K [rtac (hd case_rews) 1]) end
   713         in
       
   714           prove thy dis_defs goal
       
   715             (fn {context = ctxt, ...} => [resolve_tac ctxt [hd case_rews] 1])
       
   716         end
   713     in
   717     in
   714       val dis_stricts = map dis_strict dis_consts
   718       val dis_stricts = map dis_strict dis_consts
   715     end
   719     end
   716 
   720 
   717     (* prove discriminator/constructor rules *)
   721     (* prove discriminator/constructor rules *)
   737       fun dis_defin dis =
   741       fun dis_defin dis =
   738         let
   742         let
   739           val x = Free ("x", lhsT)
   743           val x = Free ("x", lhsT)
   740           val simps = dis_apps @ @{thms dist_eq_tr}
   744           val simps = dis_apps @ @{thms dist_eq_tr}
   741           fun tacs ctxt =
   745           fun tacs ctxt =
   742             [rtac @{thm iffI} 1,
   746             [resolve_tac ctxt @{thms iffI} 1,
   743              asm_simp_tac (put_simpset HOL_basic_ss ctxt addsimps dis_stricts) 2,
   747              asm_simp_tac (put_simpset HOL_basic_ss ctxt addsimps dis_stricts) 2,
   744              rtac exhaust 1, atac 1,
   748              resolve_tac ctxt [exhaust] 1, assume_tac ctxt 1,
   745              ALLGOALS (asm_full_simp_tac (put_simpset simple_ss ctxt addsimps simps))]
   749              ALLGOALS (asm_full_simp_tac (put_simpset simple_ss ctxt addsimps simps))]
   746           val goal = mk_trp (mk_eq (mk_undef (dis ` x), mk_undef x))
   750           val goal = mk_trp (mk_eq (mk_undef (dis ` x), mk_undef x))
   747         in prove thy [] goal (tacs o #context) end
   751         in prove thy [] goal (tacs o #context) end
   748     in
   752     in
   749       val dis_defins = map dis_defin dis_consts
   753       val dis_defins = map dis_defin dis_consts