src/HOL/Tools/inductive_package.ML
changeset 6141 a6922171b396
parent 6092 d9db67970c73
child 6394 3d9fd50fcc43
equal deleted inserted replaced
6140:af32e2c3f77a 6141:a6922171b396
    32   val quiet_mode : bool ref
    32   val quiet_mode : bool ref
    33   val add_inductive_i : bool -> bool -> bstring -> bool -> bool -> bool -> term list ->
    33   val add_inductive_i : bool -> bool -> bstring -> bool -> bool -> bool -> term list ->
    34     term list -> thm list -> thm list -> theory -> theory *
    34     term list -> thm list -> thm list -> theory -> theory *
    35       {defs:thm list, elims:thm list, raw_induct:thm, induct:thm,
    35       {defs:thm list, elims:thm list, raw_induct:thm, induct:thm,
    36        intrs:thm list,
    36        intrs:thm list,
    37        mk_cases:thm list -> string -> thm, mono:thm,
    37        mk_cases:string -> thm, mono:thm,
    38        unfold:thm}
    38        unfold:thm}
    39   val add_inductive : bool -> bool -> string list -> string list
    39   val add_inductive : bool -> bool -> string list -> string list
    40     -> xstring list -> xstring list -> theory -> theory *
    40     -> xstring list -> xstring list -> theory -> theory *
    41       {defs:thm list, elims:thm list, raw_induct:thm, induct:thm,
    41       {defs:thm list, elims:thm list, raw_induct:thm, induct:thm,
    42        intrs:thm list,
    42        intrs:thm list,
    43        mk_cases:thm list -> string -> thm, mono:thm,
    43        mk_cases:string -> thm, mono:thm,
    44        unfold:thm}
    44        unfold:thm}
    45 end;
    45 end;
    46 
    46 
    47 structure InductivePackage : INDUCTIVE_PACKAGE =
    47 structure InductivePackage : INDUCTIVE_PACKAGE =
    48 struct
    48 struct
   287 
   287 
   288 (*Applies freeness of the given constructors, which *must* be unfolded by
   288 (*Applies freeness of the given constructors, which *must* be unfolded by
   289   the given defs.  Cannot simply use the local con_defs because con_defs=[] 
   289   the given defs.  Cannot simply use the local con_defs because con_defs=[] 
   290   for inference systems.
   290   for inference systems.
   291  *)
   291  *)
   292 fun con_elim_tac simps =
   292 fun con_elim_tac ss =
   293   let val elim_tac = REPEAT o (eresolve_tac elim_rls)
   293   let val elim_tac = REPEAT o (eresolve_tac elim_rls)
   294   in ALLGOALS(EVERY'[elim_tac,
   294   in ALLGOALS(EVERY'[elim_tac,
   295                  asm_full_simp_tac (simpset_of NatDef.thy addsimps simps),
   295 		     asm_full_simp_tac ss,
   296                  elim_tac,
   296 		     elim_tac,
   297                  REPEAT o bound_hyp_subst_tac])
   297 		     REPEAT o bound_hyp_subst_tac])
   298      THEN prune_params_tac
   298      THEN prune_params_tac
   299   end;
   299   end;
   300 
   300 
   301 (*String s should have the form t:Si where Si is an inductive set*)
   301 (*String s should have the form t:Si where Si is an inductive set*)
   302 fun mk_cases elims simps s =
   302 fun mk_cases elims s =
   303   let val prem = assume (read_cterm (sign_of_thm (hd elims)) (s, propT));
   303   let val prem = assume (read_cterm (sign_of_thm (hd elims)) (s, propT))
   304       val elims' = map (try (fn r =>
   304       fun mk_elim rl = rule_by_tactic (con_elim_tac (simpset())) (prem RS rl) 
   305         rule_by_tactic (con_elim_tac simps) (prem RS r) |> standard)) elims
   305 	               |> standard
   306   in case find_first is_some elims' of
   306   in case find_first is_some (map (try mk_elim) elims) of
   307        Some (Some r) => r
   307        Some (Some r) => r
   308      | None => error ("mk_cases: string '" ^ s ^ "' not of form 't : S_i'")
   308      | None => error ("mk_cases: string '" ^ s ^ "' not of form 't : S_i'")
   309   end;
   309   end;
   310 
   310 
   311 (**************************** prove induction rule ****************************)
   311 (**************************** prove induction rule ****************************)