21476
|
1 |
(* Title: Pure/morphism.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Makarius
|
|
4 |
|
|
5 |
Abstract morphisms on formal entities.
|
|
6 |
*)
|
|
7 |
|
|
8 |
infix 1 $>
|
|
9 |
|
|
10 |
signature BASIC_MORPHISM =
|
|
11 |
sig
|
|
12 |
type morphism
|
|
13 |
val $> : morphism * morphism -> morphism
|
|
14 |
end
|
|
15 |
|
|
16 |
signature MORPHISM =
|
|
17 |
sig
|
|
18 |
include BASIC_MORPHISM
|
|
19 |
val var: morphism -> string * mixfix -> string * mixfix
|
|
20 |
val name: morphism -> string -> string
|
|
21 |
val typ: morphism -> typ -> typ
|
|
22 |
val term: morphism -> term -> term
|
21521
|
23 |
val fact: morphism -> thm list -> thm list
|
21476
|
24 |
val thm: morphism -> thm -> thm
|
|
25 |
val morphism:
|
|
26 |
{name: string -> string,
|
|
27 |
var: string * mixfix -> string * mixfix,
|
|
28 |
typ: typ -> typ,
|
|
29 |
term: term -> term,
|
21521
|
30 |
fact: thm list -> thm list} -> morphism
|
21492
|
31 |
val name_morphism: (string -> string) -> morphism
|
|
32 |
val var_morphism: (string * mixfix -> string * mixfix) -> morphism
|
|
33 |
val typ_morphism: (typ -> typ) -> morphism
|
|
34 |
val term_morphism: (term -> term) -> morphism
|
21521
|
35 |
val fact_morphism: (thm list -> thm list) -> morphism
|
21492
|
36 |
val thm_morphism: (thm -> thm) -> morphism
|
21476
|
37 |
val identity: morphism
|
21492
|
38 |
val comp: morphism -> morphism -> morphism
|
21476
|
39 |
end;
|
|
40 |
|
|
41 |
structure Morphism: MORPHISM =
|
|
42 |
struct
|
|
43 |
|
|
44 |
datatype morphism = Morphism of
|
|
45 |
{name: string -> string,
|
|
46 |
var: string * mixfix -> string * mixfix,
|
|
47 |
typ: typ -> typ,
|
|
48 |
term: term -> term,
|
21521
|
49 |
fact: thm list -> thm list};
|
21476
|
50 |
|
|
51 |
fun name (Morphism {name, ...}) = name;
|
|
52 |
fun var (Morphism {var, ...}) = var;
|
|
53 |
fun typ (Morphism {typ, ...}) = typ;
|
|
54 |
fun term (Morphism {term, ...}) = term;
|
21521
|
55 |
fun fact (Morphism {fact, ...}) = fact;
|
|
56 |
val thm = singleton o fact;
|
21476
|
57 |
|
|
58 |
val morphism = Morphism;
|
|
59 |
|
21521
|
60 |
fun name_morphism name = morphism {name = name, var = I, typ = I, term = I, fact = I};
|
|
61 |
fun var_morphism var = morphism {name = I, var = var, typ = I, term = I, fact = I};
|
|
62 |
fun typ_morphism typ = morphism {name = I, var = I, typ = typ, term = I, fact = I};
|
|
63 |
fun term_morphism term = morphism {name = I, var = I, typ = I, term = term, fact = I};
|
|
64 |
fun fact_morphism fact = morphism {name = I, var = I, typ = I, term = I, fact = fact};
|
|
65 |
fun thm_morphism thm = morphism {name = I, var = I, typ = I, term = I, fact = map thm};
|
21492
|
66 |
|
21521
|
67 |
val identity = morphism {name = I, var = I, typ = I, term = I, fact = I};
|
21492
|
68 |
|
21476
|
69 |
fun comp
|
21521
|
70 |
(Morphism {name = name1, var = var1, typ = typ1, term = term1, fact = fact1})
|
|
71 |
(Morphism {name = name2, var = var2, typ = typ2, term = term2, fact = fact2}) =
|
21476
|
72 |
morphism {name = name1 o name2, var = var1 o var2,
|
21521
|
73 |
typ = typ1 o typ2, term = term1 o term2, fact = fact1 o fact2};
|
21476
|
74 |
|
|
75 |
fun phi1 $> phi2 = comp phi2 phi1;
|
|
76 |
|
|
77 |
end;
|
|
78 |
|
|
79 |
structure BasicMorphism: BASIC_MORPHISM = Morphism;
|
|
80 |
open BasicMorphism;
|