| 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
 | 
|  |     15 |   val flatten: T -> string
 | 
|  |     16 |   val make_list: string -> thm list -> (T * thm) list
 | 
|  |     17 | end;
 | 
|  |     18 | 
 | 
|  |     19 | structure Thm_Name: THM_NAME =
 | 
|  |     20 | struct
 | 
|  |     21 | 
 | 
|  |     22 | type T = string * int;
 | 
|  |     23 | val ord = prod_ord string_ord int_ord;
 | 
|  |     24 | 
 | 
| 70575 |     25 | fun print (name, index) =
 | 
|  |     26 |   if name = "" orelse index = 0 then name
 | 
|  |     27 |   else name ^ enclose "(" ")" (string_of_int index);
 | 
| 70574 |     28 | 
 | 
| 70575 |     29 | fun flatten (name, index) =
 | 
|  |     30 |   if name = "" orelse index = 0 then name
 | 
|  |     31 |   else name ^ "_" ^ string_of_int index;
 | 
| 70574 |     32 | 
 | 
|  |     33 | fun make_list name [thm: thm] = [((name, 0), thm)]
 | 
|  |     34 |   | make_list name thms = map_index (fn (i, thm) => ((name, i + 1), thm)) thms;
 | 
|  |     35 | 
 | 
|  |     36 | end;
 |