70574
|
1 |
(* Title: Pure/thm_name.ML
|
|
2 |
Author: Makarius
|
|
3 |
|
|
4 |
Systematic naming of individual theorems, as selections from multi-facts.
|
|
5 |
|
|
6 |
(NAME, 0): the single entry of a singleton fact NAME
|
|
7 |
(NAME, i): entry i of a non-singleton fact (1 <= i <= length)
|
|
8 |
*)
|
|
9 |
|
|
10 |
signature THM_NAME =
|
|
11 |
sig
|
|
12 |
type T = string * int
|
70586
|
13 |
val ord: T ord
|
70574
|
14 |
val print: T -> string
|
79376
|
15 |
val short: T * Position.T -> string * Position.T
|
79371
|
16 |
val list: string * Position.T -> 'a list -> ((T * Position.T) * 'a) list
|
79372
|
17 |
val expr: string * Position.T -> ('a list * 'b) list -> (((T * Position.T) * 'a) list * 'b) list
|
70574
|
18 |
end;
|
|
19 |
|
|
20 |
structure Thm_Name: THM_NAME =
|
|
21 |
struct
|
|
22 |
|
|
23 |
type T = string * int;
|
|
24 |
val ord = prod_ord string_ord int_ord;
|
|
25 |
|
70575
|
26 |
fun print (name, index) =
|
|
27 |
if name = "" orelse index = 0 then name
|
|
28 |
else name ^ enclose "(" ")" (string_of_int index);
|
70574
|
29 |
|
79376
|
30 |
fun short ((name, index), pos: Position.T) =
|
79358
|
31 |
if name = "" orelse index = 0 then (name, pos)
|
|
32 |
else (name ^ "_" ^ string_of_int index, pos);
|
70574
|
33 |
|
79371
|
34 |
fun list (name, pos: Position.T) [thm] = [(((name, 0): T, pos), thm)]
|
|
35 |
| list (name, pos) thms = map_index (fn (i, thm) => (((name, i + 1), pos), thm)) thms;
|
70574
|
36 |
|
79377
|
37 |
fun expr name = burrow_fst (burrow (list name));
|
79372
|
38 |
|
70574
|
39 |
end;
|