(effectul) game semantics for dependent typespbl/galop2016/vakarslides.pdf · (effectul) game...

Post on 18-Oct-2020

3 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

(Effectul) Game Semantics for Dependent Types

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar

Eindhoven, 3 April 2016

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

−→

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Overview

Game theoretic models of dependent type theory (DTT):

get faithful model of (total) DTT with Σ-, Π-, intensionalId-types and finite inductive type families;

fully complete if Id-types limited;

very intensional model - refines domain model;

Id-types more intensional: function extensionality fails;

intensional orthogonally to HoTT (time vs space): UIP holds;

call-by-name evaluation;

can (dis)allow effects by varying condition on strategies:combining dependent types and effects!

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Overview

Game theoretic models of dependent type theory (DTT):

get faithful model of (total) DTT with Σ-, Π-, intensionalId-types and finite inductive type families;

fully complete if Id-types limited;

very intensional model - refines domain model;

Id-types more intensional: function extensionality fails;

intensional orthogonally to HoTT (time vs space): UIP holds;

call-by-name evaluation;

can (dis)allow effects by varying condition on strategies:combining dependent types and effects!

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Overview

Game theoretic models of dependent type theory (DTT):

get faithful model of (total) DTT with Σ-, Π-, intensionalId-types and finite inductive type families;

fully complete if Id-types limited;

very intensional model - refines domain model;

Id-types more intensional: function extensionality fails;

intensional orthogonally to HoTT (time vs space): UIP holds;

call-by-name evaluation;

can (dis)allow effects by varying condition on strategies:combining dependent types and effects!

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

The Semantic (Hyper)Cube

Consider subfamily str of all strategies to exclude effects:

No non-termination: winning

No state: history-freeness /innocence + visibility

No control operators: question-answer discipline

No erratic choice: determinacy for Player...

Primarily, here, for str we demand all these conditions (forcompleteness results), but can vary to model effects.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

The Semantic (Hyper)Cube

Consider subfamily str of all strategies to exclude effects:

No non-termination: winning

No state: history-freeness /innocence + visibility

No control operators: question-answer discipline

No erratic choice: determinacy for Player...

Primarily, here, for str we demand all these conditions (forcompleteness results), but can vary to model effects.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Games and Simple Type Theory (STT)

Write (Game, I,&,⇒) for ccc of games and strategies.

Ground types (finite inductive types): for a set X , game X∗ withone Opponent move ∗, followed by any of the Player moves x ∈ X .

Call simple type theory (STT): λ-calculus with binary products ×,function types ⇒ and finite inductive types {ai | 1 ≤ i ≤ n}, or atotal finitary PCF with binary products.

Straightforward consequence of AJM2000:

TheoremInterpretation in Game fully and faithfully complete:SyntaxSTT

[[−]]−→ Game full and faithful.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Games and Simple Type Theory (STT)

Write (Game, I,&,⇒) for ccc of games and strategies.

Ground types (finite inductive types): for a set X , game X∗ withone Opponent move ∗, followed by any of the Player moves x ∈ X .

Call simple type theory (STT): λ-calculus with binary products ×,function types ⇒ and finite inductive types {ai | 1 ≤ i ≤ n}, or atotal finitary PCF with binary products.

Straightforward consequence of AJM2000:

TheoremInterpretation in Game fully and faithfully complete:SyntaxSTT

[[−]]−→ Game full and faithful.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Games and Simple Type Theory (STT)

Write (Game, I,&,⇒) for ccc of games and strategies.

Ground types (finite inductive types): for a set X , game X∗ withone Opponent move ∗, followed by any of the Player moves x ∈ X .

Call simple type theory (STT): λ-calculus with binary products ×,function types ⇒ and finite inductive types {ai | 1 ≤ i ≤ n}, or atotal finitary PCF with binary products.

Straightforward consequence of AJM2000:

TheoremInterpretation in Game fully and faithfully complete:SyntaxSTT

[[−]]−→ Game full and faithful.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Dependent type theory (DTT)?

What is it?

