src/Pure/Isar/auto_bind.ML
author wenzelm
Tue Aug 24 11:50:17 1999 +0200 (1999-08-24 ago)
changeset 7331 aee8f76fe54c
parent 7048 3535eec33c50
child 7452 c2289eabf706
permissions -rw-r--r--
??thesis: include params;
wenzelm@6783
     1
(*  Title:      Pure/Isar/auto_bind.ML
wenzelm@6783
     2
    ID:         $Id$
wenzelm@6783
     3
    Author:     Markus Wenzel, TU Muenchen
wenzelm@6783
     4
wenzelm@6783
     5
Automatic term bindings -- logic specific patterns.
wenzelm@6783
     6
*)
wenzelm@6783
     7
wenzelm@6783
     8
signature AUTO_BIND =
wenzelm@6783
     9
sig
wenzelm@6783
    10
  val goal: term -> (indexname * term) list
wenzelm@6796
    11
  val facts: string -> term list -> (indexname * term) list
wenzelm@6783
    12
end;
wenzelm@6783
    13
wenzelm@6783
    14
structure AutoBind: AUTO_BIND =
wenzelm@6783
    15
struct
wenzelm@6783
    16
wenzelm@6796
    17
wenzelm@6796
    18
(* goals *)
wenzelm@6783
    19
wenzelm@6796
    20
fun statement_binds (name, prop) =
wenzelm@6796
    21
  let
wenzelm@7331
    22
    val concl = Logic.strip_assums_concl prop;
wenzelm@7331
    23
    val parms = Logic.strip_params prop;
wenzelm@7331
    24
    fun list_abs tm = foldr (fn ((x, T), t) => Abs (x, T, t)) (parms, tm);
wenzelm@7331
    25
wenzelm@7331
    26
    val env = [(name ^ "_prop", prop), (name ^ "_concl", list_abs concl)] @
wenzelm@7331
    27
      (case concl of Const ("Trueprop", _) $ t => [(name, list_abs t)] | _ => []);
wenzelm@6796
    28
  in map (fn (s, t) => ((Syntax.binding s, 0), t)) env end;
wenzelm@6783
    29
wenzelm@6796
    30
fun goal prop = statement_binds ("thesis", prop);
wenzelm@6783
    31
wenzelm@6783
    32
wenzelm@6796
    33
(* facts *)
wenzelm@6796
    34
wenzelm@6796
    35
fun dddot_bind prop =
wenzelm@6796
    36
  (case Logic.strip_imp_concl prop of
wenzelm@6796
    37
    Const ("Trueprop", _) $ (_ $ t) => [(Syntax.dddot_indexname, t)]
wenzelm@6796
    38
  | _ => []);
wenzelm@6796
    39
wenzelm@6796
    40
fun facts _ [] = []
wenzelm@7048
    41
  | facts name [prop] = dddot_bind prop
wenzelm@7048
    42
  | facts name props =  dddot_bind (Library.last_elem props);
wenzelm@6796
    43
      
wenzelm@6796
    44
wenzelm@6783
    45
end;