src/HOL/Tools/Function/fun.ML
author wenzelm
Wed, 17 Aug 2011 16:30:38 +0200
changeset 44239 47ecd30e018d
parent 44237 2a2040c9d898
child 45639 efddd75c741e
permissions -rw-r--r--
less verbosity for 'function' and 'fun': observe "int" flag more carefully (cf. a32ca9165928);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
     1
(*  Title:      HOL/Tools/Function/fun.ML
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
     2
    Author:     Alexander Krauss, TU Muenchen
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
     3
41114
f9ae7c2abf7e tuned headers
krauss
parents: 39276
diff changeset
     4
Command "fun": Function definitions with pattern splitting/completion
f9ae7c2abf7e tuned headers
krauss
parents: 39276
diff changeset
     5
and automated termination proofs.
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
     6
*)
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
     7
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
     8
signature FUNCTION_FUN =
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
     9
sig
44237
2a2040c9d898 export Function_Fun.fun_config for user convenience;
wenzelm
parents: 43329
diff changeset
    10
  val fun_config : Function_Common.function_config
36523
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
    11
  val add_fun : (binding * typ option * mixfix) list ->
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
    12
    (Attrib.binding * term) list -> Function_Common.function_config ->
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
    13
    local_theory -> Proof.context
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
    14
  val add_fun_cmd : (binding * string option * mixfix) list ->
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
    15
    (Attrib.binding * string) list -> Function_Common.function_config ->
44239
47ecd30e018d less verbosity for 'function' and 'fun': observe "int" flag more carefully (cf. a32ca9165928);
wenzelm
parents: 44237
diff changeset
    16
    bool -> local_theory -> Proof.context
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    17
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    18
  val setup : theory -> theory
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    19
end
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    20
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    21
structure Function_Fun : FUNCTION_FUN =
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    22
struct
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    23
33099
b8cdd3d73022 function package: more standard names for structures and files
krauss
parents: 33098
diff changeset
    24
open Function_Lib
b8cdd3d73022 function package: more standard names for structures and files
krauss
parents: 33098
diff changeset
    25
open Function_Common
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    26
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    27
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    28
fun check_pats ctxt geq =
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    29
  let
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    30
    fun err str = error (cat_lines ["Malformed definition:",
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    31
      str ^ " not allowed in sequential mode.",
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    32
      Syntax.string_of_term ctxt geq])
42361
23f352990944 modernized structure Proof_Context;
wenzelm
parents: 41846
diff changeset
    33
    val thy = Proof_Context.theory_of ctxt
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    34
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    35
    fun check_constr_pattern (Bound _) = ()
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    36
      | check_constr_pattern t =
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    37
      let
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    38
        val (hd, args) = strip_comb t
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    39
      in
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    40
        (((case Datatype.info_of_constr thy (dest_Const hd) of
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    41
             SOME _ => ()
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    42
           | NONE => err "Non-constructor pattern")
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    43
          handle TERM ("dest_Const", _) => err "Non-constructor patterns");
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    44
         map check_constr_pattern args;
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    45
         ())
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    46
      end
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    47
39276
2ad95934521f improved error message for common mistake (fun f where "g x = ...")
krauss
parents: 36960
diff changeset
    48
    val (_, qs, gs, args, _) = split_def ctxt (K true) geq
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    49
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    50
    val _ = if not (null gs) then err "Conditional equations" else ()
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    51
    val _ = map check_constr_pattern args
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    52
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    53
    (* just count occurrences to check linearity *)
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    54
    val _ = if fold (fold_aterms (fn Bound _ => Integer.add 1 | _ => I)) args 0 > length qs
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    55
      then err "Nonlinear patterns" else ()
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    56
  in
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    57
    ()
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    58
  end
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    59
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    60
fun mk_catchall fixes arity_of =
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    61
  let
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    62
    fun mk_eqn ((fname, fT), _) =
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    63
      let
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    64
        val n = arity_of fname
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    65
        val (argTs, rT) = chop n (binder_types fT)
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    66
          |> apsnd (fn Ts => Ts ---> body_type fT)
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    67
43329
84472e198515 tuned signature: Name.invent and Name.invent_names;
wenzelm
parents: 43323
diff changeset
    68
        val qs = map Free (Name.invent Name.context "a" n ~~ argTs)
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    69
      in
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    70
        HOLogic.mk_eq(list_comb (Free (fname, fT), qs),
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    71
          Const ("HOL.undefined", rT))
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    72
        |> HOLogic.mk_Trueprop
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    73
        |> fold_rev Logic.all qs
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    74
      end
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    75
  in
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    76
    map mk_eqn fixes
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    77
  end
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    78
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    79
fun add_catchall ctxt fixes spec =
39276
2ad95934521f improved error message for common mistake (fun f where "g x = ...")
krauss
parents: 36960
diff changeset
    80
  let val fqgars = map (split_def ctxt (K true)) spec
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    81
      val arity_of = map (fn (fname,_,_,args,_) => (fname, length args)) fqgars
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    82
                     |> AList.lookup (op =) #> the
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    83
  in
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    84
    spec @ mk_catchall fixes arity_of
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    85
  end
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    86
42947
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
    87
