A categorical semantics for inductive-inductive definitions Thorsten - - PowerPoint PPT Presentation

a categorical semantics for inductive inductive
SMART_READER_LITE
LIVE PREVIEW

A categorical semantics for inductive-inductive definitions Thorsten - - PowerPoint PPT Presentation

A categorical semantics for inductive-inductive definitions Thorsten Altenkirch 2 Peter Morris 2 Fredrik Nordvall Forsberg 1 Anton Setzer 1 1 University of Nottingham, UK 2 Swansea University, UK CALCO 30/08/2011, Winchester Plan of the talk 1


slide-1
SLIDE 1

A categorical semantics for inductive-inductive definitions

Thorsten Altenkirch2 Peter Morris2 Fredrik Nordvall Forsberg1 Anton Setzer1

1 University of Nottingham, UK 2 Swansea University, UK

CALCO 30/08/2011, Winchester

slide-2
SLIDE 2

Plan of the talk

1 What are inductive-inductive definitions? 2 How can they be described, categorically? 3 Exploiting initiality. 1

slide-3
SLIDE 3

Notation

Work in the framework of Martin-L¨

  • f type theory.

Unit type 1, disjoint union A + B. Dependent function spaces (x : A) → B(x).

◮ Elements are functions f such that f (a) : B(a) whenever a : A.

Dependent pairs Σx :A.B(x).

◮ Elements are pairs a, b where a : A, b : B(a). ◮ Projections π0 : Σx :A.B(x) → A and π1 : (y : ΣA B) → B(π0(y)).

Set the type of (small) types / propositions.

2

slide-4
SLIDE 4

Inductive-inductive definitions

slide-5
SLIDE 5

What is an inductive-inductive definition?

Induction-induction is a principle for defining datatypes A : Set, B : A → Set. Both A and B are defined inductively, i.e. “built up from below”.

3

slide-6
SLIDE 6

What is an inductive-inductive definition?

Induction-induction is a principle for defining datatypes A : Set, B : A → Set. Both A and B are defined inductively, i.e. “built up from below”. A and B are defined simultaneously, so the constructors for A can refer to B and vice versa. In addition, the constructors for B can even refer to the constructors for A.

3

slide-7
SLIDE 7

But isn’t that. . . ?

An inductive-inductive definition is in general not: An ordinary inductive definition

◮ Because we define A : Set and B : A → Set simultaneously. 4

slide-8
SLIDE 8

But isn’t that. . . ?

An inductive-inductive definition is in general not: An ordinary inductive definition

◮ Because we define A : Set and B : A → Set simultaneously.

An ordinary mutual inductive definition

◮ Because B : A → Set is indexed by A. 4

slide-9
SLIDE 9

But isn’t that. . . ?

An inductive-inductive definition is in general not: An ordinary inductive definition

◮ Because we define A : Set and B : A → Set simultaneously.

An ordinary mutual inductive definition

◮ Because B : A → Set is indexed by A.

An indexed inductive definition

◮ Because the index set A : Set is defined along with B : A → Set, and

not fixed beforehand.

◮ However, conjecture that it can be reduced to IID. 4

slide-10
SLIDE 10

But isn’t that. . . ?

An inductive-inductive definition is in general not: An ordinary inductive definition

◮ Because we define A : Set and B : A → Set simultaneously.

An ordinary mutual inductive definition

◮ Because B : A → Set is indexed by A.

An indexed inductive definition

◮ Because the index set A : Set is defined along with B : A → Set, and

not fixed beforehand.

◮ However, conjecture that it can be reduced to IID.

An inductive-recursive definition

◮ Because B : A → Set is defined inductively, not recursively. 4

slide-11
SLIDE 11

Induction-recursion vs induction-induction

Inductive-recursive definition: Need to define B(c( x)) completely when introducing c( x).

◮ For each constructor c of A, must define B(c(

x)) = . . . B . . ..

◮ But can refer to B(x) both positively and negatively in type of c. ◮ Example: B(σ(s, t)) = Σ x :B(s) . B(t(x)).

Inductive-inductive definition: Elements of B(x) can be defined any time after x is introduced.

◮ So might depend on elements introduced after x. ◮ We can refer to B(x) only positively. ◮ Example: B : A → Set where d : (x : A) → (y : B(x)) → B(c(x, y)). 5

