Category-Partial Orders Prologue and Category- partial Proof - - PowerPoint PPT Presentation

category partial orders
SMART_READER_LITE
LIVE PREVIEW

Category-Partial Orders Prologue and Category- partial Proof - - PowerPoint PPT Presentation

C-POs and Proof Principles Ralf Hinze Category-Partial Orders Prologue and Category- partial Proof Principles orders Split c-pos Monic c-pos Ralf Hinze Initial objects Computing Laboratory, University of Oxford Proof Wolfson


slide-1
SLIDE 1

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Category-Partial Orders and Proof Principles

Ralf Hinze

Computing Laboratory, University of Oxford Wolfson Building, Parks Road, Oxford, OX1 3QD, England ralf.hinze@comlab.ox.ac.uk http://www.comlab.ox.ac.uk/ralf.hinze/

June 2008

1 / 43

slide-2
SLIDE 2

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

data List = [ ] | Nat : List append :: (List, List) → List append ([ ], bs) = bs append (a : as, bs) = a : append (as, bs)

2 / 43

slide-3
SLIDE 3

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

∀x : List . P(x) P(x) ⇐ ⇒ append (x, [ ]) = x

3 / 43

slide-4
SLIDE 4

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Case P([ ]): append ([ ], [ ]) = { definition of append } [ ] Case P(a : as): append (a : as, [ ]) = { definition of append } a : append (as, [ ]) = { ex hypothesi } a : as

4 / 43

slide-5
SLIDE 5

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

append :: (List, List) → List append (as, bs) = foldr (:) bs as

5 / 43

slide-6
SLIDE 6

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

append (as, [ ]) = { definition of append } foldr (:) [ ] as = { reflection: foldr (:) [ ] = id } as

6 / 43

slide-7
SLIDE 7

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Cat + ⊆ ?

7 / 43

slide-8
SLIDE 8

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Ordering objects

A category-partial order is a pair C, ⊑ where

◮ C is a category and ◮ ⊑ is a subcategory of C that is a partial order on the

  • bjects of C.

8 / 43

slide-9
SLIDE 9

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Ordering morphisms

Let f : A → B and g : C → D, then f ⊑ g iff A ⊑ C, B ⊑ D and the following diagram commutes. A f ≻ B C g ≻ D ⇐ ⇒ ⊑B,D · f = g · ⊑A,C

9 / 43

slide-10
SLIDE 10

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Properties

◮ ⊑ on morphisms is a partial order. ◮ Let f, g : A → B, then

f ⊑ g ⇐ ⇒ f = g

10 / 43

slide-11
SLIDE 11

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Examples

◮ Set, ⊆: f ⊑ g iff f is the restriction of g to A. ◮ Functor categories: DC is a c-po if D is one.

11 / 43

slide-12
SLIDE 12

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

In Set: B A ⊆ ≻ f ≻ C ⊆ ≻ ⇐ ⇒ f = ⊆

12 / 43

slide-13
SLIDE 13

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Split transitivity

Let f : A → B, then ⊑B,C · f = ⊑A,C ⇐ ⇒ f = ⊑A,B A c-po that satisfies this property is called a split c-po.

13 / 43

slide-14
SLIDE 14

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

An equivalent formulation

Let f : A → B, then f ⊑ idC = ⇒ f = ⊑A,B A f ≻ B C idC ≻ C

14 / 43

slide-15
SLIDE 15

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

In Set the inclusion morphisms are monos. ⊆ · f1 = ⊆ · f2 ⇐ ⇒ f1 = f2

15 / 43

slide-16
SLIDE 16

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Monic c-pos

A c-po is called a monic c-po if the arrows ⊑A,B are monos: Let f1, f2 : A → B in C, then ⊑B,C · f1 = ⊑B,C · f2 ⇐ ⇒ f1 = f2

16 / 43

slide-17
SLIDE 17

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Properties

In a monic c-po the lower arrow uniquely determines the upper arrow. A f ≻ B C g ≻ D

17 / 43

slide-18
SLIDE 18

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Contracts

Let f : A → B, then f ∈ R → S :⇐ ⇒ ∃g : R → S . g ⊑ f Think of R → S as a contract with precondition R and postcondition S. But note that the postcondition can’t be weaker than B. R ≻ S A f ≻ B

18 / 43

slide-19
SLIDE 19

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

An aside: The category of contracts

◮ Identity:

R ⊑ A ⇐ ⇒ idA ∈ R → R

◮ Composition: Let f : A → B and g : B → C, then

f ∈ R → S ∧ g ∈ S → T = ⇒ g · f ∈ R → T R ≻ R A idA ≻ A R ≻ S ≻ T A f ≻ B g ≻ C

19 / 43

slide-20
SLIDE 20

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Initial objects

¡A ≻ A

20 / 43

slide-21
SLIDE 21

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Universal property

¡A = h ⇐ ⇒ h : 0 → A

21 / 43

slide-22
SLIDE 22

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Reflection

Set A = 0 and h = id0. We obtain ¡0 = id0

22 / 43

slide-23
SLIDE 23

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Fusion

Let f : B → A and set h = f · ¡B : 0 → A. We obtain ¡A = f · ¡B ⇐ = f : B → A B ¡B

  • f

