author | webertj |
Fri, 01 Jun 2007 23:52:06 +0200 | |
changeset 23195 | f065f7c846fe |
parent 22670 | c803b2696ada |
child 24031 | e94e541346d7 |
permissions | -rw-r--r-- |
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 |
22235 | 25 |
val cterm: morphism -> cterm -> cterm |
21476 | 26 |
val morphism: |
27 |
{name: string -> string, |
|
28 |
var: string * mixfix -> string * mixfix, |
|
29 |
typ: typ -> typ, |
|
30 |
term: term -> term, |
|
21521 | 31 |
fact: thm list -> thm list} -> morphism |
21492 | 32 |
val name_morphism: (string -> string) -> morphism |
33 |
val var_morphism: (string * mixfix -> string * mixfix) -> morphism |
|
34 |
val typ_morphism: (typ -> typ) -> morphism |
|
35 |
val term_morphism: (term -> term) -> morphism |
|
21521 | 36 |
val fact_morphism: (thm list -> thm list) -> morphism |
21492 | 37 |
val thm_morphism: (thm -> thm) -> morphism |
21476 | 38 |
val identity: morphism |
22571
3f00e937d1c9
renamed comp to compose (avoid clash with Alice keywords);
wenzelm
parents:
22235
diff
changeset
|
39 |
val compose: morphism -> morphism -> morphism |
22670
c803b2696ada
added Morphism.transform/form (generic non-sense);
wenzelm
parents:
22571
diff
changeset
|
40 |
val transform: morphism -> (morphism -> 'a) -> morphism -> 'a |
c803b2696ada
added Morphism.transform/form (generic non-sense);
wenzelm
parents:
22571
diff
changeset
|
41 |
val form: (morphism -> 'a) -> 'a |
21476 | 42 |
end; |
43 |
||
44 |
structure Morphism: MORPHISM = |
|
45 |
struct |
|
46 |
||
47 |
datatype morphism = Morphism of |
|
48 |
{name: string -> string, |
|
49 |
var: string * mixfix -> string * mixfix, |
|
50 |
typ: typ -> typ, |
|
51 |
term: term -> term, |
|
21521 | 52 |
fact: thm list -> thm list}; |
21476 | 53 |
|
54 |
fun name (Morphism {name, ...}) = name; |
|
55 |
fun var (Morphism {var, ...}) = var; |
|
56 |
fun typ (Morphism {typ, ...}) = typ; |
|
57 |
fun term (Morphism {term, ...}) = term; |
|
21521 | 58 |
fun fact (Morphism {fact, ...}) = fact; |
59 |
val thm = singleton o fact; |
|
22235 | 60 |
val cterm = Drule.cterm_rule o thm; |
21476 | 61 |
|
62 |
val morphism = Morphism; |
|
63 |
||
21521 | 64 |
fun name_morphism name = morphism {name = name, var = I, typ = I, term = I, fact = I}; |
65 |
fun var_morphism var = morphism {name = I, var = var, typ = I, term = I, fact = I}; |
|
66 |
fun typ_morphism typ = morphism {name = I, var = I, typ = typ, term = I, fact = I}; |
|
67 |
fun term_morphism term = morphism {name = I, var = I, typ = I, term = term, fact = I}; |
|
68 |
fun fact_morphism fact = morphism {name = I, var = I, typ = I, term = I, fact = fact}; |
|
69 |
fun thm_morphism thm = morphism {name = I, var = I, typ = I, term = I, fact = map thm}; |
|
21492 | 70 |
|
21521 | 71 |
val identity = morphism {name = I, var = I, typ = I, term = I, fact = I}; |
21492 | 72 |
|
22571
3f00e937d1c9
renamed comp to compose (avoid clash with Alice keywords);
wenzelm
parents:
22235
diff
changeset
|
73 |
fun compose |
21521 | 74 |
(Morphism {name = name1, var = var1, typ = typ1, term = term1, fact = fact1}) |
75 |
(Morphism {name = name2, var = var2, typ = typ2, term = term2, fact = fact2}) = |
|
21476 | 76 |
morphism {name = name1 o name2, var = var1 o var2, |
21521 | 77 |
typ = typ1 o typ2, term = term1 o term2, fact = fact1 o fact2}; |
21476 | 78 |
|
22571
3f00e937d1c9
renamed comp to compose (avoid clash with Alice keywords);
wenzelm
parents:
22235
diff
changeset
|
79 |
fun phi1 $> phi2 = compose phi2 phi1; |
21476 | 80 |
|
22670
c803b2696ada
added Morphism.transform/form (generic non-sense);
wenzelm
parents:
22571
diff
changeset
|
81 |
fun transform phi f = fn psi => f (phi $> psi); |
c803b2696ada
added Morphism.transform/form (generic non-sense);
wenzelm
parents:
22571
diff
changeset
|
82 |
fun form f = f identity; |
c803b2696ada
added Morphism.transform/form (generic non-sense);
wenzelm
parents:
22571
diff
changeset
|
83 |
|
21476 | 84 |
end; |
85 |
||
86 |
structure BasicMorphism: BASIC_MORPHISM = Morphism; |
|
87 |
open BasicMorphism; |