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

src/Pure/morphism.ML

author | wenzelm |

Fri Apr 12 14:54:14 2013 +0200 (2013-04-12) | |

changeset 51700 | c8f2bad67dbb |

parent 45289 | 25e9e7f527b4 |

child 53087 | 5a1dcda7967c |

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

tuned signature;

tuned comments;

tuned comments;

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 type 'a funs = ('a -> 'a) list

20 val binding: morphism -> binding -> binding

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 funs,

28 typ: typ funs,

29 term: term funs,

30 fact: thm list funs} -> morphism

31 val binding_morphism: (binding -> binding) -> morphism

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

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

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

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

36 val identity: morphism

37 val compose: morphism -> morphism -> morphism

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

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

40 end;

42 structure Morphism: MORPHISM =

43 struct

45 type 'a funs = ('a -> 'a) list;

46 fun apply fs = fold_rev (fn f => fn x => f x) fs;

48 datatype morphism = Morphism of

49 {binding: binding funs,

50 typ: typ funs,

51 term: term funs,

52 fact: thm list funs};

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

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

57 fun typ (Morphism {typ, ...}) = apply typ;

58 fun term (Morphism {term, ...}) = apply term;

59 fun fact (Morphism {fact, ...}) = apply fact;

60 val thm = singleton o fact;

61 val cterm = Drule.cterm_rule o thm;

63 val morphism = Morphism;

65 fun binding_morphism binding = morphism {binding = [binding], typ = [], term = [], fact = []};

66 fun typ_morphism typ = morphism {binding = [], typ = [typ], term = [], fact = []};

67 fun term_morphism term = morphism {binding = [], typ = [], term = [term], fact = []};

68 fun fact_morphism fact = morphism {binding = [], typ = [], term = [], fact = [fact]};

69 fun thm_morphism thm = morphism {binding = [], typ = [], term = [], fact = [map thm]};

71 val identity = morphism {binding = [], typ = [], term = [], fact = []};

73 fun compose

74 (Morphism {binding = binding1, typ = typ1, term = term1, fact = fact1})

75 (Morphism {binding = binding2, typ = typ2, term = term2, fact = fact2}) =

76 morphism {binding = binding1 @ binding2, typ = typ1 @ typ2,

77 term = term1 @ term2, fact = fact1 @ fact2};

79 fun phi1 $> phi2 = compose phi2 phi1;

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

82 fun form f = f identity;

84 end;

86 structure Basic_Morphism: BASIC_MORPHISM = Morphism;

87 open Basic_Morphism;