author | wenzelm |
Thu, 06 Jun 2024 22:26:40 +0200 | |
changeset 80274 | cff00b3dddf5 |
parent 62763 | 3e9a68bd30a7 |
child 81279 | d2e39f0f9b40 |
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 |
Author: Markus Wenzel, TU Muenchen |
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
3 |
|
17349 | 4 |
Automatic bindings of Isar text elements. |
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 |
|
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
7 |
signature AUTO_BIND = |
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
8 |
sig |
9296 | 9 |
val thesisN: string |
17349 | 10 |
val thisN: string |
60448 | 11 |
val thatN: string |
21448 | 12 |
val assmsN: string |
60408
1fd46ced2fa8
more uniform treatment of auto bindings vs. explicit user bindings;
wenzelm
parents:
60401
diff
changeset
|
13 |
val abs_params: term -> term -> term |
59970 | 14 |
val goal: Proof.context -> term list -> (indexname * term option) list |
62763 | 15 |
val dddot: indexname |
59970 | 16 |
val facts: Proof.context -> term list -> (indexname * term option) list |
60401 | 17 |
val no_facts: indexname list |
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 |
|
33386 | 20 |
structure Auto_Bind: AUTO_BIND = |
6783
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 |
|
10359 | 23 |
(** bindings **) |
24 |
||
25 |
val thesisN = "thesis"; |
|
26 |
val thisN = "this"; |
|
60448 | 27 |
val thatN = "that"; |
21448 | 28 |
val assmsN = "assms"; |
10359 | 29 |
|
59970 | 30 |
fun strip_judgment ctxt = Object_Logic.drop_judgment ctxt o Logic.strip_assums_concl; |
11764 | 31 |
|
60408
1fd46ced2fa8
more uniform treatment of auto bindings vs. explicit user bindings;
wenzelm
parents:
60401
diff
changeset
|
32 |
fun abs_params prop = fold_rev Term.abs (Logic.strip_params prop); |
1fd46ced2fa8
more uniform treatment of auto bindings vs. explicit user bindings;
wenzelm
parents:
60401
diff
changeset
|
33 |
|
59970 | 34 |
fun statement_binds ctxt name prop = |
60408
1fd46ced2fa8
more uniform treatment of auto bindings vs. explicit user bindings;
wenzelm
parents:
60401
diff
changeset
|
35 |
[((name, 0), SOME (abs_params prop (strip_judgment ctxt prop)))]; |
10359 | 36 |
|
37 |
||
38 |
(* goal *) |
|
39 |
||
59970 | 40 |
fun goal ctxt [prop] = statement_binds ctxt thesisN prop |
15531 | 41 |
| goal _ _ = [((thesisN, 0), NONE)]; |
10359 | 42 |
|
43 |
||
62763 | 44 |
(* dddot *) |
45 |
||
46 |
val dddot = ("dddot", 0); |
|
47 |
||
48 |
val _ = |
|
49 |
Theory.setup (Sign.parse_translation |
|
50 |
[("_DDDOT", fn _ => fn ts => Term.list_comb (Syntax.var dddot, ts))]); |
|
51 |
||
52 |
||
10359 | 53 |
(* facts *) |
54 |
||
59970 | 55 |
fun get_arg ctxt prop = |
56 |
(case strip_judgment ctxt prop of |
|
60408
1fd46ced2fa8
more uniform treatment of auto bindings vs. explicit user bindings;
wenzelm
parents:
60401
diff
changeset
|
57 |
_ $ t => SOME (abs_params prop t) |
15531 | 58 |
| _ => NONE); |
10359 | 59 |
|
60408
1fd46ced2fa8
more uniform treatment of auto bindings vs. explicit user bindings;
wenzelm
parents:
60401
diff
changeset
|
60 |
fun facts ctxt props = |
1fd46ced2fa8
more uniform treatment of auto bindings vs. explicit user bindings;
wenzelm
parents:
60401
diff
changeset
|
61 |
(case try List.last props of |
1fd46ced2fa8
more uniform treatment of auto bindings vs. explicit user bindings;
wenzelm
parents:
60401
diff
changeset
|
62 |
NONE => [] |
62763 | 63 |
| SOME prop => [(dddot, get_arg ctxt prop)] @ statement_binds ctxt thisN prop); |
10359 | 64 |
|
62763 | 65 |
val no_facts = [dddot, (thisN, 0)]; |
10808 | 66 |
|
6783
9cf9c17d9e35
renamed object_logic.ML to Isar/auto_bind.ML and tuned this module;
wenzelm
parents:
diff
changeset
|
67 |
end; |