src/HOL/Nominal/nominal_induct.ML
changeset 42361 23f352990944
parent 37137 bac3d00a910a
child 42488 4638622bcaa1
equal deleted inserted replaced
42360:da8817d01e7c 42361:23f352990944
    52         (x, tuple (map Free avoiding)) ::
    52         (x, tuple (map Free avoiding)) ::
    53         map_filter (fn (z, SOME t) => SOME (z, t) | _ => NONE) (zs ~~ inst)
    53         map_filter (fn (z, SOME t) => SOME (z, t) | _ => NONE) (zs ~~ inst)
    54       end;
    54       end;
    55      val substs =
    55      val substs =
    56        map2 subst insts concls |> flat |> distinct (op =)
    56        map2 subst insts concls |> flat |> distinct (op =)
    57        |> map (pairself (Thm.cterm_of (ProofContext.theory_of ctxt)));
    57        |> map (pairself (Thm.cterm_of (Proof_Context.theory_of ctxt)));
    58   in 
    58   in 
    59     (((cases, nconcls), consumes), Drule.cterm_instantiate substs joined_rule) 
    59     (((cases, nconcls), consumes), Drule.cterm_instantiate substs joined_rule) 
    60   end;
    60   end;
    61 
    61 
    62 fun rename_params_rule internal xs rule =
    62 fun rename_params_rule internal xs rule =
    81 
    81 
    82 (* nominal_induct_tac *)
    82 (* nominal_induct_tac *)
    83 
    83 
    84 fun nominal_induct_tac ctxt simp def_insts avoiding fixings rules facts =
    84 fun nominal_induct_tac ctxt simp def_insts avoiding fixings rules facts =
    85   let
    85   let
    86     val thy = ProofContext.theory_of ctxt;
    86     val thy = Proof_Context.theory_of ctxt;
    87     val cert = Thm.cterm_of thy;
    87     val cert = Thm.cterm_of thy;
    88 
    88 
    89     val ((insts, defs), defs_ctxt) = fold_map Induct.add_defs def_insts ctxt |>> split_list;
    89     val ((insts, defs), defs_ctxt) = fold_map Induct.add_defs def_insts ctxt |>> split_list;
    90     val atomized_defs = map (map (Conv.fconv_rule Induct.atomize_cterm)) defs;
    90     val atomized_defs = map (map (Conv.fconv_rule Induct.atomize_cterm)) defs;
    91 
    91 
    92     val finish_rule =
    92     val finish_rule =
    93       split_all_tuples
    93       split_all_tuples
    94       #> rename_params_rule true
    94       #> rename_params_rule true
    95         (map (Name.clean o ProofContext.revert_skolem defs_ctxt o fst) avoiding);
    95         (map (Name.clean o Proof_Context.revert_skolem defs_ctxt o fst) avoiding);
    96 
    96 
    97     fun rule_cases ctxt r =
    97     fun rule_cases ctxt r =
    98       let val r' = if simp then Induct.simplified_rule ctxt r else r
    98       let val r' = if simp then Induct.simplified_rule ctxt r else r
    99       in Rule_Cases.make_nested (Thm.prop_of r') (Induct.rulified_term r') end;
    99       in Rule_Cases.make_nested (Thm.prop_of r') (Induct.rulified_term r') end;
   100   in
   100   in
   124             Induct.guess_instance ctxt
   124             Induct.guess_instance ctxt
   125               (finish_rule (Induct.internalize more_consumes rule)) i st'
   125               (finish_rule (Induct.internalize more_consumes rule)) i st'
   126             |> Seq.maps (fn rule' =>
   126             |> Seq.maps (fn rule' =>
   127               CASES (rule_cases ctxt rule' cases)
   127               CASES (rule_cases ctxt rule' cases)
   128                 (Tactic.rtac (rename_params_rule false [] rule') i THEN
   128                 (Tactic.rtac (rename_params_rule false [] rule') i THEN
   129                   PRIMITIVE (singleton (ProofContext.export defs_ctxt ctxt))) st'))))
   129                   PRIMITIVE (singleton (Proof_Context.export defs_ctxt ctxt))) st'))))
   130     THEN_ALL_NEW_CASES
   130     THEN_ALL_NEW_CASES
   131       ((if simp then Induct.simplify_tac ctxt THEN' (TRY o Induct.trivial_tac)
   131       ((if simp then Induct.simplify_tac ctxt THEN' (TRY o Induct.trivial_tac)
   132         else K all_tac)
   132         else K all_tac)
   133        THEN_ALL_NEW Induct.rulify_tac)
   133        THEN_ALL_NEW Induct.rulify_tac)
   134   end;
   134   end;