src/Pure/morphism.ML
author wenzelm
Thu Nov 23 00:51:57 2006 +0100 (2006-11-23)
changeset 21476 4677b7b84247
child 21492 c73faa8e98aa
permissions -rw-r--r--
Abstract morphisms on formal entities.
wenzelm@21476
     1
(*  Title:      Pure/morphism.ML
wenzelm@21476
     2
    ID:         $Id$
wenzelm@21476
     3
    Author:     Makarius
wenzelm@21476
     4
wenzelm@21476
     5
Abstract morphisms on formal entities.
wenzelm@21476
     6
*)
wenzelm@21476
     7
wenzelm@21476
     8
infix 1 $>
wenzelm@21476
     9
wenzelm@21476
    10
signature BASIC_MORPHISM =
wenzelm@21476
    11
sig
wenzelm@21476
    12
  type morphism
wenzelm@21476
    13
  val $> : morphism * morphism -> morphism
wenzelm@21476
    14
end
wenzelm@21476
    15
wenzelm@21476
    16
signature MORPHISM =
wenzelm@21476
    17
sig
wenzelm@21476
    18
  include BASIC_MORPHISM
wenzelm@21476
    19
  val var: morphism -> string * mixfix -> string * mixfix
wenzelm@21476
    20
  val name: morphism -> string -> string
wenzelm@21476
    21
  val typ: morphism -> typ -> typ
wenzelm@21476
    22
  val term: morphism -> term -> term
wenzelm@21476
    23
  val thm: morphism -> thm -> thm
wenzelm@21476
    24
  val morphism:
wenzelm@21476
    25
   {name: string -> string,
wenzelm@21476
    26
    var: string * mixfix -> string * mixfix,
wenzelm@21476
    27
    typ: typ -> typ,
wenzelm@21476
    28
    term: term -> term,
wenzelm@21476
    29
    thm: thm -> thm} -> morphism
wenzelm@21476
    30
  val comp: morphism -> morphism -> morphism
wenzelm@21476
    31
  val identity: morphism
wenzelm@21476
    32
  val transfer: theory -> morphism
wenzelm@21476
    33
end;
wenzelm@21476
    34
wenzelm@21476
    35
structure Morphism: MORPHISM =
wenzelm@21476
    36
struct
wenzelm@21476
    37
wenzelm@21476
    38
datatype morphism = Morphism of
wenzelm@21476
    39
 {name: string -> string,
wenzelm@21476
    40
  var: string * mixfix -> string * mixfix,
wenzelm@21476
    41
  typ: typ -> typ,
wenzelm@21476
    42
  term: term -> term,
wenzelm@21476
    43
  thm: thm -> thm};
wenzelm@21476
    44
wenzelm@21476
    45
fun name (Morphism {name, ...}) = name;
wenzelm@21476
    46
fun var (Morphism {var, ...}) = var;
wenzelm@21476
    47
fun typ (Morphism {typ, ...}) = typ;
wenzelm@21476
    48
fun term (Morphism {term, ...}) = term;
wenzelm@21476
    49
fun thm (Morphism {thm, ...}) = thm;
wenzelm@21476
    50
wenzelm@21476
    51
val morphism = Morphism;
wenzelm@21476
    52
wenzelm@21476
    53
fun comp
wenzelm@21476
    54
    (Morphism {name = name1, var = var1, typ = typ1, term = term1, thm = thm1})
wenzelm@21476
    55
    (Morphism {name = name2, var = var2, typ = typ2, term = term2, thm = thm2}) =
wenzelm@21476
    56
  morphism {name = name1 o name2, var = var1 o var2,
wenzelm@21476
    57
    typ = typ1 o typ2, term = term1 o term2, thm = thm1 o thm2};
wenzelm@21476
    58
wenzelm@21476
    59
fun phi1 $> phi2 = comp phi2 phi1;
wenzelm@21476
    60
wenzelm@21476
    61
val identity = morphism {name = I, var = I, typ = I, term = I, thm = I};
wenzelm@21476
    62
wenzelm@21476
    63
fun transfer thy = morphism {name = I, var = I, typ = I, term = I, thm = Thm.transfer thy};
wenzelm@21476
    64
wenzelm@21476
    65
end;
wenzelm@21476
    66
wenzelm@21476
    67
structure BasicMorphism: BASIC_MORPHISM = Morphism;
wenzelm@21476
    68
open BasicMorphism;
wenzelm@21476
    69