slide-12
SLIDE 12

An example

Instances of induction-induction have been used implicitly by Dybjer (Internal type theory, 1996), Danielsson (A formalisation of a dependently typed language as an inductive-recursive

family, 2007), and

Chapman (Type theory should eat itself, 2009) to model dependent type theory inside itself.

6

slide-13
SLIDE 13

Type theory inside type theory

Context : Set Type : Context → Set Term : (Γ : Context) → Type(Γ) → Set . . . Substitutions, . . . . . .

7

defined inductively

slide-14
SLIDE 14

The crucial point

The empty context ε is a well-formed context. If τ is a well-formed type in context Γ, then Γ, x : τ is a well-formed context. ε : Context Γ : Context τ : Type(Γ) Γ ⊲ τ : Context

8

slide-15
SLIDE 15

Constructor for Type referring to constructor for Context

Γ context Γ ⊢ σ type Γ, x : σ ⊢ τ(x) type Γ ⊢ Π x :σ . τ(x) type

9

slide-16
SLIDE 16

Constructor for Type referring to constructor for Context

Γ context Γ ⊢ σ type Γ, x : σ ⊢ τ(x) type Γ ⊢ Π x :σ . τ(x) type Γ : Context

9

slide-17
SLIDE 17

Constructor for Type referring to constructor for Context

Γ context Γ ⊢ σ type Γ, x : σ ⊢ τ(x) type Γ ⊢ Π x :σ . τ(x) type Γ : Context σ : Type(Γ)

9

slide-18
SLIDE 18

Constructor for Type referring to constructor for Context

Γ context Γ ⊢ σ type Γ, x : σ ⊢ τ(x) type Γ ⊢ Π x :σ . τ(x) type Γ : Context σ : Type(Γ) τ : Type(Γ ⊲ σ)

9

slide-19
SLIDE 19

Constructor for Type referring to constructor for Context

Γ context Γ ⊢ σ type Γ, x : σ ⊢ τ(x) type Γ ⊢ Π x :σ . τ(x) type Γ : Context σ : Type(Γ) τ : Type(Γ ⊲ σ)

9

slide-20
SLIDE 20

Constructor for Type referring to constructor for Context

Γ context Γ ⊢ σ type Γ, x : σ ⊢ τ(x) type Γ ⊢ Π x :σ . τ(x) type Γ : Context σ : Type(Γ) τ : Type(Γ ⊲ σ) Π(σ, τ) : Type(Γ)

9

slide-21
SLIDE 21

But is there a theory?

Previous work: axiomatisation. Now: initial algebra like semantics – less ugly details.

10

slide-22
SLIDE 22

Describing inductive-inductive datatypes

slide-23
SLIDE 23

Initial algebra semantics

Let F : C → C be a functor. Recall that an F-algebra is a pair (X, f ) where X ∈ C and f : F(X) → X. A morphism α : (X, f ) → (Y , g) between F-algebras is a morphism α : X → Y such that F(X)

f

  • F(α)
  • X

α

  • F(Y )

g

Y

Model inductive data types as initial F-algebra for suitable endofunctor F. (F “represents” the data type by describing its constructors.)

Example: F(X) = 1 + (X × X), [empty, node] : F(BTree) → BTree.

11

slide-24
SLIDE 24

Induction-induction as initial algebras?

In general, an inductive-inductive definition consists of

◮ A : Set, ◮ B : A → Set, ◮ a constructor inA : ArgA(A, B) → A for A, ◮ a constructor inB : (x : ArgA(A, B)) → ArgB(A, B, inA) → B(inA(x))

for B

for some functors ArgA, ArgB (but from and to where?).

12

slide-25
SLIDE 25

Induction-induction as initial algebras?

In general, an inductive-inductive definition consists of

◮ A : Set, ◮ B : A → Set, ◮ a constructor inA : ArgA(A, B) → A for A, ◮ a constructor inB : (x : ArgA(A, B)) → ArgB(A, B, inA) → B(inA(x))

for B

for some functors ArgA, ArgB (but from and to where?). First thought: an inductive-inductive def. is a family (A, B) of sets, so they should be represented by functors F = (F0, F1) : Fam(Set) → Fam(Set).

12

slide-26
SLIDE 26

Induction-induction as initial algebras?

In general, an inductive-inductive definition consists of