fun warnings ctxt origs tss =
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
    88
  let
42947
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
    89
    fun warn_redundant t =
43277
1fd31f859fc7 pervasive Output operations;
wenzelm
parents: 42947
diff changeset
    90
      warning ("Ignoring redundant equation: " ^ quote (Syntax.string_of_term ctxt t))
42947
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
    91
    fun warn_missing strs =
43277
1fd31f859fc7 pervasive Output operations;
wenzelm
parents: 42947
diff changeset
    92
      warning (cat_lines ("Missing patterns in function definition:" :: strs))
42947
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
    93
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
    94
    val (tss', added) = chop (length origs) tss
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
    95
42947
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
    96
    val _ = case chop 3 (flat added) of
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
    97
       ([], []) => ()
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
    98
     | (eqs, []) => warn_missing (map (Syntax.string_of_term ctxt) eqs)
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
    99
     | (eqs, rest) => warn_missing (map (Syntax.string_of_term ctxt) eqs
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
   100
         @ ["(" ^ string_of_int (length rest) ^ " more)"])
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
   101
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
   102
    val _ = (origs ~~ tss')
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
   103
      |> map (fn (t, ts) => if null ts then warn_redundant t else ())
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   104
  in
42947
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
   105
    ()
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   106
  end
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   107
33099
b8cdd3d73022 function package: more standard names for structures and files
krauss
parents: 33098
diff changeset
   108
fun sequential_preproc (config as FunctionConfig {sequential, ...}) ctxt fixes spec =
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   109
  if sequential then
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   110
    let
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   111
      val (bnds, eqss) = split_list spec
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   112
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   113
      val eqs = map the_single eqss
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   114
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   115
      val feqs = eqs
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   116
        |> tap (check_defs ctxt fixes) (* Standard checks *)
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   117
        |> tap (map (check_pats ctxt)) (* More checks for sequential mode *)
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   118
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   119
      val compleqs = add_catchall ctxt fixes feqs (* Completion *)
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   120
42947
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
   121
      val spliteqs = Function_Split.split_all_equations ctxt compleqs
fcb6250bf6b4 fun command produces warning when patterns are incomplete (somewhat analogous to primrec)
krauss
parents: 42793
diff changeset
   122
        |> tap (warnings ctxt feqs)
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   123
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   124
      fun restore_spec thms =
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   125
        bnds ~~ take (length bnds) (unflat spliteqs thms)
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   126
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   127
      val spliteqs' = flat (take (length bnds) spliteqs)
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   128
      val fnames = map (fst o fst) fixes
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   129
      val indices = map (fn eq => find_index (curry op = (fname_of eq)) fnames) spliteqs'
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   130
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   131
      fun sort xs = partition_list (fn i => fn (j,_) => i = j) 0 (length fnames - 1) (indices ~~ xs)
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   132
        |> map (map snd)
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   133
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   134
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   135
      val bnds' = bnds @ replicate (length spliteqs - length bnds) Attrib.empty_binding
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   136
34232
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   137
      (* using theorem names for case name currently disabled *)
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   138
      val case_names = map_index (fn (i, (_, es)) => mk_case_names i "" (length es)) 
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   139
        (bnds' ~~ spliteqs) |> flat
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   140
    in
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   141
      (flat spliteqs, restore_spec, sort, case_names)
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   142
    end
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   143
  else
36a2a3029fd3 new year's resolution: reindented code in function package
krauss
parents: 33957
diff changeset
   144
    Function_Common.empty_preproc check_defs config ctxt fixes spec
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   145
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   146
val setup =
33099
b8cdd3d73022 function package: more standard names for structures and files
krauss
parents: 33098
diff changeset
   147
  Context.theory_map (Function_Common.set_preproc sequential_preproc)
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   148
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   149
41417
211dbd42f95d function (default) is legacy feature
krauss
parents: 41114
diff changeset
   150
val fun_config = FunctionConfig { sequential=true, default=NONE,
41846
b368a7aee46a removed support for tail-recursion from function package (now implemented by partial_function)
krauss
parents: 41417
diff changeset
   151
  domintros=false, partials=false }
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   152
44239
47ecd30e018d less verbosity for 'function' and 'fun': observe "int" flag more carefully (cf. a32ca9165928);
wenzelm
parents: 44237
diff changeset
   153
fun gen_add_fun add lthy =
36523
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
   154
  let
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
   155
    fun pat_completeness_auto ctxt =
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
   156
      Pat_Completeness.pat_completeness_tac ctxt 1
42793
88bee9f6eec7 proper Proof.context for classical tactics;
wenzelm
parents: 42361
diff changeset
   157
      THEN auto_tac ctxt
36523
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
   158
    fun prove_termination lthy =
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
   159
      Function.prove_termination NONE
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
   160
        (Function_Common.get_termination_prover lthy lthy) lthy
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
   161
  in
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
   162
    lthy
44239
47ecd30e018d less verbosity for 'function' and 'fun': observe "int" flag more carefully (cf. a32ca9165928);
wenzelm
parents: 44237
diff changeset
   163
    |> add pat_completeness_auto |> snd
36523
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
   164
    |> Local_Theory.restore
36547
2a9d0ec8c10d return updated info record after termination proof
krauss
parents: 36523
diff changeset
   165
    |> prove_termination |> snd
36523
a294e4ebe0a3 clarified signature; simpler implementation in terms of function's tactic interface
krauss
parents: 36521
diff changeset
   166
  end
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   167
44239
47ecd30e018d less verbosity for 'function' and 'fun': observe "int" flag more carefully (cf. a32ca9165928);
wenzelm
parents: 44237
diff changeset
   168
fun add_fun a b c = gen_add_fun (Function.add_function a b c)
47ecd30e018d less verbosity for 'function' and 'fun': observe "int" flag more carefully (cf. a32ca9165928);
wenzelm
parents: 44237
diff changeset
   169
fun add_fun_cmd a b c int = gen_add_fun (fn tac => Function.add_function_cmd a b c tac int)
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   170
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   171
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   172
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   173
val _ =
44239
47ecd30e018d less verbosity for 'function' and 'fun': observe "int" flag more carefully (cf. a32ca9165928);
wenzelm
parents: 44237
diff changeset
   174
  Outer_Syntax.local_theory' "fun" "define general recursive functions (short version)"
36960
01594f816e3a prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents: 36547
diff changeset
   175
  Keyword.thy_decl
33099
b8cdd3d73022 function package: more standard names for structures and files
krauss
parents: 33098
diff changeset
   176
  (function_parser fun_config
36960
01594f816e3a prefer structure Keyword, Parse, Parse_Spec, Outer_Syntax;
wenzelm
parents: 36547
diff changeset
   177
     >> (fn ((config, fixes), statements) => add_fun_cmd fixes statements config))
33098
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   178
3e9ae9032273 renamed FundefDatatype -> Function_Fun
krauss
parents:
diff changeset
   179
end