summary |
shortlog |
changelog |
graph |
tags |
branches |
files |
changeset |
file |
revisions |
annotate |
diff |
raw

src/Pure/morphism.ML

author | wenzelm |

Sat Dec 13 15:00:39 2008 +0100 (2008-12-13) | |

changeset 29091 | b81fe045e799 |

parent 28965 | 1de908189869 |

child 29581 | b3b33e0298eb |

permissions | -rw-r--r-- |

Context.display_names;

1 (* Title: Pure/morphism.ML

2 Author: Makarius

4 Abstract morphisms on formal entities.

5 *)

7 infix 1 $>

9 signature BASIC_MORPHISM =

10 sig

11 type morphism

12 type declaration = morphism -> Context.generic -> Context.generic

13 val $> : morphism * morphism -> morphism

14 end

16 signature MORPHISM =

17 sig

18 include BASIC_MORPHISM

19 val var: morphism -> Binding.T * mixfix -> Binding.T * mixfix

20 val binding: morphism -> Binding.T -> Binding.T

21 val typ: morphism -> typ -> typ

22 val term: morphism -> term -> term

23 val fact: morphism -> thm list -> thm list

24 val thm: morphism -> thm -> thm

25 val cterm: morphism -> cterm -> cterm

26 val morphism:

27 {binding: Binding.T -> Binding.T,

28 var: Binding.T * mixfix -> Binding.T * mixfix,

29 typ: typ -> typ,

30 term: term -> term,

31 fact: thm list -> thm list} -> morphism

32 val binding_morphism: (Binding.T -> Binding.T) -> morphism

33 val var_morphism: (Binding.T * mixfix -> Binding.T * mixfix) -> morphism

34 val typ_morphism: (typ -> typ) -> morphism

35 val term_morphism: (term -> term) -> morphism

36 val fact_morphism: (thm list -> thm list) -> morphism

37 val thm_morphism: (thm -> thm) -> morphism

38 val identity: morphism

39 val compose: morphism -> morphism -> morphism

40 val transform: morphism -> (morphism -> 'a) -> morphism -> 'a

41 val form: (morphism -> 'a) -> 'a

42 end;

44 structure Morphism: MORPHISM =

45 struct

47 datatype morphism = Morphism of

48 {binding: Binding.T -> Binding.T,

49 var: Binding.T * mixfix -> Binding.T * mixfix,

50 typ: typ -> typ,

51 term: term -> term,

52 fact: thm list -> thm list};

54 type declaration = morphism -> Context.generic -> Context.generic;

56 fun binding (Morphism {binding, ...}) = binding;

57 fun var (Morphism {var, ...}) = var;

58 fun typ (Morphism {typ, ...}) = typ;

59 fun term (Morphism {term, ...}) = term;

60 fun fact (Morphism {fact, ...}) = fact;

61 val thm = singleton o fact;

62 val cterm = Drule.cterm_rule o thm;

64 val morphism = Morphism;

66 fun binding_morphism binding = morphism {binding = binding, var = I, typ = I, term = I, fact = I};

67 fun var_morphism var = morphism {binding = I, var = var, typ = I, term = I, fact = I};

68 fun typ_morphism typ = morphism {binding = I, var = I, typ = typ, term = I, fact = I};

69 fun term_morphism term = morphism {binding = I, var = I, typ = I, term = term, fact = I};

70 fun fact_morphism fact = morphism {binding = I, var = I, typ = I, term = I, fact = fact};

71 fun thm_morphism thm = morphism {binding = I, var = I, typ = I, term = I, fact = map thm};

73 val identity = morphism {binding = I, var = I, typ = I, term = I, fact = I};

75 fun compose

76 (Morphism {binding = binding1, var = var1, typ = typ1, term = term1, fact = fact1})

77 (Morphism {binding = binding2, var = var2, typ = typ2, term = term2, fact = fact2}) =

78 morphism {binding = binding1 o binding2, var = var1 o var2,

79 typ = typ1 o typ2, term = term1 o term2, fact = fact1 o fact2};

81 fun phi1 $> phi2 = compose phi2 phi1;

83 fun transform phi f = fn psi => f (phi $> psi);

84 fun form f = f identity;

86 end;

88 structure BasicMorphism: BASIC_MORPHISM = Morphism;

89 open BasicMorphism;