Internal Parametricity and Cubical Type Theory€¦ · HoTTEST 2019 23 Examples: bridge-discrete...

Preview:

Citation preview

HoTTEST 2019 0

Internal Parametricity

and Cubical Type Theory

Evan Cavallo

& Robert Harper

Carnegie Mellon University

HoTTEST 2019 1

Internal Parametricity

Bernardy & Moulin.

A Computa�onal Interpreta�on of Parametricity. 2012.

Type Theory in Color. 2013.

Bernardy, Coquand, & Moulin.

A Presheaf Model of Parametric Type Theory. 2015.

Nuyts, Vezzosi, & Devriese.

Parametric Quan�fiers for Dependent Type Theory. 2017.

C & Harper. [arXiv:1901.00489]

Parametric Cubical Type Theory. 2019.

HoTTEST 2019 1

Internal Parametricity

Bernardy & Moulin.

A Computa�onal Interpreta�on of Parametricity. 2012.

Type Theory in Color. 2013.

Bernardy, Coquand, & Moulin.

A Presheaf Model of Parametric Type Theory. 2015.

Nuyts, Vezzosi, & Devriese.

Parametric Quan�fiers for Dependent Type Theory. 2017.

C & Harper. [arXiv:1901.00489]

Parametric Cubical Type Theory. 2019.

HoTTEST 2019 2

THIS TALK:

What is internal parametricity,

and how does it relate to

higher-dimensional type theory?

HoTTEST 2019 3

Parametric polymorphism, intui�vely

Parametric func�ons are “uniform” in type variables:

HoTTEST 2019 3

Parametric polymorphism, intui�vely

Parametric func�ons are “uniform” in type variables:

Compare with “ad-hoc” polymorphism:

HoTTEST 2019 4

Reynolds’ abstrac�on theorem (1983)

DEF: A family of (set-theore�c) func�ons is

parametric when it preserves all rela�ons.

HoTTEST 2019 4

Reynolds’ abstrac�on theorem (1983)

DEF: A family of (set-theore�c) func�ons is

parametric when it preserves all rela�ons. e.g.,

HoTTEST 2019 4

Reynolds’ abstrac�on theorem (1983)

DEF: A family of (set-theore�c) func�ons is

parametric when it preserves all rela�ons. e.g.,

Abstrac�on theorem: the denota�on of any term in

simply-typed λ-calculus (with ×, bool) is parametric.

HoTTEST 2019 5

Reynolds’ abstrac�on theorem (1983)

HoTTEST 2019 5

Reynolds’ abstrac�on theorem (1983)

HoTTEST 2019 6

Reynolds’ abstrac�on theorem (1983)

HoTTEST 2019 6

Reynolds’ abstrac�on theorem (1983)

HoTTEST 2019 6

Reynolds’ abstrac�on theorem (1983)

HoTTEST 2019 7

Reynolds’ abstrac�on theorem (1983)

Key idea: λ-calculus has a rela�onal interpreta�on.

HoTTEST 2019 7

Reynolds’ abstrac�on theorem (1983)

Key idea: λ-calculus has a rela�onal interpreta�on.

HoTTEST 2019 7

Reynolds’ abstrac�on theorem (1983)

Key idea: λ-calculus has a rela�onal interpreta�on.

HoTTEST 2019 7

Reynolds’ abstrac�on theorem (1983)

Key idea: λ-calculus has a rela�onal interpreta�on.

HoTTEST 2019 7

Reynolds’ abstrac�on theorem (1983)

Key idea: λ-calculus has a rela�onal interpreta�on.

Abstrac�on theorem extends interpreta�on to terms

HoTTEST 2019 8

Internal Parametricity (Bernardy et al)

Can we internalize the rela�onal interpreta�on in

dependent type theory?

HoTTEST 2019 8

Internal Parametricity (Bernardy et al)

Can we internalize the rela�onal interpreta�on in

dependent type theory?

i.e., can we give an opera�onal account of

parametricity?

HoTTEST 2019 8

Internal Parametricity (Bernardy et al)

Can we internalize the rela�onal interpreta�on in

dependent type theory?

i.e., can we give an opera�onal account of

parametricity?

HoTTEST 2019 8

Internal Parametricity (Bernardy et al)

Can we internalize the rela�onal interpreta�on in

dependent type theory?

i.e., can we give an opera�onal account of

parametricity?

HoTTEST 2019 8

Internal Parametricity (Bernardy et al)