Curry-Howard for predicate logic: types with free (term)variables, constructions Σ,Π, Id (cf. ∃,∀,=) on types.Judgements like x : A ` B(x) type and x : A ` b(x) : B(x).Order in context matters!No clean separation syntax types and terms.

Why care?

Move towards richer type systems: e.g. GADTs in Haskell.Types allowed to refer to data: e.g. n : N ` List(n) type.Specification by typing: certification by type checking.Programming logic as a proof assistant.Logical Frameworks.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Dependent type theory (DTT)?

What is it?

Curry-Howard for predicate logic: types with free (term)variables, constructions Σ,Π, Id (cf. ∃,∀,=) on types.Judgements like x : A ` B(x) type and x : A ` b(x) : B(x).Order in context matters!No clean separation syntax types and terms.

Why care?

Move towards richer type systems: e.g. GADTs in Haskell.Types allowed to refer to data: e.g. n : N ` List(n) type.Specification by typing: certification by type checking.Programming logic as a proof assistant.Logical Frameworks.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Dependent types and their terms:n : N ` List(n) typen : N, x : List(n) ` reverse(x) : List(n)

Π- and Σ-types (generalising ⇒ and ×):` λnλx reverse(x) : Πn:NList(n)⇒ List(n)` mult : Πk,l ,m:Nmatrix(k, l)×matrix(l ,m)⇒ matrix(k,m)` 〈9, [No, wise, fish, would, go, anywhere, without, a, porpoise]〉 : Σn:NList(n)

Id-type:` refl : IdN(0, (λx x)(0))x , y : B ` case(x,case(y,refl,refl),case(y,refl,refl)) : IdB(lsor(x,y),rsor(x,y))

Finite inductive type families:x : months ` days(x) type` 31 : days(October).

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Dependent types and their terms:n : N ` List(n) typen : N, x : List(n) ` reverse(x) : List(n)

Π- and Σ-types (generalising ⇒ and ×):` λnλx reverse(x) : Πn:NList(n)⇒ List(n)` mult : Πk,l ,m:Nmatrix(k, l)×matrix(l ,m)⇒ matrix(k,m)` 〈9, [No, wise, fish, would, go, anywhere, without, a, porpoise]〉 : Σn:NList(n)

Id-type:` refl : IdN(0, (λx x)(0))x , y : B ` case(x,case(y,refl,refl),case(y,refl,refl)) : IdB(lsor(x,y),rsor(x,y))

Finite inductive type families:x : months ` days(x) type` 31 : days(October).

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

A Faithful Translation to Simple Type Theory (STT)

Idea: DTT talks about same algorithms as STT but can assignthem a more precise type/specification.

Formally: have faithful translation (−)T of DTT into STT.

x : A ` (ai 7→i {bi ,j | j}) type 7→ ` {bi ,j | i , j} type

x : A ` Σy :BC type 7→ ` BT × CT type

x : A ` Πy :BC type 7→ ` BT ⇒ CT type

x : A, y : B, y ′ : B ` IdB(y , y ′) type 7→ ` {refl} type

x ′ : A′ ` B(a) type 7→ ` B(x)T type

+ translation on terms.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

A Faithful Translation to Simple Type Theory (STT)

Idea: DTT talks about same algorithms as STT but can assignthem a more precise type/specification.

Formally: have faithful translation (−)T of DTT into STT.

x : A ` (ai 7→i {bi ,j | j}) type 7→ ` {bi ,j | i , j} type

x : A ` Σy :BC type 7→ ` BT × CT type

x : A ` Πy :BC type 7→ ` BT ⇒ CT type

x : A, y : B, y ′ : B ` IdB(y , y ′) type 7→ ` {refl} type

x ′ : A′ ` B(a) type 7→ ` B(x)T type

+ translation on terms.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

The idea of our interpretation [[·]] will be to construct a categoryCtxtGame of dependent context games with a functor ,(−) toGame, such that

SyntaxDTT[[−]]- CtxtGame

SyntaxSTT

(−)T

?

⊂[[−]]

- Game.

,(−)

?

Games model of DTT will therefore automatically be faithful.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Dependent Games and Strategies

Game B with dependency on A consists of:

game ,(B) (without dependency);

