A tale of theories and data-structures Jacques Carette, Musa - - PowerPoint PPT Presentation

a tale of theories and data structures
SMART_READER_LITE
LIVE PREVIEW

A tale of theories and data-structures Jacques Carette, Musa - - PowerPoint PPT Presentation

A tale of theories and data-structures Jacques Carette, Musa Al-hassy, Wolfram Kahl McMaster University, Hamilton June 4, 2018 Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 1 / 15 Lists and Monoids


slide-1
SLIDE 1

A tale of theories and data-structures

Jacques Carette, Musa Al-hassy, Wolfram Kahl

McMaster University, Hamilton

June 4, 2018

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 1 / 15

slide-2
SLIDE 2

Lists and Monoids

Claim

A List is a Free Monoid What does that really mean?

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 2 / 15

slide-3
SLIDE 3

Lists and Monoids

Claim

A List is a Free Monoid What does that really mean? Fancy explanation: The functor from the category Types of types and function, with List as its object mapping and map for homomorphism, to the category Monoid of monoids and monoid homomorphisms, is left adjoint to the forgetful functor (from Monoid to Types).

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 2 / 15

slide-4
SLIDE 4

Lists and Monoids

Claim

A List is a Free Monoid What does that really mean? Fancy explanation: The functor from the category Types of types and function, with List as its object mapping and map for homomorphism, to the category Monoid of monoids and monoid homomorphisms, is left adjoint to the forgetful functor (from Monoid to Types). List (equipped with constructors [], :: and functions map, ++, singleton, and foldr) is the language of monoids. In other words, List is the canonical term syntax for computing with monoids.

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 2 / 15

slide-5
SLIDE 5

Lists and Monoids

Claim

A List is a Free Monoid What does that really mean? Fancy explanation: The functor from the category Types of types and function, with List as its object mapping and map for homomorphism, to the category Monoid of monoids and monoid homomorphisms, is left adjoint to the forgetful functor (from Monoid to Types). List (equipped with constructors [], :: and functions map, ++, singleton, and foldr) is the language of monoids. In other words, List is the canonical term syntax for computing with monoids. Why on earth would we care about that? Let’s see!

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 2 / 15

slide-6
SLIDE 6

Non-categorical version

The requirements roughly translate to Monoid: Need a container C of α with a distinguished container e devoid of α’s a binary operation ∗ that puts two containers together such that e is a left/right unit for ∗. Functor: A way to apply a (α → β) function to a C α to get a C β which “plays well” with id, ◦, ≡ and ∗. Adjunction: An operation singleton embedding an α as a container C α an operation foldr (over arbitrary Monoid) such that both operations “play well” with each other. Extremely handy: Induction principle

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 3 / 15

slide-7
SLIDE 7

The plot thickens

Given an arbitrary type A : Theory Free Structure CoFree Carrier Identity A Identity A Pointed Maybe A – Unary Eventually A, N × A ? Involutive A ⊎ A A × A Magma Tree A ? Semigroup NEList A ? Monoid List A ? Left Unital Semigroup List A × N ? Right Unital Semigroup N× List A ?

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 4 / 15

slide-8
SLIDE 8

The plot thickens

Given an arbitrary type A : Theory Free Structure CoFree Carrier Identity A Identity A Pointed Maybe A – Unary Eventually A, N × A ? Involutive A ⊎ A A × A Magma Tree A ? Semigroup NEList A ? Monoid List A ? Left Unital Semigroup List A × N ? Right Unital Semigroup N× List A ? What is the Free Structure? It is “the” term language in normal form associated to the theory.

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 4 / 15

slide-9
SLIDE 9

Benefits

Benefits of the formal approach: Obvious: Dispell silly conjectures/errors Discover some neat relationships between algebraic theories and data-structures fold (aka the counit) Induction

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 5 / 15

slide-10
SLIDE 10

Benefits

Benefits of the formal approach: Obvious: Dispell silly conjectures/errors Discover some neat relationships between algebraic theories and data-structures fold (aka the counit) Induction Examples: counit for Unary, Involutive

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 5 / 15

slide-11
SLIDE 11

Extending the tale

