src/Pure/Isar/auto_bind.ML
author wenzelm
Thu, 07 Oct 1999 12:36:53 +0200
changeset 7775 26898fbd19ca
parent 7675 c859160e78b0
child 8227 d67db92897df
permissions -rw-r--r--
verbatim / verb markupup commands;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/Isar/auto_bind.ML
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     4
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     5
Automatic term bindings -- logic specific patterns.
7675
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
     6
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
     7
The implementation below works fine with the more common
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
     8
object-logics, such as HOL, ZF.
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
     9
*)
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    10
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    11
signature AUTO_BIND =
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    12
sig
7599
40b7f7f51208 admit unbinding;
wenzelm
parents: 7474
diff changeset
    13
  val goal: term -> (indexname * term option) list
40b7f7f51208 admit unbinding;
wenzelm
parents: 7474
diff changeset
    14
  val facts: string -> term list -> (indexname * term option) list
7675
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    15
  val atomic_thesis: term -> (string * term) * term
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    16
end;
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    17
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    18
structure AutoBind: AUTO_BIND =
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    19
struct
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    20
7675
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    21
val thesisN = "thesis";
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    22
val thisN = "this";
6796
c2e5cb8cd50d facts: bind named props (from proof.ML/let_thms);
wenzelm
parents: 6783
diff changeset
    23
7675
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    24
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    25
(* goal *)
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    26
6796
c2e5cb8cd50d facts: bind named props (from proof.ML/let_thms);
wenzelm
parents: 6783
diff changeset
    27
fun statement_binds (name, prop) =
c2e5cb8cd50d facts: bind named props (from proof.ML/let_thms);
wenzelm
parents: 6783
diff changeset
    28
  let
7331
aee8f76fe54c ??thesis: include params;
wenzelm
parents: 7048
diff changeset
    29
    val concl = Logic.strip_assums_concl prop;
aee8f76fe54c ??thesis: include params;
wenzelm
parents: 7048
diff changeset
    30
    val parms = Logic.strip_params prop;
aee8f76fe54c ??thesis: include params;
wenzelm
parents: 7048
diff changeset
    31
    fun list_abs tm = foldr (fn ((x, T), t) => Abs (x, T, t)) (parms, tm);
aee8f76fe54c ??thesis: include params;
wenzelm
parents: 7048
diff changeset
    32
7599
40b7f7f51208 admit unbinding;
wenzelm
parents: 7474
diff changeset
    33
    val env = [(name ^ "_prop", Some prop), (name ^ "_concl", Some (list_abs concl)),
40b7f7f51208 admit unbinding;
wenzelm
parents: 7474
diff changeset
    34
      (name, case concl of Const ("Trueprop", _) $ t => Some (list_abs t) | _ => None)];
7474
43cedde6d52a removed Syntax.binding;
wenzelm
parents: 7452
diff changeset
    35
  in map (fn (s, t) => ((s, 0), t)) env end;
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    36
7675
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    37
fun goal prop = statement_binds (thesisN, prop);
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    38
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    39
6796
c2e5cb8cd50d facts: bind named props (from proof.ML/let_thms);
wenzelm
parents: 6783
diff changeset
    40
(* facts *)
c2e5cb8cd50d facts: bind named props (from proof.ML/let_thms);
wenzelm
parents: 6783
diff changeset
    41
c2e5cb8cd50d facts: bind named props (from proof.ML/let_thms);
wenzelm
parents: 6783
diff changeset
    42
fun dddot_bind prop =
7599
40b7f7f51208 admit unbinding;
wenzelm
parents: 7474
diff changeset
    43
  [(Syntax.dddot_indexname,
40b7f7f51208 admit unbinding;
wenzelm
parents: 7474
diff changeset
    44
      case Logic.strip_imp_concl prop of Const ("Trueprop", _) $ (_ $ t) => Some t | _ => None)];
6796
c2e5cb8cd50d facts: bind named props (from proof.ML/let_thms);
wenzelm
parents: 6783
diff changeset
    45
c2e5cb8cd50d facts: bind named props (from proof.ML/let_thms);
wenzelm
parents: 6783
diff changeset
    46
fun facts _ [] = []
7452
c2289eabf706 "this";
wenzelm
parents: 7331
diff changeset
    47
  | facts name props =
c2289eabf706 "this";
wenzelm
parents: 7331
diff changeset
    48
      let val prop = Library.last_elem props
7675
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    49
      in dddot_bind prop @ statement_binds (thisN, prop) end;
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    50
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    51
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    52
(* atomic_thesis *)
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    53
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    54
fun mk_free t = Free (thesisN, Term.fastype_of t);
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    55
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    56
fun atomic_thesis ((c as Const ("Trueprop", _)) $ t) = ((thesisN, t), c $ mk_free t)
c859160e78b0 added atomic_thesis;
wenzelm
parents: 7599
diff changeset
    57
  | atomic_thesis t = ((thesisN, t), mk_free t);
6796
c2e5cb8cd50d facts: bind named props (from proof.ML/let_thms);
wenzelm
parents: 6783
diff changeset
    58
      
c2e5cb8cd50d facts: bind named props (from proof.ML/let_thms);
wenzelm
parents: 6783
diff changeset
    59
6783
9cf9c17d9e35 renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff changeset
    60
end;