| author | wenzelm |
| Tue, 06 Jun 2000 20:31:22 +0200 | |
| changeset 9038 | 63d20536971f |
| parent 8807 | 0046be1769f9 |
| child 9296 | 0d2b31e1ea1b |
| permissions | -rw-r--r-- |
|
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 |
| 8807 | 4 |
License: GPL (GNU GENERAL PUBLIC LICENSE) |
|
6783
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
5 |
|
|
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
6 |
Automatic term bindings -- logic specific patterns. |
| 7675 | 7 |
|
| 8227 | 8 |
Note: the current implementation is not quite 'generic', but works |
9 |
fine with the more common object-logics (HOL, FOL, ZF etc.). |
|
|
6783
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 |
|
|
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
12 |
signature AUTO_BIND = |
|
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
13 |
sig |
| 7599 | 14 |
val goal: term -> (indexname * term option) list |
15 |
val facts: string -> term list -> (indexname * term option) list |
|
| 7675 | 16 |
val atomic_thesis: term -> (string * term) * term |
| 8227 | 17 |
val add_judgment: bstring * string * mixfix -> theory -> theory |
18 |
val add_judgment_i: bstring * typ * mixfix -> theory -> theory |
|
|
6783
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
19 |
end; |
|
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
20 |
|
|
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
21 |
structure AutoBind: AUTO_BIND = |
|
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
22 |
struct |
|
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
23 |
|
| 7675 | 24 |
val thesisN = "thesis"; |
25 |
val thisN = "this"; |
|
| 6796 | 26 |
|
| 7675 | 27 |
|
| 8227 | 28 |
(** bindings **) |
29 |
||
| 8612 | 30 |
fun list_abs parms tm = foldr (fn ((x, T), t) => Abs (x, T, t)) (parms, tm); |
31 |
||
32 |
||
| 7675 | 33 |
(* goal *) |
|
6783
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
34 |
|
| 6796 | 35 |
fun statement_binds (name, prop) = |
36 |
let |
|
| 7331 | 37 |
val concl = Logic.strip_assums_concl prop; |
38 |
val parms = Logic.strip_params prop; |
|
39 |
||
| 8612 | 40 |
val env = [(name ^ "_prop", Some prop), (name ^ "_concl", Some (list_abs parms concl)), |
41 |
(name, case concl of Const ("Trueprop", _) $ t => Some (list_abs parms t) | _ => None)];
|
|
| 7474 | 42 |
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
|
43 |
|
| 7675 | 44 |
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
|
45 |
|
|
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
46 |
|
| 6796 | 47 |
(* facts *) |
48 |
||
| 8612 | 49 |
fun get_subject prop = |
50 |
(case (Logic.strip_assums_concl prop) of |
|
51 |
Const ("Trueprop", _) $ (_ $ t) => Some (list_abs (Logic.strip_params prop) t)
|
|
52 |
| _ => None); |
|
| 6796 | 53 |
|
54 |
fun facts _ [] = [] |
|
| 7452 | 55 |
| facts name props = |
56 |
let val prop = Library.last_elem props |
|
| 8612 | 57 |
in [(Syntax.dddot_indexname, get_subject prop)] @ statement_binds (thisN, prop) end; |
| 7675 | 58 |
|
59 |
||
60 |
(* atomic_thesis *) |
|
61 |
||
62 |
fun mk_free t = Free (thesisN, Term.fastype_of t); |
|
63 |
||
64 |
fun atomic_thesis ((c as Const ("Trueprop", _)) $ t) = ((thesisN, t), c $ mk_free t)
|
|
65 |
| atomic_thesis t = ((thesisN, t), mk_free t); |
|
| 8227 | 66 |
|
67 |
||
68 |
(** judgment **) |
|
69 |
||
70 |
fun gen_add_judgment add args = PureThy.local_path o add [args] o PureThy.global_path; |
|
71 |
||
72 |
val add_judgment = gen_add_judgment Theory.add_consts; |
|
73 |
val add_judgment_i = gen_add_judgment Theory.add_consts_i; |
|
74 |
||
| 6796 | 75 |
|
|
6783
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
76 |
end; |