Can we internalize the rela�onal interpreta�on in

dependent type theory?

i.e., can we give an opera�onal account of

parametricity?

HoTTEST 2019 9

An interlude: cubical type theory

HoTTEST 2019 9

An interlude: cubical type theory

category of dimension contexts could be:

faces, degeneracies, and permuta�ons [BCH]

+ diagonals [AFH, ABCFHL]

+ connec�ons [CCHM]

HoTTEST 2019 9

An interlude: cubical type theory

category of dimension contexts could be:

faces, degeneracies, and permuta�ons [BCH]

+ diagonals [AFH, ABCFHL]

+ connec�ons [CCHM]

respect for equality ensured by Kan opera�ons

HoTTEST 2019 9

An interlude: cubical type theory

category of dimension contexts could be:

faces, degeneracies, and permuta�ons [BCH]

+ diagonals [AFH, ABCFHL]

+ connec�ons [CCHM]

respect for equality ensured by Kan opera�ons

univalence via G / Glue / V types

HoTTEST 2019 10

Interlude: cubical type theory

HoTTEST 2019 10

Interlude: cubical type theory

HoTTEST 2019 10

Interlude: cubical type theory

HoTTEST 2019 10

Interlude: cubical type theory

HoTTEST 2019 10

Interlude: cubical type theory

Can we do the same for rela�ons?

HoTTEST 2019 11

Internal Parametricity (Bernardy et al)

Context of bridge variables (colors)

HoTTEST 2019 11

Internal Parametricity (Bernardy et al)

Context of bridge variables (colors)

Faces, degeneracies, and permuta�ons [BCH]

HoTTEST 2019 11

Internal Parametricity (Bernardy et al)

Context of bridge variables (colors)

Faces, degeneracies, and permuta�ons [BCH]

Faces:

HoTTEST 2019 11

Internal Parametricity (Bernardy et al)

Context of bridge variables (colors)

Faces, degeneracies, and permuta�ons [BCH]

Faces:

Degeneracies:

HoTTEST 2019 11

Internal Parametricity (Bernardy et al)

Context of bridge variables (colors)

Faces, degeneracies, and permuta�ons [BCH]

Faces:

Degeneracies:

Permuta�ons:

HoTTEST 2019 12

Bridge types

HoTTEST 2019 12

Bridge types

HoTTEST 2019 12

Bridge types

HoTTEST 2019 12

Bridge types

etc.

HoTTEST 2019 13

Bridges in func�on types

HoTTEST 2019 13

Bridges in func�on types

In cartesian cubical type theories:

HoTTEST 2019 13

Bridges in func�on types

In cartesian cubical type theories:

In BCH, this violates freshness requirements!

HoTTEST 2019 13

Bridges in func�on types

In cartesian cubical type theories:

In BCH, this violates freshness requirements!

Rela�onal interpreta�on of func�on types:

HoTTEST 2019 13

Bridges in func�on types

In cartesian cubical type theories:

In BCH, this violates freshness requirements!

Rela�onal interpreta�on of func�on types:

equivalent in the presence of J

HoTTEST 2019 14

Bridges in func�on types

HoTTEST 2019 14

Bridges in func�on types

Forward:

HoTTEST 2019 14

Bridges in func�on types

Forward:

Backward:

HoTTEST 2019 14

Bridges in func�on types

Forward:

Backward:Backward:

HoTTEST 2019 14

Bridges in func�on types

Forward:

Backward:Backward:

HoTTEST 2019 14

Bridges in func�on types

Forward:

Backward:Backward:

“case analysis for dimension terms”

HoTTEST 2019 15

Bridges in func�on types

Stability of capture under subs�tu�on relies on

absence of diagonals:

HoTTEST 2019 15

Bridges in func�on types

Stability of capture under subs�tu�on relies on

absence of diagonals:

HoTTEST 2019 15

Bridges in func�on types

Stability of capture under subs�tu�on relies on

absence of diagonals:

HoTTEST 2019 15

Bridges in func�on types

Stability of capture under subs�tu�on relies on

absence of diagonals:

HoTTEST 2019 15

Bridges in func�on types

Stability of capture under subs�tu�on relies on

absence of diagonals:

HoTTEST 2019 15

Bridges in func�on types

Stability of capture under subs�tu�on relies on

absence of diagonals:

HoTTEST 2019 16

Bridges in the universe (“rela�vity”)

Want:

HoTTEST 2019 16