≻ A ¡

A

23 / 43

slide-24
SLIDE 24

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

The mother of all proof principles

f : A → R g : B → R f · ¡A = g · ¡B A ≺ ¡

A

B ¡

B

≻ R ¡R

g f ≻

24 / 43

slide-25
SLIDE 25

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

A special case: Set B = R and g = idR. We obtain f : A → R f · ¡A = ¡R So, the proof principle implies fusion.

25 / 43

slide-26
SLIDE 26

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

A more special case: Set f = ⊑A,R. We obtain A ⊑ R ¡A ⊑ ¡R A ⊑ R ¡R ∈ 0 → A ¡A ≻ A

  • ¡R

≻ R

26 / 43

slide-27
SLIDE 27

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

An even more special case: Set R = 0. We obtain A ⊑ 0 ¡A ⊑ ¡0 A ⊑ 0 ¡0 ∈ 0 → A Recall that ¡0 = id0. So, in a split c-po this implies: A ⊑ 0 A = 0

27 / 43

slide-28
SLIDE 28

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

An even more special case: Set R = 0. We obtain A ⊑ 0 ¡A ⊑ ¡0 A ⊑ 0 ¡0 ∈ 0 → A Recall that ¡0 = id0. So, in a split c-po this implies: A ⊑ 0 A = 0

28 / 43

slide-29
SLIDE 29

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Cospans

Given: objects A and B. A cospan is an object C with two morphisms f : A → C and g : A → C. A f ≻ C ≺ g B

29 / 43

slide-30
SLIDE 30

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

The category of cospans

Cospans are the objects of the category Cospan(A, B). Morphisms in Cospan(A, B) are morphisms in the underlying category that make the following diagram commute. A f ≻ C ≺ g B A idA

  • f′

≻ C′ h

g′ B idB

  • 30 / 43
slide-31
SLIDE 31

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Coproducts

The initial object in Cospan(A, B) is the coproduct of A and B. Notation: A inl≻ A + B ≺inr B A idA

  • f

≻ C f ▽ g

g B idB

  • 31 / 43
slide-32
SLIDE 32

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Ordering cospans

C, f, g ⊑ C′, f′, g′ :⇐ ⇒ C ⊑ C′ ∧ f ⊑ f′ ∧ g ⊑ g′

32 / 43

slide-33
SLIDE 33

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Proof principle: case analysis

R ⊑ C ¡C ∈ 0 → R R ⊑ C f ∈ A → R g ∈ B → R f ▽ g ∈ A + B → R

33 / 43

slide-34
SLIDE 34

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

A special case: C = 0. R ⊑ 0 R = 0 R ⊑ A + B inl ∈ A → R inr ∈ B → R R = A + B

34 / 43

slide-35
SLIDE 35

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

F-algebras

Given: a functor F : C → C. An F-algebra is an object T with a morphism f : FT → T. FT f ≻ T

35 / 43

slide-36
SLIDE 36

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

The category of F-algebras

F-algebras are the objects of the category Alg(F). Morphisms in Alg(F) are morphisms in the underlying category that make the following diagram commute. FT f ≻ T FT ′ Fh

  • f′

≻ T ′ h

  • 36 / 43
slide-37
SLIDE 37

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Initial algebras

The initial object in Alg(F) is the least fixed point of F. Notation: F(µT) in ≻ µT FT Ff

  • f

≻ T f

  • 37 / 43
slide-38
SLIDE 38

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Ordering F-algebras

T, f ⊑ T ′, f′ :⇐ ⇒ T ⊑ T ′ ∧ f ⊑ f′

38 / 43

slide-39
SLIDE 39

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Proof principle: induction

R ⊑ C ¡C ∈ 0 → R R ⊑ C f ∈ FR → R f ∈ µF → R

39 / 43

slide-40
SLIDE 40

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

A special case: C = 0. R ⊑ 0 R = 0 R ⊑ µF in ∈ FR → R R = µF

40 / 43

slide-41
SLIDE 41

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

data Base A = 1 + Nat × A type List = µBase P = { x : List | append (x, [ ]) = x } nil ∈ 1 → P cons ∈ Nat × P → P nil ▽ cons ∈ Base P → P in ∈ Base P → P P = List

41 / 43

slide-42
SLIDE 42

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Correctness of insertion sort

Ord = { x : List | ordered x } nil ∈ 1 → Ord insert ∈ Nat × Ord → Ord nil ▽ insert ∈ Base Ord → Ord nil ▽ insert ∈ List → Ord

42 / 43

slide-43
SLIDE 43

C-POs and Proof Principles Ralf Hinze Prologue Category- partial

  • rders

Split c-pos Monic c-pos Initial

  • bjects

Proof principles Coproducts Initial algebras Examples Epilogue

Epilogue

◮ Simple and general framework for studying proof

principles.

◮ Nicely links proof principles to contracts. ◮ The development dualises: proof principles for terminal

  • bjects (products, final coalgebras).

◮ But, the requirements also dualise: epic inclusion,

cosplit transitivity which doesn’t hold in Set. {0} ∅ ⊆ ≻ ⊆ ≻ {1} {

1 } ≻

43 / 43