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