Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fResult/ce8751a25b279039c98aab17d7c9f73c to your computer and use it in GitHub Desktop.
Save fResult/ce8751a25b279039c98aab17d7c9f73c to your computer and use it in GitHub Desktop.
Day 05 - EP4 (Continue) Functors and natural transformations.md

Functors and natural transformations (Continue)

แบบฝึกหัดจากรอบที่แล้ว

แบบฝึกหัดใหม่

เราจะมารู้เรื่อง Category $\Bbb{Rel}$ กัน แต่ก่อนจะเข้าใจเรื่อง Relation ได้ ต้องเท้าความเรื่อง Category of Set ก่อน กำหนดให้มี Category $\Bbb{Set}$ ที่มี Object เป็น $Set$(s) ต่างๆ มี Morphism เป็น function(s) มี Identity Morphism เป็น $1_x=x$ (หรือ $f\ x=x$) ถ้ามี $1_x(a)=a$ มี Composition...

$$\begin{align}\text{let }&f:x\to y\\&g:y\to z\\g\circ f\ x&=g(f\ x)\end{align}$$

มี idl และ idr คือ...

$$\begin{align}\text{let }&f:x\\&1_x\circ f=f\tag{idl}\\ &f\circ 1_y=f\tag{idr}\end{align}$$

จากนั้นเรากำหนดให้มี Category $\Bbb{Rel}$ ซึ่งเป็น Category ของ Relation โดยที่มี Object เป็น Set(s) มี Morphism ที่เรียกว่า Relation (ไม่ใช่ function แล้วนะ)

[!info] การตั้งชื่อ Category เราสามารถตั้งชื่อตาม Object หรือว่า Morphism ก็ได้ เช่น Category $\Bbb{Set}$ ตั้งชื่อตาม Object Set(s) Category $\Bbb{Rel}$ ตั้งชื่อตาม Morphism Relation(s)

Relation & Category of Relation

Relation

$$\begin{align} \text{let A and B are sets}\\\ A=&\{a,b,c\}\\\ B=&\{1,2\}\\\ C=&\{k,l,m\} A\times B=&\{\ (a,1),(b,2),(c,3)\\\ &,\ (b,1),(b,2),(b,3)\\\ &,\ (c,1),(c,2),(c,3)\ \} \end{align}$$

^592363

เราสามารถเรียก $A\times B$ ได้ว่า Catesian Product ได้ด้วย

แล้วสรุปว่า Relation คืออะไร? Relation จะคล้ายกับ Function แต่จะแตกต่างกันตรงที่ Relation น้้น แต่ละ Domain แต่ละตัวจะ map ไปหา Co-domain กี่ตัวก็ได้ (0 ก็ได้) แต่ Function จะ map Domain ไปหา Co-domain ได้แค่ตัวเดียวเท่านั้น

Object of Relation

จาก[[#^592363|ข้างบน]] เรามี Set $A\times B$ แล้ว เราสามารถเขียน subset ของ $A\times B$ ได้ เช่น $C={(b,2),(c,1),(c,2)}$ เพราะว่าสมาชิกทุกตัวที่อยู่ใน C ก็มีอยู่ใน $A\times B$ ด้วย

Morphism of Relation

ยกตัวอย่างเรื่อง Subset ถ้า $X\subseteq Y$ แล้ว $x\in X \to y\in X$

[!info] ถ้าเรามี $X\subset Y$ หมายความว่า $X\subseteq Y\land X\neq Y$ หรือ X ต้องน้อยกว่า Y นั่นเอง $\therefore$ เวลาเราพูดถึง subset เรามักหมายถึง $\subseteq$ มากกว่าครับ

แล้วถ้าเรามี $R:A\to B$ อ่านว่า Relation R จาก A ไป B

[!info] ข้างบนเป็นการเขียนแบบ Category Theoric หากจะเขียนแบบ Set Theoric จะเขียนได้ว่า $R\subseteq A\times B$

Identity of Relation

$$\begin{align} \text{Identity }1_A&:A\to A\tag{Cat Theoric}\\\ 1_A&\subseteq A\times A\tag{Set Theoric}\\\ \text{it'll be defined as } 1_A&=\{(x,x)\ |\ x\in A\}\\\ \therefore 1_A&=\{(a,a),(b,b),(c,c)\} \end{align}$$

โดยที่ [[#^592363|Set A อยู่ข้างบน]] เราจะได้ Identity ตามภาพนี้ ซึ่ง Morphism $1_A$ มันก็คือ Function นั่นเอง (แต่จริงๆ ลูกศรมันเลี้ยวกลับมาหา object ตัวเดิมนะ) ![[Relation Identity.png]]

Composition of Relation

$$\text{let }R:A\to B,\ S:B\to C$$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment