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