Given an arbitrary type A : Theory Free Structure Carrier Identity A Pointed Maybe A Unary N × A Involutive A ⊎ A Magma Tree A Semigroup NEList A Monoid List A Left Unital Semigroup List A × N Right Unital Semigroup N× List A Commutative Monoid ? Group ? Abelian Group ? Idempotent Comm. Monoid ?

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 6 / 15

slide-12
SLIDE 12

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A.

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-13
SLIDE 13

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-14
SLIDE 14

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

◮ Ordered! Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-15
SLIDE 15

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

◮ Ordered!

A → N

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-16
SLIDE 16

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

◮ Ordered!

A → N

◮ No finite support! Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-17
SLIDE 17

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

◮ Ordered!

A → N

◮ No finite support!

A → N plus finite support

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-18
SLIDE 18

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

◮ Ordered!

A → N

◮ No finite support!

A → N plus finite support

◮ “Finite support” is hard to say constructively . . . Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-19
SLIDE 19

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

◮ Ordered!

A → N

◮ No finite support!

A → N plus finite support

◮ “Finite support” is hard to say constructively . . . ◮ Summing over all elements of A is even harder . . . Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-20
SLIDE 20

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

◮ Ordered!

A → N

◮ No finite support!

A → N plus finite support

◮ “Finite support” is hard to say constructively . . . ◮ Summing over all elements of A is even harder . . . ◮ Can build a decidable equiv. relation on A from A → N! Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-21
SLIDE 21

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

◮ Ordered!

A → N

◮ No finite support!

A → N plus finite support

◮ “Finite support” is hard to say constructively . . . ◮ Summing over all elements of A is even harder . . . ◮ Can build a decidable equiv. relation on A from A → N!

List A up to bag-equality (aka permutations)

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-22
SLIDE 22

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

◮ Ordered!

A → N

◮ No finite support!

A → N plus finite support

◮ “Finite support” is hard to say constructively . . . ◮ Summing over all elements of A is even harder . . . ◮ Can build a decidable equiv. relation on A from A → N!

List A up to bag-equality (aka permutations)

◮ almost works! Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-23
SLIDE 23

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

◮ Ordered!

A → N

◮ No finite support!

A → N plus finite support

◮ “Finite support” is hard to say constructively . . . ◮ Summing over all elements of A is even harder . . . ◮ Can build a decidable equiv. relation on A from A → N!

List A up to bag-equality (aka permutations)

◮ almost works! ◮ Commutative Monoid uses ≡ Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-24
SLIDE 24

Commutative Monoid and Bag

Definition

A Bag (over a type A) is an unordered finite collection of x where x : A. Implementation? Inductive type

◮ Ordered!

A → N

◮ No finite support!

A → N plus finite support

◮ “Finite support” is hard to say constructively . . . ◮ Summing over all elements of A is even harder . . . ◮ Can build a decidable equiv. relation on A from A → N!

List A up to bag-equality (aka permutations)

◮ almost works! ◮ Commutative Monoid uses ≡

Theorem (Within Martin-L¨

  • f Type Theory)

There’s no free functor from Types to Commutative Monoids using ≡.

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 7 / 15

slide-25
SLIDE 25

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-26
SLIDE 26

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Definition

A Bag over a setoid A is an unordered collection of x where x : Carrier A.

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-27
SLIDE 27

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Definition

A Bag over a setoid A is an unordered collection of x where x : Carrier A. Implementation attempts:

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-28
SLIDE 28

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Definition

A Bag over a setoid A is an unordered collection of x where x : Carrier A. Implementation attempts: Nils Anders Danielsson’s Bag Equivalence via a Proof-Relevant Membership Relation

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-29
SLIDE 29

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Definition

A Bag over a setoid A is an unordered collection of x where x : Carrier A. Implementation attempts: Nils Anders Danielsson’s Bag Equivalence via a Proof-Relevant Membership Relation

◮ Too many parts over ≡ Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-30
SLIDE 30

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Definition

A Bag over a setoid A is an unordered collection of x where x : Carrier A. Implementation attempts: Nils Anders Danielsson’s Bag Equivalence via a Proof-Relevant Membership Relation

◮ Too many parts over ≡

Erik Palmgren’s Setoid Families

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-31
SLIDE 31

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Definition

