#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Options

# Programming with Categories - Lecture 8 Discussion

edited February 5

Programming with Categories - Lecture 8 - Blueprints and Models

These are my notes on the first part of Bartosz' lecture.

A very simple blueprint for a vertebrate animal, consists of a body connected to a head at the top and four limbs along the sides, two limbs per side. Bartosz draws this as a stick figure.

  O
|
--|--
|
--|--
|


There can be many models of this blueprint category. Human and Dog are two such models. The human stick figure is the stereotype of what any kindergarten kid can do - it has the same number of lines as the blueprint (6).

 O
/|\
/ \


And here's my version of the dog. See the video around 2:30 to see Bartosz' much better drawing of a dog.

O-----
/\ /\


How are these models related to each other and to the blueprint? Each is a separate category.

Below are the beginnings of my program that implements this in Haskell. I am just starting to learn Haskell so this is probably very naive.

Or you can visit https://repl.it/languages/haskell, paste the following code into the editor, and click run.

main = do
-- specify the objects in each of the three categories
let blueprint = [0..5]
let human = ["head", "body", "leftarm", "rightarm", "leftleg", "rightleg"]
let dog = ["head", "body", "frontleftpaw", "frontrightpaw", "backleftpaw", "backrightpaw"]

-- specify the morphisms from blueprint to each of the two models, using lists of pairs
let bh = zip blueprint human
let bd = zip blueprint dog

-- print out the lists of pairs (the morphisms)
print bh
print bd


The result is:

[(0,"head"),(1,"body"),(2,"leftarm"),(3,"rightarm"),(4,"leftleg"),(5,"rightleg")]


I will continue learning Haskell, and how it relates to Category Theory, while further exploring this example from the lecture, and invite others to do the same with this and other examples. Please feel free to make suggestions.

• Options
1.

Another way to capture Bartosz' presentation of his Blueprints and Models example, is to recreate it using Graphviz. Here's an initial version of this. Discussion and suggestions would be welcome.

digraph X { rankdir = LR
// there are three categories in the example that Bartosz presents
// each category has objects and morphisms that belong to that category
//edge {color = blue} NO
subgraph clusterB {label = Blueprint; color = indigo; style = dashed
0 1 2 3 4 5
0->1 [color = blue]
}
subgraph clusterH {label = Human; color = indigo
hhead hbody lefthand righthand leftfoot rightfoot neck shoulder
}
subgraph clusterD {label = Dog; color = indigo
dhead dbody frontleftpaw frontrightpaw backleftpaw backrightpaw
}

// functors between categories  object -> object
0->hhead [color = orange] [label = F]
0->dhead [color = orange] [label = G]
// but Graphviz, which is based on a concept of Graph, is probably unable to completely represent functors, which include mappings between morphisms  m -> m

// natural transformation, from model to model

Comment Source:Another way to capture Bartosz' presentation of his **Blueprints and Models** example, is to recreate it using Graphviz. Here's an initial version of this. Discussion and suggestions would be welcome. ~~~ digraph X { rankdir = LR // there are three categories in the example that Bartosz presents // each category has objects and morphisms that belong to that category //edge {color = blue} NO subgraph clusterB {label = Blueprint; color = indigo; style = dashed 0 1 2 3 4 5 0->1 [color = blue] } subgraph clusterH {label = Human; color = indigo hhead hbody lefthand righthand leftfoot rightfoot neck shoulder hhead->hbody [color = blue] hhead->neck->shoulder [color = blue] } subgraph clusterD {label = Dog; color = indigo dhead dbody frontleftpaw frontrightpaw backleftpaw backrightpaw dhead->dbody [color = blue] } // functors between categories object -> object 0->hhead [color = orange] [label = F] 0->dhead [color = orange] [label = G] // but Graphviz, which is based on a concept of Graph, is probably unable to completely represent functors, which include mappings between morphisms m -> m // natural transformation, from model to model hhead->dhead [color = red] } ~~~ And here is the corresponding SVG image. ![Figure B](https://gist.githubusercontent.com/kenwebb/6d048138ce60e42a800482b4c55c017c/raw/c83658698c275c4e8e668a87358c34f95251d0a5/BlueprintAndModels.svg?sanitize=true "Figure B")