src/Pure/Isar/auto_bind.ML
author wenzelm
Sat Sep 04 21:05:01 1999 +0200 (1999-09-04 ago)
changeset 7474 43cedde6d52a
parent 7452 c2289eabf706
child 7599 40b7f7f51208
permissions -rw-r--r--
removed Syntax.binding;
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@7474
    28
  in map (fn (s, t) => ((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@7452
    41
  | facts name props =
wenzelm@7452
    42
      let val prop = Library.last_elem props
wenzelm@7452
    43
      in dddot_bind prop @ statement_binds ("this", prop) end;
wenzelm@6796
    44
      
wenzelm@6796
    45
wenzelm@6783
    46
end;