src/Pure/Isar/local_defs.ML
changeset 19897 fe661eb3b0e7
parent 19585 70a1ce3b23ae
child 20021 815393c02db9
equal deleted inserted replaced
19896:286d950883bc 19897:fe661eb3b0e7
    38     val pp = ProofContext.pp ctxt;
    38     val pp = ProofContext.pp ctxt;
    39     val display_term = quote o Pretty.string_of_term pp;
    39     val display_term = quote o Pretty.string_of_term pp;
    40     fun err msg = cat_error msg ("The error(s) above occurred in definition: " ^ display_term eq);
    40     fun err msg = cat_error msg ("The error(s) above occurred in definition: " ^ display_term eq);
    41     val ((lhs, _), eq') = eq
    41     val ((lhs, _), eq') = eq
    42       |> Sign.no_vars pp
    42       |> Sign.no_vars pp
    43       |> Logic.dest_def pp Term.is_Free (ProofContext.is_fixed ctxt) (K true)
    43       |> Logic.dest_def pp Term.is_Free (Variable.is_fixed ctxt) (K true)
    44       handle TERM (msg, _) => err msg | ERROR msg => err msg;
    44       handle TERM (msg, _) => err msg | ERROR msg => err msg;
    45   in (Term.dest_Free (Term.head_of lhs), eq') end;
    45   in (Term.dest_Free (Term.head_of lhs), eq') end;
    46 
    46 
    47 val abs_def = Logic.abs_def #> apfst Term.dest_Free;
    47 val abs_def = Logic.abs_def #> apfst Term.dest_Free;
    48 
    48 
   155     fun prove ctxt' t def =
   155     fun prove ctxt' t def =
   156       let
   156       let
   157         val thy' = ProofContext.theory_of ctxt';
   157         val thy' = ProofContext.theory_of ctxt';
   158         val prop' = Term.subst_atomic [(Free (c, T), t)] prop;
   158         val prop' = Term.subst_atomic [(Free (c, T), t)] prop;
   159         val frees = Term.fold_aterms (fn Free (x, _) =>
   159         val frees = Term.fold_aterms (fn Free (x, _) =>
   160           if ProofContext.is_fixed ctxt' x then I else insert (op =) x | _ => I) prop' [];
   160           if Variable.is_fixed ctxt' x then I else insert (op =) x | _ => I) prop' [];
   161       in
   161       in
   162         Goal.prove thy' frees [] prop' (K (ALLGOALS
   162         Goal.prove thy' frees [] prop' (K (ALLGOALS
   163           (meta_rewrite_tac ctxt' THEN'
   163           (meta_rewrite_tac ctxt' THEN'
   164             Tactic.rewrite_goal_tac [def] THEN'
   164             Tactic.rewrite_goal_tac [def] THEN'
   165             Tactic.resolve_tac [Drule.reflexive_thm])))
   165             Tactic.resolve_tac [Drule.reflexive_thm])))