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