summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2010-03-15 14:52:47 +0000
committerkrasimir <krasimir@chalmers.se>2010-03-15 14:52:47 +0000
commitc6f3111e67975d674a4f04cbd3a314a1aa6456fe (patch)
tree2a5dd625e22bb831c5d5cf1d157b995a5ccfb268 /examples
parentaef1a1a5a35a403b3d32c3e3ad8923310a0624f0 (diff)
added natural transformations
Diffstat (limited to 'examples')
-rw-r--r--examples/category-theory/CategoryTheory.gf1
-rw-r--r--examples/category-theory/Functor.gf15
-rw-r--r--examples/category-theory/NaturalTransform.gf10
3 files changed, 26 insertions, 0 deletions
diff --git a/examples/category-theory/CategoryTheory.gf b/examples/category-theory/CategoryTheory.gf
index 800bdb4a3..d079c53b1 100644
--- a/examples/category-theory/CategoryTheory.gf
+++ b/examples/category-theory/CategoryTheory.gf
@@ -3,6 +3,7 @@ abstract CategoryTheory
, Morphisms
, InitialAndTerminal
, Functor
+ , NaturalTransform
, Equalizer
** {
} \ No newline at end of file
diff --git a/examples/category-theory/Functor.gf b/examples/category-theory/Functor.gf
index e6df95b0f..58432a349 100644
--- a/examples/category-theory/Functor.gf
+++ b/examples/category-theory/Functor.gf
@@ -12,7 +12,22 @@ data functor : ({c1, c2} : Category)
fun compF : ({c1,c2,c3} : Category) -> Functor c3 c2 -> Functor c1 c3 -> Functor c1 c2 ;
def compF {c1} {c2} {c3} (functor {c3} {c2} f032 f132 eqid32 eqcmp32) (functor {c1} {c3} f013 f113 eqid13 eqcmp13) =
functor (\x -> f032 (f013 x)) (\x -> f132 (f113 x)) (\x -> mapEqAr (f132 {?} {?}) eqid13) ? ;
+-}
+fun mapEl : ({c1, c2} : Category)
+ -> Functor c1 c2
+ -> El c1
+ -> El c2 ;
+def mapEl {c1} {c2} (functor {c1} {c2} f0 f1 _ _) = f0 ;
+{-
+fun mapAr : ({c1, c2} : Category)
+ -> ({x,y} : El c1)
+ -> (f : Functor c1 c2)
+ -> Arrow x y
+ -> Arrow (mapEl f x) (mapEl f y) ;
+def mapAr {c1} {c2} {x} {y} (functor {c1} {c2} f0 f1 _ _) = f1 {x} {y} ;
+-}
+{-
fun mapEqAr : ({c} : Category)
-> ({x,y} : El c)
-> ({f,g} : Arrow x y)
diff --git a/examples/category-theory/NaturalTransform.gf b/examples/category-theory/NaturalTransform.gf
new file mode 100644
index 000000000..01a7a65ef
--- /dev/null
+++ b/examples/category-theory/NaturalTransform.gf
@@ -0,0 +1,10 @@
+abstract NaturalTransform = Functor ** {
+
+cat NT ({c1,c2} : Category) (f,g : Functor c1 c2) ;
+
+data nt : ({c1,c2} : Category)
+ -> (f,g : Functor c1 c2)
+ -> ((x : El c1) -> Arrow (mapEl f x) (mapEl g x))
+ -> NT f g ;
+
+} \ No newline at end of file