Bridges in the universe (“rela�vity”)

Want:

Forward:

HoTTEST 2019 16

Bridges in the universe (“rela�vity”)

Want:

Forward:

Backward:

HoTTEST 2019 16

Bridges in the universe (“rela�vity”)

Want:

Forward:

Backward:

BCH G-types for rela�ons

HoTTEST 2019 17

Bridges in the universe (“rela�vity”)

HoTTEST 2019 17

Bridges in the universe (“rela�vity”)

cartesian (Glue/V)

HoTTEST 2019 17

Bridges in the universe (“rela�vity”)

cartesian (Glue/V)

HoTTEST 2019 17

Bridges in the universe (“rela�vity”)

cartesian (Glue/V)

HoTTEST 2019 17

Bridges in the universe (“rela�vity”)

cartesian (Glue/V)

HoTTEST 2019 17

Bridges in the universe (“rela�vity”)

cartesian (Glue/V) substructural (Gel)

HoTTEST 2019 17

Bridges in the universe (“rela�vity”)

cartesian (Glue/V) substructural (Gel)

HoTTEST 2019 17

Bridges in the universe (“rela�vity”)

cartesian (Glue/V) substructural (Gel)

HoTTEST 2019 18

Want:

Bridges in the universe (“rela�vity”)

HoTTEST 2019 18

Want:

Bridges in the universe (“rela�vity”)

Bernardy, Coquand, & Moulin: add equali�es

HoTTEST 2019 18

Want:

Bridges in the universe (“rela�vity”)

Bernardy, Coquand, & Moulin: add equali�es

Validated by interpreta�on in refined presheaves

HoTTEST 2019 18

Want:

Bridges in the universe (“rela�vity”)

Bernardy, Coquand, & Moulin: add equali�es

Validated by interpreta�on in refined presheaves

Alterna�ve: use univalence?

HoTTEST 2019 19

Parametric cubical type theory (C & Harper)

HoTTEST 2019 19

Parametric cubical type theory (C & Harper)

Structural variables for paths,

substructural variables for bridges

HoTTEST 2019 19

Parametric cubical type theory (C & Harper)

Structural variables for paths,

substructural variables for bridges

Extend Kan opera�ons to make Bridge types Kan

HoTTEST 2019 19

Parametric cubical type theory (C & Harper)

Structural variables for paths,

substructural variables for bridges

Extend Kan opera�ons to make Bridge types Kan

w/ computa�onal seman�cs

HoTTEST 2019 20

Parametric cubical type theory (C & Harper)

HoTTEST 2019 20

Parametric cubical type theory (C & Harper)

HoTTEST 2019 20

Parametric cubical type theory (C & Harper)

HoTTEST 2019 20

Parametric cubical type theory (C & Harper)

HoTTEST 2019 20

Parametric cubical type theory (C & Harper)

(and the other inverse condi�on)

HoTTEST 2019 21

Examples: Church booleans

What can we say about ?

HoTTEST 2019 21

Examples: Church booleans

What can we say about ?

Given define a rela�on.

HoTTEST 2019 21

Examples: Church booleans

What can we say about ?

Given define a rela�on.

Apply at the Gel type for in a fresh .

HoTTEST 2019 21

Examples: Church booleans

What can we say about ?

Given define a rela�on.

Apply at the Gel type for in a fresh .

HoTTEST 2019 21

Examples: Church booleans

What can we say about ?

Given define a rela�on.

Apply at the Gel type for in a fresh .

Extract a witness.

HoTTEST 2019 22

Examples: actual booleans

What are the bridges in ?

HoTTEST 2019 22

Examples: actual booleans

What are the bridges in ?

Define the Gel type corresponding to paths in .

HoTTEST 2019 22

Examples: actual booleans

What are the bridges in ?

Define the Gel type corresponding to paths in .

Map from to by case analysis

HoTTEST 2019 22

Examples: actual booleans

What are the bridges in ?

Define the Gel type corresponding to paths in .

Map from to by case analysisMap from to by case analysis

HoTTEST 2019 22

Examples: actual booleans

What are the bridges in ?

Define the Gel type corresponding to paths in .

Map from to by case analysisMap from to by case analysis

HoTTEST 2019 22

Examples: actual booleans

What are the bridges in ?

Define the Gel type corresponding to paths in .

Map from to by case analysisMap from to by case analysis

Prove this is an equivalence! (iterated parametricity)

