src/HOL/Tools/function_package/auto_term.ML
author wenzelm
Wed, 02 Aug 2006 22:26:49 +0200
changeset 20295 8b3e97502fd9
parent 19770 be5c23ebe1eb
child 20873 4066ee15b278
permissions -rw-r--r--
use proper RecdefPackage.get_hints; tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     1
(*  Title:      HOL/Tools/function_package/auto_term.ML
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     2
    ID:         $Id$
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     3
    Author:     Alexander Krauss, TU Muenchen
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     4
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     5
A package for general recursive function definitions. 
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     6
The auto_term method.
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     7
*)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     8
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
     9
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    10
signature FUNDEF_AUTO_TERM =
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    11
sig
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    12
    val setup : theory -> theory
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    13
end
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    14
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    15
structure FundefAutoTerm : FUNDEF_AUTO_TERM = 
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    16
struct
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    17
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    18
open FundefCommon
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    19
open FundefAbbrev
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    20
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    21
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    22
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    23
fun auto_term_tac tc_intro_rule relstr wf_rules ss =
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    24
    (resolve_tac [tc_intro_rule] 1)                    (* produce the usual goals *)
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    25
        THEN (instantiate_tac [("R", relstr)])    (* instantiate with the given relation *)
20295
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    26
        THEN (ALLGOALS 
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    27
                  (fn 1 => REPEAT (ares_tac wf_rules 1)    (* Solve wellfoundedness *)
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    28
                    | i => asm_simp_tac ss i))    (* Simplify termination conditions *)
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    29
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    30
fun mk_termination_meth relstr ctxt =
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    31
    let
20295
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    32
        val {simps, congs, wfs} = RecdefPackage.get_hints (Context.Proof ctxt)
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    33
        val ss = local_simpset_of ctxt addsimps simps
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    34
            
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    35
        val intro_rule = ProofContext.get_thm ctxt (Name "termination")
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    36
          (* FIXME avoid internal name lookup -- dynamic scoping! *)
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    37
    in
20295
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    38
        Method.RAW_METHOD (K (auto_term_tac
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    39
                                  intro_rule
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    40
                                  relstr
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    41
                                  wfs
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    42
                                  ss))
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    43
    end
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    44
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    45
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    46
20295
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    47
val setup = Method.add_methods
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    48
  [("auto_term", Method.simple_args Args.name mk_termination_meth,
8b3e97502fd9 use proper RecdefPackage.get_hints;
wenzelm
parents: 19770
diff changeset
    49
    "termination prover for recdef compatibility")]
19564
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    50
d3e2f532459a First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff changeset
    51
end