updated content, fixed a lot of glitches

This commit is contained in:
Yann Esposito 2012-11-16 16:48:56 +01:00
parent 6a764a9562
commit d18f1f25b0
26 changed files with 116 additions and 70 deletions

View file

@ -189,7 +189,7 @@
</section>
<section class="slide">
<h2><span class="yellow">/.*/</span> ⇒? Category Theory</h2>
<p>Gate between different scientific fields</p>
<p>Categories package entire mathematical theories.</p>
<ul>
<li>Topology</li>
<li>Quantum Physics</li>
@ -219,7 +219,7 @@
<ul><li> Time is irrelevant by default.
</li><li> Mostly static constructions like pipes.
</li><li> All pipes are round ⇒ all error at runtime
</li><li> All pipes can be plugged ⇒ all error at runtime
<ul><li> (+ ("foo" 27) 32)
</li><li> Y = λf.(λx.f (x x)) (λx.f (x x))
</li><li> Y g = g (Y g)
@ -229,12 +229,12 @@
<p>Natural abstraction: higher level functions <span class="and"><span class="and">&amp;</span></span> equations</p>
</section>
<section class="slide">
<h2>Strongly Typed Pure Programming</h2>
<ul><li>Add specific forms on pipes.
<h2>Typed Pure Programming</h2>
<ul><li>Add shapes to pipes:
<ul><li> <code class="red">4 + ["foo",27]</code> forbidden
</li><li> <code class="red">["foo",27]</code> forbidden
</li></ul>
</li><li>Pipe can contains other pipes.
</li><li>Polymorphic (elastic) shapes:
<ul><li> <code>data Maybe a = Just a | Nothing</code>
</li><li> <code>[Just 32,Nothing,Just 12] :: [Maybe Integer]</code>
</li></ul>
@ -242,18 +242,19 @@
<p>Natural abstraction: Polymorphic higher level functions.</p>
</section>
<section class="slide">
<h2>Polymorphism: <code>mappend</code></h2>
<h2>Polymorphism: <code>mappend (<>)</code></h2>
<h3><code>(<>) = `mappend`</code></h3>
<pre class="haskell"><code>"abc" <> "def" = "abcdef"
("abc","xyz") <> ("ABC","XYZ") = ("abcABC","xyzXYZ")
3 <> 4 = ERROR which law? + or *
<pre class="haskell"><code>"abc" <> "def" = "abcdef" -- String
("ab","xy") <> ("AB","XY") = ("abAB","xyXY") -- (String,String)
3 <> 4 ⇒ ERROR which law? + or * -- Int
-- Use a type to remove ambiguity
type Sum = Sum {getSum :: a} -- Just a named box
-- Monoid (N,+)
type Sum = Sum {getSum :: a}
(<>+) = getSum (Sum x <> Sum y)
3 <>+ 4 = 7
-- Monoid (N,*)
type Product = Product {getProduct :: a}
(<>*) = getProduct (Product x <> Product y)
3 <>* 4 = 12</code></pre>
@ -264,11 +265,11 @@ type Product = Product {getProduct :: a}
<p>Example: <span class="red"><code>(>>=)</code></span> with <code>[a]</code> and <code>Maybe a</code></p>
<pre class="haskell"><code>data Maybe a = Just a | Nothing</code></pre>
<pre class="haskell"><code>-- Maybe : Maybe Int >>= Int -> Maybe (Int -> Int) >>= (Int -> Int) -> Maybe Int
<pre class="haskell"><code>-- Maybe Int >>= Int -> Maybe (Int -> Int) >>= (Int -> Int) -> Maybe Int
(Just 2) <span class="red">&gt;&gt;=</span> \x -> (Just (\z->z*z)) <span class="red">&gt;&gt;=</span> \f -> Just (f x) = Just 4
Nothing <span class="red">&gt;&gt;=</span> \x -> (Just (\z->z*z)) <span class="red">&gt;&gt;=</span> \f -> Just (f x) = Nothing
-- Lists: [a] : [Int] >>= Int -> [Int -> Int] >>= (Int -> Int) -> [Int]
-- [Int] >>= Int -> [Int -> Int] >>= (Int -> Int) -> [Int]
[1,2] <span class="red">&gt;&gt;=</span> \x -> [(+10),(+20)] <span class="red">&gt;&gt;=</span> \f -> [f x] = [11,21,12,22]
[] <span class="red">&gt;&gt;=</span> \x -> [(+10),(+20)] <span class="red">&gt;&gt;=</span> \f -> [f x] = []</code></pre>
</section>
@ -419,9 +420,8 @@ type Product = Product {getProduct :: a}
</figure>
</section>
<section class="slide">
<h2>Categories Everywhere?</h2>
<h2>Category \(\Set\)</h2>
<h3>\(\Set\)</h3>
<ul>
<li> \(\ob{\Set}\) are sets</li>
<li> \(\hom{\Set}\) are functions</li>
@ -443,6 +443,7 @@ type Product = Product {getProduct :: a}
<li>\(\Grp\): (groups, group morphisms,∘)</li>
<li>\(\Rng\): (rings, ring morphisms,∘)</li>
<li>\( \ML\): (types, terms, \(λg. λf. λx. g f x\) )</li>
<li>\( \Hask\): (Haskell types, functions, <code>(.)</code> )</li>
<li>...</li>
</ul>
</section>
@ -467,18 +468,17 @@ type Product = Product {getProduct :: a}
<h3>Graph</h3>
<figure class="right" style="max-width:40%" >
<img src="categories/img/mp/graph-category.png" alt="Each graph is a category"/>
<figcaption style="text-align:left"><ul><li>\(\ob{G}={X,Y,Z}\),
</li><li>\(\hom{G}=\{ε,α,β,γ,αβ,βγ,...\}\)<br/>
\(\phantom{\hom{G}}=(βγ?)?(αβγ)^*(αβ?)?\),
</li><li>\(αβ∘γ=αβγ\)
</li></ul>
</figcaption>
</figure>
<ul>
<li> \(\ob{G}\) are vertices</li>
<li> \(\hom{G}\) each path</li>
<li> ∘ is path concatenation</li>
</ul>
<ul><li>\(\ob{G}=\{X,Y,Z\}\),
</li><li>\(\hom{G}=\{ε,α,β,γ,αβ,βγ,...\}\)<br/>
\(\phantom{\hom{G}}=(β?γ)?(αβγ)^*(αβ?)?\),
</li><li>\(αβ∘γ=αβγ\)
</li></ul>
</section>
<section class="slide">
<h2>Degenerated Categories</h2>
@ -496,7 +496,7 @@ type Product = Product {getProduct :: a}
<img src="categories/img/mp/numbers.png" alt="Each number as a category"/>
</section>
<section class="slide">
<h2>Degenerated Categories</h2>
<h2>Degenerated Categories: Preorders</h2>
<h3>Preorders</h3>
<p>each preorder \((P,≤): \ob{P}={P},\hom{x,y}=\{{x≤y}\} ⇔ x≤y,f_{y,z} \circ f_{x,y} = f_{x,z} \)</p>
@ -512,6 +512,18 @@ type Product = Product {getProduct :: a}
<p><em>Only identities ; not so interesting</em></p>
</section>
<section class="slide">
<h2>Categorical Property</h2>
<p>Any property which can be expressed in term of category, objects, morphism and composition</p>
<ul><li> <em>isomorphism</em>: \(f:A→B\) s.t. ∃g:B→A, \(g∘f=id_A\) <span class="and">&amp;</span> \(f∘g=id_B\)
</li><li> <em>Initial</em>: \(Z\in\ob{C}\) s.t. \(∀Y∈\ob{C}, \#\hom{Z,Y}=1\)
</li><li> <em>Dual</em>: reverse direction of arrows of \(\C\)
</li><li> <em>Functor</em>: structure preserving mapping between categories
</li><li> ...
</li></ul>
</section>
<section class="slide">
<h2>Functor</h2>
<p> A functor is a mapping between two categories.
@ -546,7 +558,7 @@ A <em>functor</em> \(\F\) from \(\C\) to \(\D\):</p>
<section class="slide">
<h2>Endofunctors</h2>
<p>A endofunctor for \(\C\) is a functor \(F:\C→\C\).</p>
<p>An <em>endofunctor</em> for \(\C\) is a functor \(F:\C→\C\).</p>
<img src="categories/img/mp/endofunctor.png" alt="Endofunctor"/>
</section>
<section class="slide">
@ -582,9 +594,9 @@ A <em>functor</em> \(\F\) from \(\C\) to \(\D\):</p>
<img class="right" style="max-width:30%" src="categories/img/mp/hask.png" alt="Haskell Category Representation"/>
<ul><li>
\(ob(\Hask) = \) Haskell types
\(\ob{\Hask} = \) Haskell types
</li><li>
\(hom(\Hask) = \) Haskell functions
\(\hom{\Hask} = \) Haskell functions
</li><li>
∘ = <code>(.)</code> Haskell function composition
</li></ul>
@ -607,8 +619,7 @@ A <em>functor</em> \(\F\) from \(\C\) to \(\D\):</p>
<section class="slide">
<h2>Haskell Functors Example: Maybe</h2>
<pre class="haskell"><code>
data Maybe a = Just a | Nothing
<pre class="haskell"><code>data Maybe a = Just a | Nothing
instance Functor Maybe where
fmap :: (a -> b) -> (Maybe a -> Maybe b)
fmap f (Just a) = f a
@ -616,8 +627,7 @@ instance Functor Maybe where
fmap (+1) (Just 1) == 2
fmap (+1) Nothing == Nothing
fmap head (Just [1,2,3]) == Just 1
</code></pre>
fmap head (Just [1,2,3]) == Just 1</code></pre>
</section>
<section class="slide">
<h2>Haskell Functors Example: List</h2>
@ -654,12 +664,11 @@ fmap head (Cons 'c' [1,2,3])== Cons 'c' 1
</code></pre>
</section>
<section class="slide">
<h2>Functor as boxes</h2>
<h2>Haskell Functor intuition</h2>
<p>Haskell functor can be seen as boxes containing all Haskell types and functions.
Haskell types is fractal:</p>
<p>Put normal function inside Box-like types</p>
<img src="categories/img/mp/hask-endofunctor.png" alt="Haskell functor representation"/>
<img src="categories/img/mp/boxfunctor.png" alt="Haskell Functor as a box play"/>
</section>
<section class="slide">
<h2>Haskell Functor properties</h2>
@ -670,6 +679,14 @@ Haskell types is fractal:</p>
</li><li>a couple <b>(Object,Morphism)</b> of Hask.
</li></ul>
</section>
<section class="slide">
<h2>Functor as boxes</h2>
<p>Haskell functor can be seen as boxes containing all Haskell types and functions.
Haskell types is fractal:</p>
<img src="categories/img/mp/hask-endofunctor.png" alt="Haskell functor representation"/>
</section>
<!-- End slides. -->

View file

@ -1,5 +1,5 @@
<h2><span class="yellow">/.*/</span> ⇒? Category Theory</h2>
<p>Gate between different scientific fields</p>
<p>Categories package entire mathematical theories.</p>
<ul>
<li>Topology</li>
<li>Quantum Physics</li>

View file

@ -2,7 +2,7 @@
<ul><li> Time is irrelevant by default.
</li><li> Mostly static constructions like pipes.
</li><li> All pipes are round ⇒ all error at runtime
</li><li> All pipes can be plugged ⇒ all error at runtime
<ul><li> (+ ("foo" 27) 32)
</li><li> Y = λf.(λx.f (x x)) (λx.f (x x))
</li><li> Y g = g (Y g)

View file

@ -1,9 +1,9 @@
<h2>Strongly Typed Pure Programming</h2>
<ul><li>Add specific forms on pipes.
<h2>Typed Pure Programming</h2>
<ul><li>Add shapes to pipes:
<ul><li> <code class="red">4 + ["foo",27]</code> forbidden
</li><li> <code class="red">["foo",27]</code> forbidden
</li></ul>
</li><li>Pipe can contains other pipes.
</li><li>Polymorphic (elastic) shapes:
<ul><li> <code>data Maybe a = Just a | Nothing</code>
</li><li> <code>[Just 32,Nothing,Just 12] :: [Maybe Integer]</code>
</li></ul>

View file

@ -1,15 +1,16 @@
<h2>Polymorphism: <code>mappend</code></h2>
<h2>Polymorphism: <code>mappend (<>)</code></h2>
<h3><code>(<>) = `mappend`</code></h3>
<pre class="haskell"><code>"abc" <> "def" = "abcdef"
("abc","xyz") <> ("ABC","XYZ") = ("abcABC","xyzXYZ")
3 <> 4 = ERROR which law? + or *
<pre class="haskell"><code>"abc" <> "def" = "abcdef" -- String
("ab","xy") <> ("AB","XY") = ("abAB","xyXY") -- (String,String)
3 <> 4 ⇒ ERROR which law? + or * -- Int
-- Use a type to remove ambiguity
type Sum = Sum {getSum :: a} -- Just a named box
-- Monoid (N,+)
type Sum = Sum {getSum :: a}
(<>+) = getSum (Sum x <> Sum y)
3 <>+ 4 = 7
-- Monoid (N,*)
type Product = Product {getProduct :: a}
(<>*) = getProduct (Product x <> Product y)
3 <>* 4 = 12</code></pre>

View file

@ -3,10 +3,10 @@
<p>Example: <span class="red"><code>(>>=)</code></span> with <code>[a]</code> and <code>Maybe a</code></p>
<pre class="haskell"><code>data Maybe a = Just a | Nothing</code></pre>
<pre class="haskell"><code>-- Maybe : Maybe Int >>= Int -> Maybe (Int -> Int) >>= (Int -> Int) -> Maybe Int
<pre class="haskell"><code>-- Maybe Int >>= Int -> Maybe (Int -> Int) >>= (Int -> Int) -> Maybe Int
(Just 2) <span class="red">&gt;&gt;=</span> \x -> (Just (\z->z*z)) <span class="red">&gt;&gt;=</span> \f -> Just (f x) = Just 4
Nothing <span class="red">&gt;&gt;=</span> \x -> (Just (\z->z*z)) <span class="red">&gt;&gt;=</span> \f -> Just (f x) = Nothing
-- Lists: [a] : [Int] >>= Int -> [Int -> Int] >>= (Int -> Int) -> [Int]
-- [Int] >>= Int -> [Int -> Int] >>= (Int -> Int) -> [Int]
[1,2] <span class="red">&gt;&gt;=</span> \x -> [(+10),(+20)] <span class="red">&gt;&gt;=</span> \f -> [f x] = [11,21,12,22]
[] <span class="red">&gt;&gt;=</span> \x -> [(+10),(+20)] <span class="red">&gt;&gt;=</span> \f -> [f x] = []</code></pre>

View file

@ -1,6 +1,5 @@
<h2>Categories Everywhere?</h2>
<h2>Category \(\Set\)</h2>
<h3>\(\Set\)</h3>
<ul>
<li> \(\ob{\Set}\) are sets</li>
<li> \(\hom{\Set}\) are functions</li>

View file

@ -6,5 +6,6 @@
<li>\(\Grp\): (groups, group morphisms,∘)</li>
<li>\(\Rng\): (rings, ring morphisms,∘)</li>
<li>\( \ML\): (types, terms, \(λg. λf. λx. g f x\) )</li>
<li>\( \Hask\): (Haskell types, functions, <code>(.)</code> )</li>
<li>...</li>
</ul>

View file

@ -3,15 +3,14 @@
<h3>Graph</h3>
<figure class="right" style="max-width:40%" >
<img src="categories/img/mp/graph-category.png" alt="Each graph is a category"/>
<figcaption style="text-align:left"><ul><li>\(\ob{G}={X,Y,Z}\),
</li><li>\(\hom{G}=\{ε,α,β,γ,αβ,βγ,...\}\)<br/>
\(\phantom{\hom{G}}=(βγ?)?(αβγ)^*(αβ?)?\),
</li><li>\(αβ∘γ=αβγ\)
</li></ul>
</figcaption>
</figure>
<ul>
<li> \(\ob{G}\) are vertices</li>
<li> \(\hom{G}\) each path</li>
<li> ∘ is path concatenation</li>
</ul>
<ul><li>\(\ob{G}=\{X,Y,Z\}\),
</li><li>\(\hom{G}=\{ε,α,β,γ,αβ,βγ,...\}\)<br/>
\(\phantom{\hom{G}}=(β?γ)?(αβγ)^*(αβ?)?\),
</li><li>\(αβ∘γ=αβγ\)
</li></ul>

View file

@ -1,4 +1,4 @@
<h2>Degenerated Categories</h2>
<h2>Degenerated Categories: Preorders</h2>
<h3>Preorders</h3>
<p>each preorder \((P,≤): \ob{P}={P},\hom{x,y}=\{{x≤y}\} ⇔ x≤y,f_{y,z} \circ f_{x,y} = f_{x,z} \)</p>

View file

@ -0,0 +1,10 @@
<h2>Categorical Property</h2>
<p>Any property which can be expressed in term of category, objects, morphism and composition</p>
<ul><li> <em>isomorphism</em>: \(f:A→B\) s.t. ∃g:B→A, \(g∘f=id_A\) &amp; \(f∘g=id_B\)
</li><li> <em>Initial</em>: \(Z\in\ob{C}\) s.t. \(∀Y∈\ob{C}, \#\hom{Z,Y}=1\)
</li><li> <em>Dual</em>: reverse direction of arrows of \(\C\)
</li><li> <em>Functor</em>: structure preserving mapping between categories
</li><li> ...
</li></ul>

View file

@ -1,4 +1,4 @@
<h2>Endofunctors</h2>
<p>A endofunctor for \(\C\) is a functor \(F:\C→\C\).</p>
<p>An <em>endofunctor</em> for \(\C\) is a functor \(F:\C→\C\).</p>
<img src="categories/img/mp/endofunctor.png" alt="Endofunctor"/>

View file

@ -5,9 +5,9 @@
<img class="right" style="max-width:30%" src="categories/img/mp/hask.png" alt="Haskell Category Representation"/>
<ul><li>
\(ob(\Hask) = \) Haskell types
\(\ob{\Hask} = \) Haskell types
</li><li>
\(hom(\Hask) = \) Haskell functions
\(\hom{\Hask} = \) Haskell functions
</li><li>
∘ = <code>(.)</code> Haskell function composition
</li></ul>

View file

@ -1,7 +1,6 @@
<h2>Haskell Functors Example: Maybe</h2>
<pre class="haskell"><code>
data Maybe a = Just a | Nothing
<pre class="haskell"><code>data Maybe a = Just a | Nothing
instance Functor Maybe where
fmap :: (a -> b) -> (Maybe a -> Maybe b)
fmap f (Just a) = f a
@ -9,5 +8,4 @@ instance Functor Maybe where
fmap (+1) (Just 1) == 2
fmap (+1) Nothing == Nothing
fmap head (Just [1,2,3]) == Just 1
</code></pre>
fmap head (Just [1,2,3]) == Just 1</code></pre>

View file

@ -0,0 +1,5 @@
<h2>Haskell Functor intuition</h2>
<p>Put normal function inside Box-like types</p>
<img src="categories/img/mp/boxfunctor.png" alt="Haskell Functor as a box play"/>

View file

@ -1,6 +1,6 @@
pair a,b;
a:=origin;
b:=a shifted (gu,0);
b:=a shifted (1.7gu,0);
drawState(a,"a");
drawState(b,"b");
@ -14,7 +14,6 @@ drawbox(fa,"F");
drawState(fa,"a");
drawbox(fb,"F");
drawState(fb,"b");
drawEdge(fa,fb,"\mathtt{fmap} f");
pair mf,mff;
path ab,fafb;
@ -22,6 +21,23 @@ ab :=edge(a,b);
fafb:=edge(fa,fb);
mf := midpoint(ab);
mff := midpoint(fafb);
path arr;
arr = subpath (0,.5) of mf -- mff;
drawarrow arr withpen pencircle scaled 1 withcolor yellow;
path p, arr;
p := mf -- mff;
arr := subpath (0.05,0.65) of p;
drawoptions(withcolor yellow);
label.rt(btex $\mathtt{fmap}$ etex,midpoint(arr));
drawoptions(withcolor yellow withpen pencircle scaled 1 dashed evenly);
drawarrow arr;
p:=edge(a,fa);
arr := subpath (0,0.7) of p;
drawarrow arr;
label.rt(btex $F$ etex,midpoint(arr));
p:=edge(b,fb);
arr := subpath (0,0.7) of p;
drawarrow arr;
label.rt(btex $F$ etex,midpoint(arr));
drawoptions(withcolor base1 dashed evenly);
drawEdgeAngle(fa,fb,"f",-35);
nodespace:=2u+1mm;
drawoptions(withcolor base1);
drawEdge(fa,fb,"\mathtt{fmap}\ f");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -64,7 +64,7 @@ drawarrow edgeAngle(list,flist,25) dashed evenly;
drawState(list,"\mathtt{[a]}");
drawState(flist,"\mathtt{F\ [a]}");
drawoptions(withcolor orange withpen pencircle scaled 1);
drawoptions(withcolor magenta withpen pencircle scaled 1);
drawarrow edgeAngle(bool,fbool,-25) dashed evenly;
drawState(bool,"\mathtt{Bool}");
drawState(fbool,"\mathtt{F\ Bool}");

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 KiB

After

Width:  |  Height:  |  Size: 65 KiB