A Bag over a setoid A is an unordered collection of x where x : Carrier A. Implementation attempts: Nils Anders Danielsson’s Bag Equivalence via a Proof-Relevant Membership Relation

◮ Too many parts over ≡

Erik Palmgren’s Setoid Families

◮ Extremely complex, forget the actual dead end. Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-32
SLIDE 32

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Definition

A Bag over a setoid A is an unordered collection of x where x : Carrier A. Implementation attempts: Nils Anders Danielsson’s Bag Equivalence via a Proof-Relevant Membership Relation

◮ Too many parts over ≡

Erik Palmgren’s Setoid Families

◮ Extremely complex, forget the actual dead end.

Mimick above with our own Proof-Relevant ∈ over Setoid

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-33
SLIDE 33

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Definition

A Bag over a setoid A is an unordered collection of x where x : Carrier A. Implementation attempts: Nils Anders Danielsson’s Bag Equivalence via a Proof-Relevant Membership Relation

◮ Too many parts over ≡

Erik Palmgren’s Setoid Families

◮ Extremely complex, forget the actual dead end.

Mimick above with our own Proof-Relevant ∈ over Setoid

◮ Proof that fold well-behaved very hard. Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-34
SLIDE 34

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Definition

A Bag over a setoid A is an unordered collection of x where x : Carrier A. Implementation attempts: Nils Anders Danielsson’s Bag Equivalence via a Proof-Relevant Membership Relation

◮ Too many parts over ≡

Erik Palmgren’s Setoid Families

◮ Extremely complex, forget the actual dead end.

Mimick above with our own Proof-Relevant ∈ over Setoid

◮ Proof that fold well-behaved very hard.

Bag-equality in new version of Agda!

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-35
SLIDE 35

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Definition

A Bag over a setoid A is an unordered collection of x where x : Carrier A. Implementation attempts: Nils Anders Danielsson’s Bag Equivalence via a Proof-Relevant Membership Relation

◮ Too many parts over ≡

Erik Palmgren’s Setoid Families

◮ Extremely complex, forget the actual dead end.

Mimick above with our own Proof-Relevant ∈ over Setoid

◮ Proof that fold well-behaved very hard.

Bag-equality in new version of Agda!

◮ Still assumes ≡. Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-36
SLIDE 36

Change the question!

Definition

A DBag over a type A with dec. = is an unordered collection of x where x : A.

Definition

A Bag over a setoid A is an unordered collection of x where x : Carrier A. Implementation attempts: Nils Anders Danielsson’s Bag Equivalence via a Proof-Relevant Membership Relation

◮ Too many parts over ≡

Erik Palmgren’s Setoid Families

◮ Extremely complex, forget the actual dead end.

Mimick above with our own Proof-Relevant ∈ over Setoid

◮ Proof that fold well-behaved very hard.

Bag-equality in new version of Agda!

◮ Still assumes ≡.

Experimental library with permutations over tables ⇒ proof that fold is well-behaved Success!

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 8 / 15

slide-37
SLIDE 37

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-38
SLIDE 38

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda Internalize length of “list” into a record Seq —subst is evil! Table of A is Fin N → A (finite support)

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-39
SLIDE 39

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda Internalize length of “list” into a record Seq —subst is evil! Table of A is Fin N → A (finite support) Equivalence of sequences S and T is

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-40
SLIDE 40

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda Internalize length of “list” into a record Seq —subst is evil! Table of A is Fin N → A (finite support) Equivalence of sequences S and T is

◮ A permutation between |S| and |T|, i.e. Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-41
SLIDE 41

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda Internalize length of “list” into a record Seq —subst is evil! Table of A is Fin N → A (finite support) Equivalence of sequences S and T is

◮ A permutation between |S| and |T|, i.e. ◮ An equivalence between Fin |S| and Fin |T| Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-42
SLIDE 42

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda Internalize length of “list” into a record Seq —subst is evil! Table of A is Fin N → A (finite support) Equivalence of sequences S and T is

◮ A permutation between |S| and |T|, i.e. ◮ An equivalence between Fin |S| and Fin |T| ◮ A proof that permuting the elements of T gives a pointwise

