A Framework for Constructive Category Theory in Computer Algebra
Total Page:16
File Type:pdf, Size:1020Kb
A framework for constructive category theory in computer algebra Sebastian Posur, Kamal Saleh, Fabian Zickgraf University of Siegen July 15, 2019 Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 1 / 65 Part I Constructive category theory Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 2 / 65 Addition of two numbers: Abstraction of language Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Abstraction of language Addition of two numbers: Data type: int Data type: float Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Abstraction of language Addition of two numbers: Assembly Data type: int Data type: float Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Abstraction of language Addition of two numbers: Assembly Data type: int Data type: float addi: movl %edi, -4(%rsp) movl %esi, -8(%rsp) movl -4(%rsp), %esi addl -8(%rsp), %esi movl %esi, %eax ret Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Abstraction of language Addition of two numbers: Assembly Data type: int Data type: float addi: addf: movl %edi, -4(%rsp) movss %xmm0, -4(%rsp) movl %esi, -8(%rsp) movss %xmm1, -8(%rsp) movl -4(%rsp), %esi movss -4(%rsp), %xmm0 addl -8(%rsp), %esi addss -8(%rsp), %xmm0 movl %esi, %eax ret ret Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Abstraction of language Addition of two numbers: C Data type: int Data type: float Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Abstraction of language Addition of two numbers: C Data type: int Data type: float int addi( int a, int b ) { return a + b; } Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Abstraction of language Addition of two numbers: C Data type: int Data type: float int addi( int a, float addf( float a, int b ) float b ) { { return a + b; return a + b; } } Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Abstraction of language Addition of two numbers: GAP or Julia Data type: int Data type: float Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Abstraction of language Addition of two numbers: GAP or Julia Data type: int Data type: float function( a, b ) return a + b; end; Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Abstraction of language Addition of two numbers: GAP or Julia Data type: int Data type: float function( a, b ) function( a, b ) return a + b; return a + b; end; end; Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 High language leads to generic code! Abstraction of language Addition of two numbers: GAP or Julia Data type: int, float function( a, b ) return a + b; end; Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Abstraction of language Addition of two numbers: GAP or Julia Data type: int, float function( a, b ) return a + b; end; High language leads to generic code! Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 3 / 65 Vector spaces Ideals of Z hv1; v2i ; hw1; w2i ≤ V : hxi, hyi ≤ Z : Solution of Euclidean algorithm: x1v1 + x2v2 hlcm (x; y)i =y1w1 + y2w2 Generic algorithm for both cases? Category theory! Abstraction of language Computing the intersection of two subobjects Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 4 / 65 Ideals of Z hxi, hyi ≤ Z : Solution of Euclidean algorithm: x1v1 + x2v2 hlcm (x; y)i =y1w1 + y2w2 Generic algorithm for both cases? Category theory! Abstraction of language Computing the intersection of two subobjects Vector spaces hv1; v2i ; hw1; w2i ≤ V : Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 4 / 65 Ideals of Z hxi, hyi ≤ Z : Euclidean algorithm: hlcm (x; y)i Generic algorithm for both cases? Category theory! Abstraction of language Computing the intersection of two subobjects Vector spaces hv1; v2i ; hw1; w2i ≤ V : Solution of x1v1 + x2v2 =y1w1 + y2w2 Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 4 / 65 hxi, hyi ≤ Z : Euclidean algorithm: hlcm (x; y)i Generic algorithm for both cases? Category theory! Abstraction of language Computing the intersection of two subobjects Vector spaces Ideals of Z hv1; v2i ; hw1; w2i ≤ V : Solution of x1v1 + x2v2 =y1w1 + y2w2 Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 4 / 65 Euclidean algorithm: hlcm (x; y)i Generic algorithm for both cases? Category theory! Abstraction of language Computing the intersection of two subobjects Vector spaces Ideals of Z hv1; v2i ; hw1; w2i ≤ V : hxi, hyi ≤ Z : Solution of x1v1 + x2v2 =y1w1 + y2w2 Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 4 / 65 Generic algorithm for both cases? Category theory! Abstraction of language Computing the intersection of two subobjects Vector spaces Ideals of Z hv1; v2i ; hw1; w2i ≤ V : hxi, hyi ≤ Z : Solution of Euclidean algorithm: x1v1 + x2v2 hlcm (x; y)i =y1w1 + y2w2 Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 4 / 65 Category theory! Abstraction of language Computing the intersection of two subobjects Vector spaces Ideals of Z hv1; v2i ; hw1; w2i ≤ V : hxi, hyi ≤ Z : Solution of Euclidean algorithm: x1v1 + x2v2 hlcm (x; y)i =y1w1 + y2w2 Generic algorithm for both cases? Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 4 / 65 Abstraction of language Computing the intersection of two subobjects Vector spaces Ideals of Z hv1; v2i ; hw1; w2i ≤ V : hxi, hyi ≤ Z : Solution of Euclidean algorithm: x1v1 + x2v2 hlcm (x; y)i =y1w1 + y2w2 Generic algorithm for both cases? Category theory! Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 4 / 65 abstracts mathematical structures, defines a language to formulate theorems and algorithms for different structures at the same time. CAP - Categories, Algorithms, Programming CAP implements a categorical programming language. Category theory as programming language Category theory Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 5 / 65 defines a language to formulate theorems and algorithms for different structures at the same time. CAP - Categories, Algorithms, Programming CAP implements a categorical programming language. Category theory as programming language Category theory abstracts mathematical structures, Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 5 / 65 CAP - Categories, Algorithms, Programming CAP implements a categorical programming language. Category theory as programming language Category theory abstracts mathematical structures, defines a language to formulate theorems and algorithms for different structures at the same time. Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 5 / 65 CAP implements a categorical programming language. Category theory as programming language Category theory abstracts mathematical structures, defines a language to formulate theorems and algorithms for different structures at the same time. CAP - Categories, Algorithms, Programming Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 5 / 65 Category theory as programming language Category theory abstracts mathematical structures, defines a language to formulate theorems and algorithms for different structures at the same time. CAP - Categories, Algorithms, Programming CAP implements a categorical programming language. Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 5 / 65 (assoc.) HomC(A; B) · : HomC(A; B) × HomC(B; C) ! HomC(A; C) Neutral elements: idA 2 HomC(A; A) A B C ObjC Categories Definition A category C contains the following data: Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 6 / 65 (assoc.) HomC(A; B) · : HomC(A; B) × HomC(B; C) ! HomC(A; C) Neutral elements: idA 2 HomC(A; A) Categories Definition A category C contains the following data: ObjC A B C Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 6 / 65 (assoc.) · : HomC(A; B) × HomC(B; C) ! HomC(A; C) Neutral elements: idA 2 HomC(A; A) Categories Definition A category C contains the following data: ObjC HomC(A; B) A B C Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 6 / 65 (assoc.) · : HomC(A; B) × HomC(B; C) ! HomC(A; C) Neutral elements: idA 2 HomC(A; A) Categories Definition A category C contains the following data: ObjC HomC(A; B) A B C Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 6 / 65 (assoc.) · : HomC(A; B) × HomC(B; C) ! HomC(A; C) Neutral elements: idA 2 HomC(A; A) Categories Definition A category C contains the following data: ObjC HomC(A; B) A B C Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 6 / 65 Neutral elements: idA 2 HomC(A; A) Categories Definition A category C contains the following data: ObjC HomC(A; B) · : HomC(A; B) × HomC(B; C) ! HomC(A; C) (assoc.) A B C Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 6 / 65 Neutral elements: idA 2 HomC(A; A) Categories Definition A category C contains the following data: ObjC HomC(A; B) · : HomC(A; B) × HomC(B; C) ! HomC(A; C) (assoc.) A B C Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 6 / 65 Categories Definition A category C contains the following data: ObjC HomC(A; B) · : HomC(A; B) × HomC(B; C) ! HomC(A; C) (assoc.) Neutral elements: idA 2 HomC(A; A) A B C Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 6 / 65 Categories Definition A category C contains the following data: ObjC HomC(A; B) · : HomC(A; B) × HomC(B; C) ! HomC(A; C) (assoc.) Neutral elements: idA 2 HomC(A; A) A B C Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 6 / 65 Categories Definition A category C contains the following data: ObjC HomC(A; B) · : HomC(A; B) × HomC(B; C) ! HomC(A; C) (assoc.) Neutral elements: idA 2 HomC(A; A) A B C Posur, Saleh, Zickgraf (Siegen) CAP July 15, 2019 6 / 65 ' (computerfriendly model) We denote this category by Rowsk . Example: k-vec Obj := finite dimensional k-vector spaces Hom(V ; W ) := k-linear maps V ! W Example: matrices Obj := N0 Hom(n; m) := k n×m Finite dimensional vector spaces Let k be a field (e.g., k = Q).