function str(A) B−→ Sub(,(B)) from strategies on A tosubgames (.-closed subsets of plays) of ,(B).

Can define I, & and ⇒ on games with dependency and make intoccc with homset DGame(A)(B,C) := str(ΠA(B ⇒ C)).

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

We define a game ΠAB E A⇒ ,(B) of dependent functions.

Idea: the choice of a fibre B(a) for the output of a dependentfunction f : ΠAB is entirely the responsibility of the contextthat provides the argument a.

Opponent can determine fibre B(τ) of B:explicitly, revealing strategy τ on A, by playing in A;implicitly, by playing in ,(B);

Player has to stay within B(τ) for all τ consistent withOpponent’s behaviour.

That is, as long as there is such a τ ; otherwise, anything goes.

Indeed, Opponent is totally free and might not respect thetype dependency, as ,(−) should be faithful (to match (−)T ).

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

We define a game ΠAB E A⇒ ,(B) of dependent functions.

Idea: the choice of a fibre B(a) for the output of a dependentfunction f : ΠAB is entirely the responsibility of the contextthat provides the argument a.Opponent can determine fibre B(τ) of B:

explicitly, revealing strategy τ on A, by playing in A;implicitly, by playing in ,(B);

Player has to stay within B(τ) for all τ consistent withOpponent’s behaviour.

That is, as long as there is such a τ ; otherwise, anything goes.

Indeed, Opponent is totally free and might not respect thetype dependency, as ,(−) should be faithful (to match (−)T ).

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

We define a game ΠAB E A⇒ ,(B) of dependent functions.

Idea: the choice of a fibre B(a) for the output of a dependentfunction f : ΠAB is entirely the responsibility of the contextthat provides the argument a.Opponent can determine fibre B(τ) of B:

explicitly, revealing strategy τ on A, by playing in A;implicitly, by playing in ,(B);

Player has to stay within B(τ) for all τ consistent withOpponent’s behaviour.

That is, as long as there is such a τ ; otherwise, anything goes.

Indeed, Opponent is totally free and might not respect thetype dependency, as ,(−) should be faithful (to match (−)T ).

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Non-example of dependently typed algorithm: scheduling financemeetings

Player/Academic: x : months ` 31 : days(x)Opponent/Education FinanceBusiness Manager Manager:

Π( months∗ , days∗)∗ O31 P

Player chooses fibre: e.g. February doesn’t have a 31st day. MrManager shouldn’t allow that...

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Example of dependently typed algorithm:

Academic/Player: x : months ` casedays,months(x , {31, 1, . . . , 1, 31}) : days(x)Opponent/Education FinanceBusiness Manager Manager: − [January/x ]

Π( months∗ , days∗)∗ O

∗ PJanuary O

31 P

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Example (fibre-wise identities):

