author | wenzelm |
Mon, 06 Mar 2000 21:10:27 +0100 | |
changeset 8351 | 1b8ac0f48233 |
parent 8227 | d67db92897df |
child 8612 | e8ef58d6d6eb |
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 |
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 | 6 |
|
8227 | 7 |
Note: the current implementation is not quite 'generic', but works |
8 |
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
|
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 | 13 |
val goal: term -> (indexname * term option) list |
14 |
val facts: string -> term list -> (indexname * term option) list |
|
7675 | 15 |
val atomic_thesis: term -> (string * term) * term |
8227 | 16 |
val add_judgment: bstring * string * mixfix -> theory -> theory |
17 |
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
|
18 |
end; |
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
19 |
|
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
20 |
structure AutoBind: AUTO_BIND = |
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
21 |
struct |
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
22 |
|
7675 | 23 |
val thesisN = "thesis"; |
24 |
val thisN = "this"; |
|
6796 | 25 |
|
7675 | 26 |
|
8227 | 27 |
(** bindings **) |
28 |
||
7675 | 29 |
(* goal *) |
6783
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
30 |
|
6796 | 31 |
fun statement_binds (name, prop) = |
32 |
let |
|
7331 | 33 |
val concl = Logic.strip_assums_concl prop; |
34 |
val parms = Logic.strip_params prop; |
|
35 |
fun list_abs tm = foldr (fn ((x, T), t) => Abs (x, T, t)) (parms, tm); |
|
36 |
||
7599 | 37 |
val env = [(name ^ "_prop", Some prop), (name ^ "_concl", Some (list_abs concl)), |
38 |
(name, case concl of Const ("Trueprop", _) $ t => Some (list_abs t) | _ => None)]; |
|
7474 | 39 |
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
|
40 |
|
7675 | 41 |
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
|
42 |
|
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
43 |
|
6796 | 44 |
(* facts *) |
45 |
||
46 |
fun dddot_bind prop = |
|
7599 | 47 |
[(Syntax.dddot_indexname, |
48 |
case Logic.strip_imp_concl prop of Const ("Trueprop", _) $ (_ $ t) => Some t | _ => None)]; |
|
6796 | 49 |
|
50 |
fun facts _ [] = [] |
|
7452 | 51 |
| facts name props = |
52 |
let val prop = Library.last_elem props |
|
7675 | 53 |
in dddot_bind prop @ statement_binds (thisN, prop) end; |
54 |
||
55 |
||
56 |
(* atomic_thesis *) |
|
57 |
||
58 |
fun mk_free t = Free (thesisN, Term.fastype_of t); |
|
59 |
||
60 |
fun atomic_thesis ((c as Const ("Trueprop", _)) $ t) = ((thesisN, t), c $ mk_free t) |
|
61 |
| atomic_thesis t = ((thesisN, t), mk_free t); |
|
8227 | 62 |
|
63 |
||
64 |
(** judgment **) |
|
65 |
||
66 |
fun gen_add_judgment add args = PureThy.local_path o add [args] o PureThy.global_path; |
|
67 |
||
68 |
val add_judgment = gen_add_judgment Theory.add_consts; |
|
69 |
val add_judgment_i = gen_add_judgment Theory.add_consts_i; |
|
70 |
||
6796 | 71 |
|
6783
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
72 |
end; |