HoTTEST 2019 23

Examples: bridge-discrete types

We always have a map from (homogeneous) paths to

bridges

HoTTEST 2019 23

Examples: bridge-discrete types

We always have a map from (homogeneous) paths to

bridges

is bridge-discrete when this is an equivalence

HoTTEST 2019 23

Examples: bridge-discrete types

We always have a map from (homogeneous) paths to

bridges

is bridge-discrete when this is an equivalence

Plays the role of the iden�ty extension lemma

HoTTEST 2019 23

Examples: bridge-discrete types

We always have a map from (homogeneous) paths to

bridges

is bridge-discrete when this is an equivalence

Plays the role of the iden�ty extension lemma

e.g., any func�on from to a bridge-discrete type is

constant

HoTTEST 2019 23

Examples: bridge-discrete types

We always have a map from (homogeneous) paths to

bridges

is bridge-discrete when this is an equivalence

Plays the role of the iden�ty extension lemma

e.g., any func�on from to a bridge-discrete type is

constant

The sub-universe of bridge-discrete types is closed

under all type formers except , including

HoTTEST 2019 23

Examples: bridge-discrete types

We always have a map from (homogeneous) paths to

bridges

is bridge-discrete when this is an equivalence

Plays the role of the iden�ty extension lemma

e.g., any func�on from to a bridge-discrete type is

constant

The sub-universe of bridge-discrete types is closed

under all type formers except , including

THM: is rela�vis�c

HoTTEST 2019 24

Examples: excluded middle

HoTTEST 2019 24

Examples: excluded middle

Consider the weak excluded middle:

HoTTEST 2019 24

Examples: excluded middle

Consider the weak excluded middle:

HoTTEST 2019 24

Examples: excluded middle

Consider the weak excluded middle:

Any func�on must be constant,

because is bridge-discrete.

HoTTEST 2019 24

Examples: excluded middle

Consider the weak excluded middle:

Any func�on must be constant,

because is bridge-discrete.

Thus, .

HoTTEST 2019 24

Examples: excluded middle

Consider the weak excluded middle:

Any func�on must be constant,

because is bridge-discrete.

Thus, .

Corollary: , where

HoTTEST 2019 24

Examples: excluded middle

Consider the weak excluded middle:

Any func�on must be constant,

because is bridge-discrete.

Thus, .

Corollary: , where

(see also: Booij, Escardó, Lumsdaine, & Shulman,

Parametricity, automorphisms of the universe, and excluded middle)

HoTTEST 2019 25

Examples: suspension

HoTTEST 2019 25

Examples: suspension

What are the terms ?

HoTTEST 2019 25

Examples: suspension

What are the terms ?

Completely determined by .

HoTTEST 2019 25

Examples: suspension

What are the terms ?

Completely determined by .

Key Lemma:

HoTTEST 2019 25

Examples: suspension

What are the terms ?

Completely determined by .

Key Lemma:

(case of graph lemma in ordinary parametricity)

HoTTEST 2019 26

Future work

HoTTEST 2019 26

Future work

Connec�on to ordinary cubical type theory

HoTTEST 2019 26

Future work

Connec�on to ordinary cubical type theory

Seman�c: for in cubical type theory

without func�on types, a proof with bridges

gives an element in cubical sets, +??

-

HoTTEST 2019 26

Future work

Connec�on to ordinary cubical type theory

Seman�c: for in cubical type theory

without func�on types, a proof with bridges

gives an element in cubical sets, +??

-

- Syntac�c?

HoTTEST 2019 26

Future work

Connec�on to ordinary cubical type theory

Seman�c: for in cubical type theory

without func�on types, a proof with bridges

gives an element in cubical sets, +??

-

- Syntac�c?

Proving algebraic proper�es of HITs

HoTTEST 2019 26

Future work

Connec�on to ordinary cubical type theory

Seman�c: for in cubical type theory

without func�on types, a proof with bridges

gives an element in cubical sets, +??

-

- Syntac�c?

Proving algebraic proper�es of HITs

?

e.g., what are the terms of type

HoTTEST 2019 26

Future work

Connec�on to ordinary cubical type theory

Seman�c: for in cubical type theory

without func�on types, a proof with bridges

gives an element in cubical sets, +??

-

- Syntac�c?

Proving algebraic proper�es of HITs

?

e.g., what are the terms of type

conjecture: must be constant or iden�ty

Use to prove pentagon, hexagon, etc

Recommended