Player: x : A, y : B(x) ` y : B(x)Opponent: choose your favourite

Π( [[A]] , [[B]] ⇒ [[B]])b O

b Pb′ O

b′ P...

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Theorem

Have indexed ccc Gameop DGame−→ CCCat of dependent games:

ob(DGame(A)) := {str(A) B−→ Sub(,(B))}

hom-sets DGame(A)(B,C) := str(ΠA(B ⇒ C))

fibrewise identities as in example;

fibrewise comp. & change of base: usual AJM-composition.

As we don’t have (additive) Σ-types, not a model of DTT!”Well! I’ve often seen a cat without a grin,” thought Alice; ”but a grinwithout a cat! It’s the most curious thing I ever saw in all my life.”

TheoremFormally add them: get model CtxtGame of DTT with ΣΠ-types!Obj: lists [Xk ]k , where str(,(X1)& · · ·&,(Xk−1)) Xk−→ Sub(,(Xk)).Mor: lists of strategies on Π-games of more variables.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Theorem

Have indexed ccc Gameop DGame−→ CCCat of dependent games:

ob(DGame(A)) := {str(A) B−→ Sub(,(B))}

hom-sets DGame(A)(B,C) := str(ΠA(B ⇒ C))

fibrewise identities as in example;

fibrewise comp. & change of base: usual AJM-composition.

As we don’t have (additive) Σ-types, not a model of DTT!”Well! I’ve often seen a cat without a grin,” thought Alice; ”but a grinwithout a cat! It’s the most curious thing I ever saw in all my life.”

TheoremFormally add them: get model CtxtGame of DTT with ΣΠ-types!Obj: lists [Xk ]k , where str(,(X1)& · · ·&,(Xk−1)) Xk−→ Sub(,(Xk)).Mor: lists of strategies on Π-games of more variables.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Theorem

Have indexed ccc Gameop DGame−→ CCCat of dependent games:

ob(DGame(A)) := {str(A) B−→ Sub(,(B))}

hom-sets DGame(A)(B,C) := str(ΠA(B ⇒ C))

fibrewise identities as in example;

fibrewise comp. & change of base: usual AJM-composition.

As we don’t have (additive) Σ-types, not a model of DTT!”Well! I’ve often seen a cat without a grin,” thought Alice; ”but a grinwithout a cat! It’s the most curious thing I ever saw in all my life.”

TheoremFormally add them: get model CtxtGame of DTT with ΣΠ-types!Obj: lists [Xk ]k , where str(,(X1)& · · ·&,(Xk−1)) Xk−→ Sub(,(Xk)).Mor: lists of strategies on Π-games of more variables.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

We can also interpret

finite inductive type families x : A ` (ai 7→i {bi ,j | j} type:

[[ai ]] 7→ {bi ,j | j}∗ E {bi ,j | i , j}∗

else 7→ ∅∗ E {bi ,j | i , j}∗;

identity types x : A, x ′ : A ` IdA(x , x ′) type:

(σ, σ′) 7→ {refl | σ = σ′ }∗ E {refl}∗.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Non-Example:

Player: x : B, y : B ` p : IdB(x , y)Opponent : − [tt/x ,ff/y ]

Π( B∗ , Π( B∗ , IdB∗)∗ O

∗ Ptt O

∗ Pff O

refl P

...as tt 6= ff.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Example:

Player: x : B ` reflx : IdB(x , x)Opponent:

Π( B∗ , IdB∗{diagB∗})∗ Orefl P

...as x = x .

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Example, given x : A ` f : B(x , x , reflx ):

Player: x : A, x ′ : A, y : IdA(x , x ′) ` J(f ) : BOpponent:

Π( A , Π( A , Π( IdA , B)))b O

∗ Prefl O

f (b) Pa O

f (a) P...

...

...as refl move by Opponent has excluded all pairs (x , x ′) withx 6= x ′.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Place in intensionality spectrum Id-types:

Domains HoTT GamesFailure of Equality Reflection 3 3 3

Streicher Intensionality Criteria (I1) and (I2) 3 3 3

Streicher Intensionality Criterion (I3) 7 7 3

Failure of Function Extensionality (FunExt) 7 7 3

Failure of Uniqueness of Identity Proofs (UIP) 7 3 7.

Discrete ground types (0-types), but function hierarchy generates(open) propositional identities: applicative equivalences.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Completeness Results

Summarising, we have

Theorem (Soundness and Faithfulness)We have a faithful model of DTT with Σ-, Π-, intensional Id-typesand finite inductive type families: faithful functor

SyntaxDTT[[−]]- CtxtGame.

Actually, the model has strong completeness properties.

Theorem (Full Completeness)This interpretation is full when restricted to the types of the formA or ΠAIdB(f , g) with A and B built without Id-types:

SyntaxRestricted TypesDTT

[[−]]- CtxtGame full.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Completeness Results

Summarising, we have

Theorem (Soundness and Faithfulness)We have a faithful model of DTT with Σ-, Π-, intensional Id-typesand finite inductive type families: faithful functor

SyntaxDTT[[−]]- CtxtGame.

Actually, the model has strong completeness properties.

Theorem (Full Completeness)This interpretation is full when restricted to the types of the formA or ΠAIdB(f , g) with A and B built without Id-types:

SyntaxRestricted TypesDTT

[[−]]- CtxtGame full.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Alternative Id-types and Function Extensionality

Interpretation intensional Id-types not unique!Try alternative, mimicking the domain semantics, validatingfunction extensionality: Πx :AIdB(f (x), g(x)) ∼= IdΠx :AB(f , g).Demand that dep. games respect applicative equivalence.Define IdA: (σ, σ′) 7→ σAE ∩ σ′AE E ,(A), where σAE is theset of plays of ,(A) that is compatible with a strategy that isapplicatively equivalent to σ.

Interpret x : A ` reflx : IdA(x , x) as the copycat.For x : A ` f : B(x , x , reflx ), interpretx : A, x ′ : A, y : IdA(x , x ′) ` J(f ) : B(x , x ′, y) by playing [[f ]]between [[IdA]] and [[B]].Incompatible with partial or non-deterministic strategies!

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Alternative Id-types and Function Extensionality

Interpretation intensional Id-types not unique!Try alternative, mimicking the domain semantics, validatingfunction extensionality: Πx :AIdB(f (x), g(x)) ∼= IdΠx :AB(f , g).Demand that dep. games respect applicative equivalence.Define IdA: (σ, σ′) 7→ σAE ∩ σ′AE E ,(A), where σAE is theset of plays of ,(A) that is compatible with a strategy that isapplicatively equivalent to σ.Interpret x : A ` reflx : IdA(x , x) as the copycat.For x : A ` f : B(x , x , reflx ), interpretx : A, x ′ : A, y : IdA(x , x ′) ` J(f ) : B(x , x ′, y) by playing [[f ]]between [[IdA]] and [[B]].Incompatible with partial or non-deterministic strategies!

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Future Work

game semantics of higher inductive types / quotient types;

combining function extensionality with partiality andnon-determinism;

modelling universes and univalence;

infinite inductive type families and their definability results;

examining full completeness (w.r.t. DTT + UIP) of the modelfor the type hierarchy including unrestricted Id-types;

what do these models teach us about DTT with effects?

construct CBV and CBPV models;

compare with realizability models.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

In particular, for the first item:

HtpyGame

∞− Gpd×Set Game --

...................--Game-- A

∞− Gpd??

collapsing space-like identity,a.k.a. 0-truncation

--

--

Set

collapsing time-like identity,a.k.a. extensional collapse

??str(A)/obs.equiv.

?

X - ||X ||0.

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Bonus Example (Higher order dependent functions): approvingholiday plansPlayer/PhD Student: w : years, x : Π(y : days(w),Π(z : holidays(w , y),B)) ` going on holidays? : B

Opponent/Supervisor : −[2015/w , acceptable holidays/x ]

Π(years∗,Π( Π(days∗, Π(holidays∗, B∗))), B∗)∗ O

∗ P∗ OInternational Talk Like a Pirate Day P

ff Off P

(ITLPD happens every year, so don’t need to ask about the year.Moreover, Player is also in charge of supplying the date, so wedon’t have to determine the date before specifying the holiday.)

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Bonus Example (Higher order dependent functions): approvingholiday plansPlayer/PhD Student: w : years, x : Π(y : days(w),Π(z : holidays(w , y),B)) ` going on holidays? : B

Opponent/Supervisor : −[2015/w , acceptable holidays/x ]

Π(years∗,Π( Π(days∗, Π(holidays∗, B∗))), B∗)∗ O

∗ P∗ OInternational Talk Like a Pirate Day P

ff Ott P

disobedient student...

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

Bonus Example (Higher order dependent functions): approvingholiday plans

Player/PhD Student: w : years, x : Π(y : days(w),Π(z : holidays(w , y),B)) ` going on holidays? : BOpponent/Supervisor : − [2015/w , acceptable holidays/x ]

Π(years∗,Π( Π(days∗, Π(holidays∗, B∗))), B∗)∗ O

∗ P∗ OHoli P

∗ O∗ P2015 O

65 Ptt O

tt P

(Note that Holi happens every year with variable Gregorian dateand that Player gets to choose the day so can even specify theholiday before the day.)

Samson Abramsky, Radha Jagadeesan and Matthijs Vakar (Effectul) Game Semantics for Dependent Types

top related