◮ A : Set, ◮ B : A → Set, ◮ a constructor inA : ArgA(A, B) → A for A, ◮ a constructor inB : (x : ArgA(A, B)) → ArgB(A, B, inA) → B(inA(x))

for B

for some functors ArgA, ArgB (but from and to where?). First thought: an inductive-inductive def. is a family (A, B) of sets, so they should be represented by functors F = (F0, F1) : Fam(Set) → Fam(Set). Here, Fam(Set) category with objects (A, B) where A : Set, B : A → Set. Morphism (A, B) to (A′, B′) is (f , g) where f : A → A′, g : (x : A) → B(x) → B′(f (x)).

12

slide-27
SLIDE 27

Induction-induction as initial algebras?

In general, an inductive-inductive definition consists of

◮ A : Set, ◮ B : A → Set, ◮ a constructor inA : ArgA(A, B) → A for A, ◮ a constructor inB : (x : ArgA(A, B)) → ArgB(A, B, inA) → B(inA(x))

for B

for some functors ArgA, ArgB (but from and to where?). First thought: an inductive-inductive def. is a family (A, B) of sets, so they should be represented by functors F = (F0, F1) : Fam(Set) → Fam(Set). Here, Fam(Set) category with objects (A, B) where A : Set, B : A → Set. Morphism (A, B) to (A′, B′) is (f , g) where f : A → A′, g : (x : A) → B(x) → B′(f (x)).

? ?

12

Every endofunctor F on Fam(Set) can be split up into F0 : Fam(Set) → Set, F1 : (X : Fam(Set)) → F0(X) → Set.

slide-28
SLIDE 28

Induction-induction as initial algebras?

In general, an inductive-inductive definition consists of

◮ A : Set, ◮ B : A → Set, ◮ a constructor inA : ArgA(A, B) → A for A, ◮ a constructor inB : (x : ArgA(A, B)) → ArgB(A, B, inA) → B(inA(x))

for B

for some functors ArgA, ArgB (but from and to where?). First thought: an inductive-inductive def. is a family (A, B) of sets, so they should be represented by functors F = (F0, F1) : Fam(Set) → Fam(Set). Here, Fam(Set) category with objects (A, B) where A : Set, B : A → Set. Morphism (A, B) to (A′, B′) is (f , g) where f : A → A′, g : (x : A) → B(x) → B′(f (x)).

12

slide-29
SLIDE 29

Induction-induction as initial algebras? (cont.)

F = (F0, F1) : Fam(Set) → Fam(Set) An F-algebra ((A, B), (c, d)) would have “constructors” c : F0(A, B) → A and d : (x : F0(A, B)) → F1(A, B, x) → B(c(x)).

13

slide-30
SLIDE 30

Induction-induction as initial algebras? (cont.)

F = (F0, F1) : Fam(Set) → Fam(Set) An F-algebra ((A, B), (c, d)) would have “constructors” c : F0(A, B) → A and d : (x : F0(A, B)) → F1(A, B, x) → B(c(x)). But then the constructor d for B cannot refer to the constructor c for A! [Necessary for the Π type example]

13

slide-31
SLIDE 31

Induction-induction as initial algebras? (cont.)

F = (F0, F1) : Fam(Set) → Fam(Set) An F-algebra ((A, B), (c, d)) would have “constructors” c : F0(A, B) → A and d : (x : F0(A, B)) → F1(A, B, x) → B(c(x)). But then the constructor d for B cannot refer to the constructor c for A! [Necessary for the Π type example] Instead, we would like F ′

1 : ((A, B) : Fam(Set), c : F0(A, B) → A) → F0(A, B) → Set.

(what we have is F1 : ((A, B) : Fam(Set)) → F0(A, B) → Set.)

13

slide-32
SLIDE 32

Contexts and types described this way

ε : Context Γ : Context σ : Type(Γ) Γ ⊲ σ : Context Γ : Context ιΓ : Type(Γ) Γ : Context σ : Type(Γ) τ : Type(Γ ⊲ σ) Π(σ, τ) : Type(Γ) ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Note ‘Γ : Context’ replaced by ‘c(x)’ for x : ArgContext(Context, Type) in ArgType. Can be combined into Arg : ((A, B) : Fam(Set), c : ArgA(A, B) → A) → Fam(Set) by defining Arg(A, B, c) = (ArgA(A, B), ArgB(A, B, c)).

