src/Pure/Isar/auto_bind.ML
author wenzelm
Mon, 19 Jul 1999 21:26:33 +0200
changeset 7048 3535eec33c50
parent 6796 c2e5cb8cd50d
child 7331 aee8f76fe54c
permissions -rw-r--r--
facts: no statement_binds;

(*  Title:      Pure/Isar/auto_bind.ML
    ID:         $Id$
    Author:     Markus Wenzel, TU Muenchen

Automatic term bindings -- logic specific patterns.
*)

signature AUTO_BIND =
sig
  val goal: term -> (indexname * term) list
  val facts: string -> term list -> (indexname * term) list
end;

structure AutoBind: AUTO_BIND =
struct


(* goals *)

fun statement_binds (name, prop) =
  let
    val concl = Logic.strip_imp_concl prop;
    val env = [(name ^ "_prop", prop), (name ^ "_concl", concl)] @
      (case concl of Const ("Trueprop", _) $ t => [(name, t)] | _ => []);
  in map (fn (s, t) => ((Syntax.binding s, 0), t)) env end;

fun goal prop = statement_binds ("thesis", prop);


(* facts *)

fun dddot_bind prop =
  (case Logic.strip_imp_concl prop of
    Const ("Trueprop", _) $ (_ $ t) => [(Syntax.dddot_indexname, t)]
  | _ => []);

fun facts _ [] = []
  | facts name [prop] = dddot_bind prop
  | facts name props =  dddot_bind (Library.last_elem props);
      

end;