src/Tools/induct_tacs.ML
changeset 55715 bc04f1ab3c3a
parent 55111 5792f5106c40
child 58826 2ed2eaabe3df
equal deleted inserted replaced
55714:ed1b789d0b21 55715:bc04f1ab3c3a
    21 fun check_type ctxt (t, pos) =
    21 fun check_type ctxt (t, pos) =
    22   let
    22   let
    23     val u = singleton (Variable.polymorphic ctxt) t;
    23     val u = singleton (Variable.polymorphic ctxt) t;
    24     val U = Term.fastype_of u;
    24     val U = Term.fastype_of u;
    25     val _ = Term.is_TVar U andalso
    25     val _ = Term.is_TVar U andalso
    26       error ("Cannot determine type of " ^ Syntax.string_of_term ctxt u ^ Position.here pos);
    26       error ("Cannot determine type of " ^
       
    27         quote (Syntax.string_of_term ctxt u) ^ Position.here pos);
    27   in (u, U) end;
    28   in (u, U) end;
    28 
    29 
    29 fun gen_case_tac ctxt0 s opt_rule i st =
    30 fun gen_case_tac ctxt0 s opt_rule i st =
    30   let
    31   let
    31     val (_, ctxt) = Variable.focus_subgoal i st ctxt0;
    32     val (_, ctxt) = Variable.focus_subgoal i st ctxt0;
    73       let
    74       let
    74         val t = Syntax.read_term ctxt name;
    75         val t = Syntax.read_term ctxt name;
    75         val pos = Syntax.read_token_pos name;
    76         val pos = Syntax.read_token_pos name;
    76         val (x, _) = Term.dest_Free t handle TERM _ =>
    77         val (x, _) = Term.dest_Free t handle TERM _ =>
    77           error ("Induction argument not a variable: " ^
    78           error ("Induction argument not a variable: " ^
    78             Syntax.string_of_term ctxt t ^ Position.here pos);
    79             quote (Syntax.string_of_term ctxt t) ^ Position.here pos);
    79         val eq_x = fn Free (y, _) => x = y | _ => false;
    80         val eq_x = fn Free (y, _) => x = y | _ => false;
    80         val _ =
    81         val _ =
    81           if Term.exists_subterm eq_x concl then ()
    82           if Term.exists_subterm eq_x concl then ()
    82           else
    83           else
    83             error ("No such variable in subgoal: " ^
    84             error ("No such variable in subgoal: " ^
    84               Syntax.string_of_term ctxt t ^ Position.here pos);
    85               quote (Syntax.string_of_term ctxt t) ^ Position.here pos);
    85         val _ =
    86         val _ =
    86           if (exists o Term.exists_subterm) eq_x prems then
    87           if (exists o Term.exists_subterm) eq_x prems then
    87             warning ("Induction variable occurs also among premises: " ^
    88             warning ("Induction variable occurs also among premises: " ^
    88               Syntax.string_of_term ctxt t ^ Position.here pos)
    89               quote (Syntax.string_of_term ctxt t) ^ Position.here pos)
    89           else ();
    90           else ();
    90       in #1 (check_type ctxt (t, pos)) end;
    91       in #1 (check_type ctxt (t, pos)) end;
    91 
    92 
    92     val argss = map (map (Option.map induct_var)) varss;
    93     val argss = map (map (Option.map induct_var)) varss;
    93     val rule =
    94     val rule =