14

slide-33
SLIDE 33

Induction-induction as initial dialgebras

What kind of structure is ((A, B) : Fam(Set), c : ArgA(A, B) → A)?

15

slide-34
SLIDE 34

Induction-induction as initial dialgebras

What kind of structure is ((A, B) : Fam(Set), c : ArgA(A, B) → A)? Hagino introduced dialgebras in his PhD thesis:

Definition

Let F, G : C → D be functors. An (F, G)-dialgebra (X, f) consists of X ∈ C and f : F(X) → G(X). A morphism between dialgebras (X, f ) and (Y , g) is a morphism α : X → Y in C such that F(X)

f

  • F(α)
  • G(X)

G(α)

  • F(Y )

g

G(Y )

15

slide-35
SLIDE 35

Induction-induction as initial dialgebras

Definition

Let F, G : C → D be functors. An (F, G)-dialgebra (X, f) consists of X ∈ C and f : F(X) → G(X). A morphism between dialgebras (X, f ) and (Y , g) is a morphism α : X → Y in C such that F(X)

f

  • F(α)
  • G(X)

G(α)

  • F(Y )

g

G(Y )

((A, B) : Fam(Set), c : ArgA(A, B) → A) is a (ArgA, U)-dialgebra, where U : Fam(Set) → Set is the forgetful functor! [ U(A, B) = A ] C = Fam(Set) D = Set F = ArgA : Fam(Set) → Set G = U : Fam(Set) → Set (forgetful)

15

slide-36
SLIDE 36

Induction-induction as initial dialgebras (cont.)

Thus, our ind.-ind. definitions should be represented by functors ArgA : Fam(Set) → Set Arg : Dialg(ArgA, U) → Fam(Set) such that U ◦ Arg = ArgA ◦ V . Here, V : Dialg(ArgA, U) → Fam(Set) is the forgetful functor sending (A, f ) to A. the condition just says that “the first component of Arg is ArgA.” We will often write Arg = (ArgA, ArgB).

16

slide-37
SLIDE 37

So what category do the ind.-ind. definitions live in?

Given Arg = (ArgA, ArgB) : Dialg(ArgA, U) → Fam(Set), one might think that the “algebras” we are looking for are in Dialg(Arg, V ).

17

slide-38
SLIDE 38

So what category do the ind.-ind. definitions live in?

Given Arg = (ArgA, ArgB) : Dialg(ArgA, U) → Fam(Set), one might think that the “algebras” we are looking for are in Dialg(Arg, V ). Dialgebras with C = Dialg(ArgA, U), D = Fam(Set), F = Arg : Dialg(ArgA, U) → Fam(Set) G = V : Dialg(ArgA, U) → Fam(Set) (forgetful) so Dialg(Arg, V ) has objects (A, B, c, (d0, d1)), where

◮ A : Set, B : A → Set, ◮ c : ArgA(A, B) → A, ◮ (d0, d1) : Arg(A, B, c) → (A, B). 17

slide-39
SLIDE 39

So what category do the ind.-ind. definitions live in?

Given Arg = (ArgA, ArgB) : Dialg(ArgA, U) → Fam(Set), one might think that the “algebras” we are looking for are in Dialg(Arg, V ). Dialgebras with C = Dialg(ArgA, U), D = Fam(Set), F = Arg : Dialg(ArgA, U) → Fam(Set) G = V : Dialg(ArgA, U) → Fam(Set) (forgetful) so Dialg(Arg, V ) has objects (A, B, c, (d0, d1)), where

◮ A : Set, B : A → Set, ◮ c : ArgA(A, B) → A, ◮ (d0, d1) : Arg(A, B, c) → (A, B).

The function d0 : ArgA(A, B) → A looks like the constructor for A that we want, but d1 : (x : ArgA(A, B)) → ArgB(A, B, c, x) → B(d0(x)) does not look quite right – we need c and d0 to be the same!

17

slide-40
SLIDE 40

Making c and d0 the same

d1 : (x : ArgA(A, B)) → ArgB(A, B, c, x) → B(d0(x)) Use an equaliser in CAT.

18

slide-41
SLIDE 41

Making c and d0 the same

