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 What are inductive-inductive definitions? 2 How can they be described, categorically? 3 Exploiting initiality. 1
Notation Work in the framework of Martin-L¨ of 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
Inductive-inductive definitions
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
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
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
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
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
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
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
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
Type theory inside type theory Context : Set defined inductively Type : Context → Set Term : (Γ : Context) → Type(Γ) → Set . . . Substitutions, . . . . . . 7
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
Constructor for Type referring to constructor for Context Γ context Γ ⊢ σ type Γ , x : σ ⊢ τ ( x ) type Γ ⊢ Π x : σ . τ ( x ) type 9
Constructor for Type referring to constructor for Context Γ context Γ ⊢ σ type Γ , x : σ ⊢ τ ( x ) type Γ ⊢ Π x : σ . τ ( x ) type Γ : Context 9
Constructor for Type referring to constructor for Context Γ context Γ ⊢ σ type Γ , x : σ ⊢ τ ( x ) type Γ ⊢ Π x : σ . τ ( x ) type Γ : Context σ : Type(Γ) 9
Constructor for Type referring to constructor for Context Γ context Γ ⊢ σ type Γ , x : σ ⊢ τ ( x ) type Γ ⊢ Π x : σ . τ ( x ) type Γ : Context σ : Type(Γ) τ : Type(Γ ⊲ σ ) 9
Constructor for Type referring to constructor for Context Γ context Γ ⊢ σ type Γ , x : σ ⊢ τ ( x ) type Γ ⊢ Π x : σ . τ ( x ) type Γ : Context σ : Type(Γ) τ : Type(Γ ⊲ σ ) 9
Constructor for Type referring to constructor for Context Γ context Γ ⊢ σ type Γ , x : σ ⊢ τ ( x ) type Γ ⊢ Π x : σ . τ ( x ) type Γ : Context σ : Type(Γ) τ : Type(Γ ⊲ σ ) Π( σ, τ ) : Type(Γ) 9
But is there a theory? Previous work: axiomatisation. Now: initial algebra like semantics – less ugly details. 10
Describing inductive-inductive datatypes
� � � 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 F ( X ) X F ( α ) α � Y F ( Y ) g 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
Induction-induction as initial algebras? In general, an inductive-inductive definition consists of ◮ A : Set, ◮ B : A → Set, ◮ a constructor in A : Arg A ( A , B ) → A for A , ◮ a constructor in B : ( x : Arg A ( A , B )) → Arg B ( A , B , in A ) → B (in A ( x )) for B for some functors Arg A , Arg B (but from and to where?). 12
Induction-induction as initial algebras? In general, an inductive-inductive definition consists of ◮ A : Set, ◮ B : A → Set, ◮ a constructor in A : Arg A ( A , B ) → A for A , ◮ a constructor in B : ( x : Arg A ( A , B )) → Arg B ( A , B , in A ) → B (in A ( x )) for B for some functors Arg A , Arg B (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 = ( F 0 , F 1 ) : Fam ( Set ) → Fam ( Set ) . 12
Induction-induction as initial algebras? In general, an inductive-inductive definition consists of ◮ A : Set, ◮ B : A → Set, ◮ a constructor in A : Arg A ( A , B ) → A for A , ◮ a constructor in B : ( x : Arg A ( A , B )) → Arg B ( A , B , in A ) → B (in A ( x )) for B for some functors Arg A , Arg B (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 = ( F 0 , F 1 ) : 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
Induction-induction as initial algebras? In general, an inductive-inductive definition consists of ◮ A : Set, ◮ B : A → Set, ◮ a constructor in A : Arg A ( A , B ) → A for A , ◮ a constructor in B : ( x : Arg A ( A , B )) → Arg B ( A , B , in A ) → B (in A ( x )) for B for some functors Arg A , Arg B (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 = ( F 0 , F 1 ) : Fam ( Set ) → Fam ( Set ) . Here, Fam ( Set ) category with objects ( A , B ) where A : Set, B : A → Set. Every endofunctor F on Fam ( Set ) can be split up into Morphism ( A , B ) to ( A ′ , B ′ ) is ( f , g ) where f : A → A ′ , F 0 : Fam ( Set ) → Set , F 1 : ( X : Fam ( Set )) → F 0 ( X ) → Set . g : ( x : A ) → B ( x ) → B ′ ( f ( x )). 12
Induction-induction as initial algebras? In general, an inductive-inductive definition consists of ◮ A : Set, ◮ B : A → Set, ◮ a constructor in A : Arg A ( A , B ) → A for A , ◮ a constructor in B : ( x : Arg A ( A , B )) → Arg B ( A , B , in A ) → B (in A ( x )) for B for some functors Arg A , Arg B (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 = ( F 0 , F 1 ) : 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
Induction-induction as initial algebras? (cont.) F = ( F 0 , F 1 ) : Fam ( Set ) → Fam ( Set ) An F -algebra (( A , B ) , ( c , d )) would have “constructors” c : F 0 ( A , B ) → A and d : ( x : F 0 ( A , B )) → F 1 ( A , B , x ) → B ( c ( x )). 13
Recommend
More recommend