src/Pure/morphism.ML
author wenzelm
Sun Feb 04 22:02:15 2007 +0100 (2007-02-04)
changeset 22235 6eac7f7c3294
parent 21521 095f4963beed
child 22571 3f00e937d1c9
permissions -rw-r--r--
added cterm interface;
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@21521
    23
  val fact: morphism -> thm list -> thm list
wenzelm@21476
    24
  val thm: morphism -> thm -> thm
wenzelm@22235
    25
  val cterm: morphism -> cterm -> cterm
wenzelm@21476
    26
  val morphism:
wenzelm@21476
    27
   {name: string -> string,
wenzelm@21476
    28
    var: string * mixfix -> string * mixfix,
wenzelm@21476
    29
    typ: typ -> typ,
wenzelm@21476
    30
    term: term -> term,
wenzelm@21521
    31
    fact: thm list -> thm list} -> morphism
wenzelm@21492
    32
  val name_morphism: (string -> string) -> morphism
wenzelm@21492
    33
  val var_morphism: (string * mixfix -> string * mixfix) -> morphism
wenzelm@21492
    34
  val typ_morphism: (typ -> typ) -> morphism
wenzelm@21492
    35
  val term_morphism: (term -> term) -> morphism
wenzelm@21521
    36
  val fact_morphism: (thm list -> thm list) -> morphism
wenzelm@21492
    37
  val thm_morphism: (thm -> thm) -> morphism
wenzelm@21476
    38
  val identity: morphism
wenzelm@21492
    39
  val comp: morphism -> morphism -> morphism
wenzelm@21476
    40
end;
wenzelm@21476
    41
wenzelm@21476
    42
structure Morphism: MORPHISM =
wenzelm@21476
    43
struct
wenzelm@21476
    44
wenzelm@21476
    45
datatype morphism = Morphism of
wenzelm@21476
    46
 {name: string -> string,
wenzelm@21476
    47
  var: string * mixfix -> string * mixfix,
wenzelm@21476
    48
  typ: typ -> typ,
wenzelm@21476
    49
  term: term -> term,
wenzelm@21521
    50
  fact: thm list -> thm list};
wenzelm@21476
    51
wenzelm@21476
    52
fun name (Morphism {name, ...}) = name;
wenzelm@21476
    53
fun var (Morphism {var, ...}) = var;
wenzelm@21476
    54
fun typ (Morphism {typ, ...}) = typ;
wenzelm@21476
    55
fun term (Morphism {term, ...}) = term;
wenzelm@21521
    56
fun fact (Morphism {fact, ...}) = fact;
wenzelm@21521
    57
val thm = singleton o fact;
wenzelm@22235
    58
val cterm = Drule.cterm_rule o thm;
wenzelm@21476
    59
wenzelm@21476
    60
val morphism = Morphism;
wenzelm@21476
    61
wenzelm@21521
    62
fun name_morphism name = morphism {name = name, var = I, typ = I, term = I, fact = I};
wenzelm@21521
    63
fun var_morphism var = morphism {name = I, var = var, typ = I, term = I, fact = I};
wenzelm@21521
    64
fun typ_morphism typ = morphism {name = I, var = I, typ = typ, term = I, fact = I};
wenzelm@21521
    65
fun term_morphism term = morphism {name = I, var = I, typ = I, term = term, fact = I};
wenzelm@21521
    66
fun fact_morphism fact = morphism {name = I, var = I, typ = I, term = I, fact = fact};
wenzelm@21521
    67
fun thm_morphism thm = morphism {name = I, var = I, typ = I, term = I, fact = map thm};
wenzelm@21492
    68
wenzelm@21521
    69
val identity = morphism {name = I, var = I, typ = I, term = I, fact = I};
wenzelm@21492
    70
wenzelm@21476
    71
fun comp
wenzelm@21521
    72
    (Morphism {name = name1, var = var1, typ = typ1, term = term1, fact = fact1})
wenzelm@21521
    73
    (Morphism {name = name2, var = var2, typ = typ2, term = term2, fact = fact2}) =
wenzelm@21476
    74
  morphism {name = name1 o name2, var = var1 o var2,
wenzelm@21521
    75
    typ = typ1 o typ2, term = term1 o term2, fact = fact1 o fact2};
wenzelm@21476
    76
wenzelm@21476
    77
fun phi1 $> phi2 = comp phi2 phi1;
wenzelm@21476
    78
wenzelm@21476
    79
end;
wenzelm@21476
    80
wenzelm@21476
    81
structure BasicMorphism: BASIC_MORPHISM = Morphism;
wenzelm@21476
    82
open BasicMorphism;