d1 : (x : ArgA(A, B)) → ArgB(A, B, c, x) → B(d0(x)) Use an equaliser in CAT. Let W : Dialg(Arg, V ) → Dialg(ArgA, U) be the forgetful functor [W (A, B, c, d) = (A, B, c)].

18

slide-42
SLIDE 42

Making c and d0 the same

d1 : (x : ArgA(A, B)) → ArgB(A, B, c, x) → B(d0(x)) Use an equaliser in CAT. Let W : Dialg(Arg, V ) → Dialg(ArgA, U) be the forgetful functor [W (A, B, c, d) = (A, B, c)]. Define (V , U) : Dialg(Arg, V ) → Dialg(ArgA, U) by (V , U)(A, B, c, (d0, d1)) := (V (A, B, c), U(d0, d1)) = (A, B, d0).

18

slide-43
SLIDE 43

Making c and d0 the same

d1 : (x : ArgA(A, B)) → ArgB(A, B, c, x) → B(d0(x)) Use an equaliser in CAT. Let W : Dialg(Arg, V ) → Dialg(ArgA, U) be the forgetful functor [W (A, B, c, d) = (A, B, c)]. Define (V , U) : Dialg(Arg, V ) → Dialg(ArgA, U) by (V , U)(A, B, c, (d0, d1)) := (V (A, B, c), U(d0, d1)) = (A, B, d0). Note: U(d0, d1) : U(Arg(A, B, c)) → U(V (A, B, c)) = ArgA(V (A, B, c)) → U(V (A, B, c)).

18

slide-44
SLIDE 44

Making c and d0 the same

d1 : (x : ArgA(A, B)) → ArgB(A, B, c, x) → B(d0(x)) Use an equaliser in CAT. Let W : Dialg(Arg, V ) → Dialg(ArgA, U) be the forgetful functor [W (A, B, c, d) = (A, B, c)]. Define (V , U) : Dialg(Arg, V ) → Dialg(ArgA, U) by (V , U)(A, B, c, (d0, d1)) := (V (A, B, c), U(d0, d1)) = (A, B, d0). Note: U(d0, d1) : U(Arg(A, B, c)) → U(V (A, B, c)) = ArgA(V (A, B, c)) → U(V (A, B, c)). Take equaliser of W and (V , U), let’s call it E(ArgA,ArgB) [subcategory with objects (A, B, c, (d0, d1)) such that (A, B, c) = (A, B, d0)].

18

slide-45
SLIDE 45

Summary

Set Fam(Set)

ArgA

  • U
  • Dialg(ArgA, U)

Arg

  • V
  • Dialg(Arg, V )

(V ,U)

  • W
  • EArg
  • Warning: the diagram is not commuting!

The category E(ArgA,ArgB) has objects (A, B, c, d), where

◮ A : Set, ◮ B : A → Set, ◮ c : ArgA(A, B) → A, ◮ d : (x : ArgA(A, B)) → ArgB(A, B, c, x) → B(c(x)).

Morphisms are Fam(Set)-morphisms making some diagrams commute.

19

slide-46
SLIDE 46

Summary

Set Fam(Set)

ArgA

  • U
  • Dialg(ArgA, U)

Arg

  • V
  • Dialg(Arg, V )

(V ,U)

  • W
  • EArg
  • Warning: the diagram is not commuting!

The category E(ArgA,ArgB) has objects (A, B, c, d), where

◮ A : Set, ◮ B : A → Set, ◮ c : ArgA(A, B) → A, ◮ d : (x : ArgA(A, B)) → ArgB(A, B, c, x) → B(c(x)).

Morphisms are Fam(Set)-morphisms making some diagrams commute. Intended interpretation initial object in E(ArgA,ArgB).

19

slide-47
SLIDE 47

Initiality and elimination rules

slide-48
SLIDE 48

An example of iteration from initiality

Back to the example. Suppose that we want a concatenation of contexts + + : Context → Context → Context For example for more general formation rules such as σ : Type(Γ) τ : Type(∆) σ × τ : Type(Γ + + ∆)

20

slide-49
SLIDE 49

Context concatenation

Should satisfy equations ∆ + + ε = ∆ ∆ + + (Γ ⊲ σ) = (∆ + + Γ) ⊲ (wkΓ(σ, ∆)) ,

21

slide-50
SLIDE 50

Context concatenation