Setoid-equivalence to those of S.

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-43
SLIDE 43

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda Internalize length of “list” into a record Seq —subst is evil! Table of A is Fin N → A (finite support) Equivalence of sequences S and T is

◮ A permutation between |S| and |T|, i.e. ◮ An equivalence between Fin |S| and Fin |T| ◮ A proof that permuting the elements of T gives a pointwise

Setoid-equivalence to those of S.

Use previous infrastructure built to move between proofs on permutations and proofs on types (work on Π languages w/ Amr Sabry)

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-44
SLIDE 44

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda Internalize length of “list” into a record Seq —subst is evil! Table of A is Fin N → A (finite support) Equivalence of sequences S and T is

◮ A permutation between |S| and |T|, i.e. ◮ An equivalence between Fin |S| and Fin |T| ◮ A proof that permuting the elements of T gives a pointwise

Setoid-equivalence to those of S.

Use previous infrastructure built to move between proofs on permutations and proofs on types (work on Π languages w/ Amr Sabry) Create an abstract interface for Multiset, MultisetHom and “functorial” MultisetHom

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-45
SLIDE 45

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda Internalize length of “list” into a record Seq —subst is evil! Table of A is Fin N → A (finite support) Equivalence of sequences S and T is

◮ A permutation between |S| and |T|, i.e. ◮ An equivalence between Fin |S| and Fin |T| ◮ A proof that permuting the elements of T gives a pointwise

Setoid-equivalence to those of S.

Use previous infrastructure built to move between proofs on permutations and proofs on types (work on Π languages w/ Amr Sabry) Create an abstract interface for Multiset, MultisetHom and “functorial” MultisetHom Satisfies interface ⇒ left adjoint to Commutative Monoid

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-46
SLIDE 46

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda Internalize length of “list” into a record Seq —subst is evil! Table of A is Fin N → A (finite support) Equivalence of sequences S and T is

◮ A permutation between |S| and |T|, i.e. ◮ An equivalence between Fin |S| and Fin |T| ◮ A proof that permuting the elements of T gives a pointwise

Setoid-equivalence to those of S.

Use previous infrastructure built to move between proofs on permutations and proofs on types (work on Π languages w/ Amr Sabry) Create an abstract interface for Multiset, MultisetHom and “functorial” MultisetHom Satisfies interface ⇒ left adjoint to Commutative Monoid Bag satisfies the interface

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-47
SLIDE 47

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda Internalize length of “list” into a record Seq —subst is evil! Table of A is Fin N → A (finite support) Equivalence of sequences S and T is

◮ A permutation between |S| and |T|, i.e. ◮ An equivalence between Fin |S| and Fin |T| ◮ A proof that permuting the elements of T gives a pointwise

Setoid-equivalence to those of S.

Use previous infrastructure built to move between proofs on permutations and proofs on types (work on Π languages w/ Amr Sabry) Create an abstract interface for Multiset, MultisetHom and “functorial” MultisetHom Satisfies interface ⇒ left adjoint to Commutative Monoid Bag satisfies the interface Use abstract in key places to prevent normalization in proof goals

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-48
SLIDE 48

Key ingredients of Bag

Distilling the insights from ∼1000 lines of Agda Internalize length of “list” into a record Seq —subst is evil! Table of A is Fin N → A (finite support) Equivalence of sequences S and T is

◮ A permutation between |S| and |T|, i.e. ◮ An equivalence between Fin |S| and Fin |T| ◮ A proof that permuting the elements of T gives a pointwise

Setoid-equivalence to those of S.

Use previous infrastructure built to move between proofs on permutations and proofs on types (work on Π languages w/ Amr Sabry) Create an abstract interface for Multiset, MultisetHom and “functorial” MultisetHom Satisfies interface ⇒ left adjoint to Commutative Monoid Bag satisfies the interface Use abstract in key places to prevent normalization in proof goals Never use subst —even when building the identity permutation

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 9 / 15

slide-49
SLIDE 49

Extending the tale, take 2

