src/Pure/morphism.ML
author wenzelm
Thu Nov 23 20:33:28 2006 +0100 (2006-11-23)
changeset 21492 c73faa8e98aa
parent 21476 4677b7b84247
child 21521 095f4963beed
permissions -rw-r--r--
added name/var/typ/term/thm_morphism;
removed transfer;
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@21492
    30
  val name_morphism: (string -> string) -> morphism
wenzelm@21492
    31
  val var_morphism: (string * mixfix -> string * mixfix) -> morphism
wenzelm@21492
    32
  val typ_morphism: (typ -> typ) -> morphism
wenzelm@21492
    33
  val term_morphism: (term -> term) -> morphism
wenzelm@21492
    34
  val thm_morphism: (thm -> thm) -> morphism
wenzelm@21476
    35
  val identity: morphism
wenzelm@21492
    36
  val comp: morphism -> morphism -> morphism
wenzelm@21476
    37
end;
wenzelm@21476
    38
wenzelm@21476
    39
structure Morphism: MORPHISM =
wenzelm@21476
    40
struct
wenzelm@21476
    41
wenzelm@21476
    42
datatype morphism = Morphism of
wenzelm@21476
    43
 {name: string -> string,
wenzelm@21476
    44
  var: string * mixfix -> string * mixfix,
wenzelm@21476
    45
  typ: typ -> typ,
wenzelm@21476
    46
  term: term -> term,
wenzelm@21476
    47
  thm: thm -> thm};
wenzelm@21476
    48
wenzelm@21476
    49
fun name (Morphism {name, ...}) = name;
wenzelm@21476
    50
fun var (Morphism {var, ...}) = var;
wenzelm@21476
    51
fun typ (Morphism {typ, ...}) = typ;
wenzelm@21476
    52
fun term (Morphism {term, ...}) = term;
wenzelm@21476
    53
fun thm (Morphism {thm, ...}) = thm;
wenzelm@21476
    54
wenzelm@21476
    55
val morphism = Morphism;
wenzelm@21476
    56
wenzelm@21492
    57
fun name_morphism name = morphism {name = name, var = I, typ = I, term = I, thm = I};
wenzelm@21492
    58
fun var_morphism var = morphism {name = I, var = var, typ = I, term = I, thm = I};
wenzelm@21492
    59
fun typ_morphism typ = morphism {name = I, var = I, typ = typ, term = I, thm = I};
wenzelm@21492
    60
fun term_morphism term = morphism {name = I, var = I, typ = I, term = term, thm = I};
wenzelm@21492
    61
fun thm_morphism thm = morphism {name = I, var = I, typ = I, term = I, thm = thm};
wenzelm@21492
    62
wenzelm@21492
    63
val identity = morphism {name = I, var = I, typ = I, term = I, thm = I};
wenzelm@21492
    64
wenzelm@21476
    65
fun comp
wenzelm@21476
    66
    (Morphism {name = name1, var = var1, typ = typ1, term = term1, thm = thm1})
wenzelm@21476
    67
    (Morphism {name = name2, var = var2, typ = typ2, term = term2, thm = thm2}) =
wenzelm@21476
    68
  morphism {name = name1 o name2, var = var1 o var2,
wenzelm@21476
    69
    typ = typ1 o typ2, term = term1 o term2, thm = thm1 o thm2};
wenzelm@21476
    70
wenzelm@21476
    71
fun phi1 $> phi2 = comp phi2 phi1;
wenzelm@21476
    72
wenzelm@21476
    73
end;
wenzelm@21476
    74
wenzelm@21476
    75
structure BasicMorphism: BASIC_MORPHISM = Morphism;
wenzelm@21476
    76
open BasicMorphism;