Should satisfy equations ∆ + + ε = ∆ ∆ + + (Γ ⊲ σ) = (∆ + + Γ) ⊲ (wkΓ(σ, ∆)) , wk : (Γ : Context) → (σ : Type(Γ)) → (∆ : Context) → Type(∆ + + Γ) is a weakening operation.

◮ That is, if σ : Type(Γ), then wkΓ(σ, ∆) : Type(∆ +

+ Γ).

21

slide-51
SLIDE 51

Context concatenation

Should satisfy equations ∆ + + ε = ∆ ∆ + + (Γ ⊲ σ) = (∆ + + Γ) ⊲ (wkΓ(σ, ∆)) , wk : (Γ : Context) → (σ : Type(Γ)) → (∆ : Context) → Type(∆ + + Γ) is a weakening operation.

◮ That is, if σ : Type(Γ), then wkΓ(σ, ∆) : Type(∆ +

+ Γ).

Should satisfy own equations wkΓ(ιΓ, ∆) = ι∆+

wkΓ(ΠΓ(σ, τ), ∆) = Π∆+

+Γ(wkΓ(σ, ∆), wkΓ⊲σ(τ, ∆)) .

21

slide-52
SLIDE 52

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) .

22

slide-53
SLIDE 53

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk.

22

slide-54
SLIDE 54

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk. inA : ArgContext(A, B) → A inA(inl(⋆)) = {? : Context → Context} inA(inr(f , g)) = {? : Context → Context} , inB : (x : ArgContext(A, B)) → ArgType(A, B, inA, x) → B(inA(x)) inB(∆, inl(⋆)) = {?} inB(∆, inr(g, h)) = {?} .

22

slide-55
SLIDE 55

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk. inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. {? : Context} inA(inr(f , g)) = {? : Context → Context} , inB : (x : ArgContext(A, B)) → ArgType(A, B, inA, x) → B(inA(x)) inB(∆, inl(⋆)) = {?} inB(∆, inr(g, h)) = {?} .

22

slide-56
SLIDE 56

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk. inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = {? : Context → Context} , inB : (x : ArgContext(A, B)) → ArgType(A, B, inA, x) → B(inA(x)) inB(∆, inl(⋆)) = {?} inB(∆, inr(g, h)) = {?} .

22

slide-57
SLIDE 57

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk. inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆. {? : Context} , inB : (x : ArgContext(A, B)) → ArgType(A, B, inA, x) → B(inA(x)) inB(∆, inl(⋆)) = {?} inB(∆, inr(g, h)) = {?} .

22

slide-58
SLIDE 58

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk. inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆. ( {?0 : Context} ⊲ {?1 : Type(?0)} ) , inB : (x : ArgContext(A, B)) → ArgType(A, B, inA, x) → B(inA(x)) inB(∆, inl(⋆)) = {?} inB(∆, inr(g, h)) = {?} .

22

slide-59
SLIDE 59

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk. inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆.( f ( {?0 : Context} ) ⊲ {?1 : Type(f (?0))} inB : (x : ArgContext(A, B)) → ArgType(A, B, inA, x) → B(inA(x)) inB(∆, inl(⋆)) = {?} inB(∆, inr(g, h)) = {?} .

22

slide-60
SLIDE 60

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk. inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆. (f (∆) ⊲ {?1 : Type(f (∆))} ) , inB : (x : ArgContext(A, B)) → ArgType(A, B, inA, x) → B(inA(x)) inB(∆, inl(⋆)) = {?} inB(∆, inr(g, h)) = {?} .

22

slide-61
SLIDE 61

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk. inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆. (f (∆) ⊲ g( {?1 : Context} )) , inB : (x : ArgContext(A, B)) → ArgType(A, B, inA, x) → B(inA(x)) inB(∆, inl(⋆)) = {?} inB(∆, inr(g, h)) = {?} .

22

slide-62
SLIDE 62

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk. inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆. (f (∆) ⊲ g(∆)) , inB : (x : ArgContext(A, B)) → ArgType(A, B, inA, x) → B(inA(x)) inB(∆, inl(⋆)) = {?} inB(∆, inr(g, h)) = {?} .

22

slide-63
SLIDE 63

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk. inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆. (f (∆) ⊲ g(∆)) , inB : (x : ArgContext(A, B)) → ArgType(A, B, inA, x) → B(inA(x)) inB(∆, inl(⋆)) = λΓ. ιinA(∆)(Γ) inB(∆, inr(g, h)) = {?} .

22

slide-64
SLIDE 64

Context concatenation (cont.)

Recall: ArgContext(A, B) = 1 + Σ Γ:A. B(Γ) ArgType(A, B, c, x) = 1 + (Σ σ:B(c(x)). τ :B(c(inr(c(x), σ)))) . Want to give (A, B), where A = Context → Context and B(f ) = (∆ : Context) → Type(f (∆)), an (ArgContext, ArgType) structure such that initiality gives us + + and wk. inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆. (f (∆) ⊲ g(∆)) , inB : (x : ArgContext(A, B)) → ArgType(A, B, inA, x) → B(inA(x)) inB(∆, inl(⋆)) = λΓ. ιinA(∆)(Γ) inB(∆, inr(g, h)) = λΓ. ΠinA(∆)(Γ)(g(Γ), h(Γ)) .

22

slide-65
SLIDE 65

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

23

slide-66
SLIDE 66

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) =