Given an arbitrary type A : Theory Structure Over Equality Carrier Identity A Type ≡ Pointed Maybe A Type ≡ Unary N × A Type ≡ Involutive A ⊎ A Type ≡ Magma Tree A Type ≡ Semigroup NEList A Type ≡ Monoid List A Type ≡ Left Unital Semigroup List A × N Type ≡ Right Unital Semigroup N × List A Type ≡ Commutative Monoid Bag Setoid proof-relevant permutations Group ? ? ? Abelian Group Hybrid Sets Setoid proof-relevant permutations

  • Idemp. Comm. Monoid

Set Setoid logical equivalence

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 10 / 15

slide-50
SLIDE 50

What’s the deal with those axioms?

Works easily:

◮ Associativity: ∀x, y, z. x ∗ (y ∗ z) ≡ (x ∗ y) ∗ z; ◮ Left-unit: ∀x. e ∗ x ≡ x; ◮ Right-unit: ∀x. x ∗ e ≡ x ◮ Involutive: ∀x. inv(invx) ≡ x

Hard:

◮ Commutativity: ∀x, y. x ∗ y ≡ y ∗ x

Very Hard:

◮ Idempotence: ∀x. x ∗ x ≡ x Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 11 / 15

slide-51
SLIDE 51

What’s the deal with those axioms?

Works easily:

◮ Associativity: ∀x, y, z. x ∗ (y ∗ z) ≡ (x ∗ y) ∗ z; ◮ Left-unit: ∀x. e ∗ x ≡ x; ◮ Right-unit: ∀x. x ∗ e ≡ x ◮ Involutive: ∀x. inv(invx) ≡ x

Hard:

◮ Commutativity: ∀x, y. x ∗ y ≡ y ∗ x

Very Hard:

◮ Idempotence: ∀x. x ∗ x ≡ x

Found the secret ingredient in Algebraic Theories in Monoidal Categories by

  • L. Mauri: structural context rules (weakening, exchange, contraction).

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 11 / 15

slide-52
SLIDE 52

More tale to tell

⊥, ⊤, B, N, Z show up as initial objects. Bivariate (but × and ⊎ are adjoint to diagonal, not forgetful functor) Indexed sets of operations

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 12 / 15

slide-53
SLIDE 53

Potential data-structures

left-zero monoid, pointed unary, idempotent unary, commutative magma, pointed magma, quasigroup, loop, semilattice, medial magma, left semimedial magma, left distributive magma, idempotent magma, zeropotent magma, left unary magma, Steiner magma, null semigroup, BCI algebra, BCK algebra, squag, sloop, Moufang quasigroup, loop, left shelf, shelf, rack, spindle, quandle, Kei, involutive semigroup, band, rectangular band, hemigroup, pseudo inverse algebra, ringoid, left near semiring, near semiring, semifield, semiring, semirng, pre-dioid, dioid, star semiring, idempotent dioid, ring, commutative ring, idempotent semiring, Stone algebra, Kleene lattice, Kleene algebra, Heyting algebra, Goedel algebra, ortho lattice, directoid, semiheap, idempotent semiheap, heap, meadow, wheel.

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 13 / 15

slide-54
SLIDE 54

Structures looking for a home

Difference list, stack, queue, finite map, rose tree, digraph, multigraph, partitions, oriented cycles, colorings, tri-colorings, hedges, derangements, ballots, commutative parenthesizations, linear order, permutations, even permutations, chains, oriented sets, even sets, octopus, vertebrae.

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 14 / 15

slide-55
SLIDE 55

Math and CS

Given an arbitrary type A : Theory Structure Over Equality Carrier Identity A Type ≡ Pointed Maybe A Type ≡ Unary N × A Type ≡ Involutive A ⊎ A Type ≡ Magma Tree A Type ≡ Semigroup NEList A Type ≡ Monoid List A Type ≡ Left Unital Semigroup List A × N Type ≡ Right Unital Semigroup N × List A Type ≡ Commutative Monoid Bag Setoid proof-relevant permutations Group ? ? ? Abelian Group Hybrid Sets Setoid proof-relevant permutations

  • Idemp. Comm. Monoid

Set Setoid logical equivalence https://github.com/JacquesCarette/TheoriesAndDataStructures

Carette, Al-hassy, Kahl (McMaster) A tale of theories and data-structures June 4, 2018 15 / 15