23

slide-67
SLIDE 67

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆)))

23

slide-68
SLIDE 68

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆)))

23

ArgContext(f , g) = id + Σ(f , g)

slide-69
SLIDE 69

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆))

23

ArgContext(f , g) = id + Σ(f , g)

slide-70
SLIDE 70

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆))

23

inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆. (f (∆) ⊲ g(∆))

slide-71
SLIDE 71

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆)) = λ∆. ∆

23

inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆. (f (∆) ⊲ g(∆))

slide-72
SLIDE 72

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆)) = λ∆. ∆ Thus ∆ + + ε = ∆.

23

slide-73
SLIDE 73

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆)) = λ∆. ∆ + + (Γ ⊲ σ) = Thus ∆ + + ε = ∆.

23

slide-74
SLIDE 74

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆)) = λ∆. ∆ + + (Γ ⊲ σ) = inA(ArgContext(+ +, wk)(inr(Γ, σ))) Thus ∆ + + ε = ∆.

23

slide-75
SLIDE 75

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆)) = λ∆. ∆ + + (Γ ⊲ σ) = inA(ArgContext(+ +, wk)(inr(Γ, σ))) Thus ∆ + + ε = ∆.

23

ArgContext(f , g) = id + Σ(f , g)

slide-76
SLIDE 76

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆)) = λ∆. ∆ + + (Γ ⊲ σ) = inA(ArgContext(+ +, wk)(inr(Γ, σ))) = inA(inr(+ +(Γ), wk(Γ, σ))) Thus ∆ + + ε = ∆.

23

ArgContext(f , g) = id + Σ(f , g)

slide-77
SLIDE 77

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆)) = λ∆. ∆ + + (Γ ⊲ σ) = inA(ArgContext(+ +, wk)(inr(Γ, σ))) = inA(inr(+ +(Γ), wk(Γ, σ))) Thus ∆ + + ε = ∆.

23

inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆. (f (∆) ⊲ g(∆))

slide-78
SLIDE 78

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆)) = λ∆. ∆ + + (Γ ⊲ σ) = inA(ArgContext(+ +, wk)(inr(Γ, σ))) = inA(inr(+ +(Γ), wk(Γ, σ))) = λ∆. + + (Γ, ∆) ⊲ wk(Γ, σ, ∆) . Thus ∆ + + ε = ∆.

23

inA : ArgContext(A, B) → A inA(inl(⋆)) = λ∆. ∆ inA(inr(f , g)) = λ∆. (f (∆) ⊲ g(∆))

slide-79
SLIDE 79

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆)) = λ∆. ∆ + + (Γ ⊲ σ) = inA(ArgContext(+ +, wk)(inr(Γ, σ))) = inA(inr(+ +(Γ), wk(Γ, σ))) = λ∆. + + (Γ, ∆) ⊲ wk(Γ, σ, ∆) . Thus ∆ + + ε = ∆ and ∆ + + (Γ ⊲ σ) = (∆ + + Γ) ⊲ wkΓ(σ, ∆).

23

slide-80
SLIDE 80

Context concatenation (cont.)

Initiality gives a morphism (+ +, wk) : (Context, Type) → (A, B) s. t. (ArgContext, ArgType)(Context, Type, [ε, ⊲])

([ε,⊲],[ι,Π]) (ArgContext,ArgType)(+ +,wk)

  • (Context, Type)

(+ +,wk)

  • (ArgContext, ArgType)(A, B, inA)

(inA,inB)

(A, B)

We better check it satisfies the specification: + +(ε) = inA(ArgContext(+ +, wk)(inl(⋆))) = inA(inl(⋆)) = λ∆. ∆ + + (Γ ⊲ σ) = inA(ArgContext(+ +, wk)(inr(Γ, σ))) = inA(inr(+ +(Γ), wk(Γ, σ))) = λ∆. + + (Γ, ∆) ⊲ wk(Γ, σ, ∆) . Thus ∆ + + ε = ∆ and ∆ + + (Γ ⊲ σ) = (∆ + + Γ) ⊲ wkΓ(σ, ∆). The equations for wk hold in the same way.

23

slide-81
SLIDE 81

What about dependent functions?

Traditional presentations of type theory include elimination rules (eliminator terms) instead of defining functions using initiality. Get dependent functions elimArgA(. . .) : (x : A) → P(x) elimArgB(. . .) : (x : A) → (y : B(x)) → Q(x, y, elimArgA(. . . , x)) by defining them for elements of the form c(x), d(x, y) with access to inductive hypothesis / structurally recursive calls.

24

slide-82
SLIDE 82

What about dependent functions?

Traditional presentations of type theory include elimination rules (eliminator terms) instead of defining functions using initiality. Get dependent functions elimArgA(. . .) : (x : A) → P(x) elimArgB(. . .) : (x : A) → (y : B(x)) → Q(x, y, elimArgA(. . . , x)) by defining them for elements of the form c(x), d(x, y) with access to inductive hypothesis / structurally recursive calls. In detail:

P : A → Set Q : (x : A) → B(x) → P(x) → Set stepc : (x : ArgA(A, B)) → ArgA(P, Q, x) → P(c(x)) stepd : (x : ArgA(A, B)) → (y : ArgB(A, B, c, x)) → ( x : ArgA(P, Q, x)) → ArgB(P, Q, c, stepc, x, y, x) → Q(c(x), d(x, y), stepc(x, x)) elimArgA(P, Q, stepc, stepd) : (x : A) → P(x) elimArgB(P, Q, stepc, stepd) : (x : A) → (y : B(x)) → Q(x, y, elimArgA(P, Q, stepc, stepd, x))

24

slide-83
SLIDE 83

Elimination rules vs. initiality

One could think that eliminators are strictly stronger than initiality, since they allow one to define dependent functions (and do proof by induction).

25

slide-84
SLIDE 84

Elimination rules vs. initiality

One could think that eliminators are strictly stronger than initiality, since they allow one to define dependent functions (and do proof by induction). However, this is not the case!

Proposition

An initial object in EArg has an eliminator.

25

slide-85
SLIDE 85

Elimination rules vs. initiality

One could think that eliminators are strictly stronger than initiality, since they allow one to define dependent functions (and do proof by induction). However, this is not the case!

Proposition

An initial object in EArg has an eliminator. The proof is a generalisation of the proof of the analog result for initial algebras.

25

slide-86
SLIDE 86

Initiality vs. elimination rules

By considering constant families P(x) = Y , Q(v, x, y) = Z(y), we get

Proposition

Every object with an eliminator is weakly initial in EArg.

26

slide-87
SLIDE 87

Equivalence for strictly positive functors

For strictly positive functors (as codified in our previous axiomatisation), we can do induction on their build-up to prove the uniqueness of the initiality arrow.

Theorem

For an inductive-inductive definition given by a strictly positive functor (ArgA, ArgB), the elimination rules hold if and only if E(ArgA,ArgB) has an initial object.

27

slide-88
SLIDE 88

Summary

Inductive-inductive definitions: A : Set, B : A → Set defined mutually dependent, both defined inductively. Initial-algebra-like semantics, but using dialgebras instead of

  • rdinary algebras.

Equivalence between initiality and elimination rules for strictly positive functors.

28

slide-89
SLIDE 89

Summary

Inductive-inductive definitions: A : Set, B : A → Set defined mutually dependent, both defined inductively. Initial-algebra-like semantics, but using dialgebras instead of

  • rdinary algebras.

Equivalence between initiality and elimination rules for strictly positive functors.

28

Thanks!