Cocon: A Type Theory for Defining Logics and Proofs Brigitte - - PowerPoint PPT Presentation

cocon a type theory for defining logics and proofs
SMART_READER_LITE
LIVE PREVIEW

Cocon: A Type Theory for Defining Logics and Proofs Brigitte - - PowerPoint PPT Presentation

Cocon: A Type Theory for Defining Logics and Proofs Brigitte Pientka McGill University Montreal, Canada What are good high-level proof languages that make it easier to mechanize metatheory? What are good high-level proof languages that make


slide-1
SLIDE 1

Cocon: A Type Theory for Defining Logics and Proofs

Brigitte Pientka McGill University Montreal, Canada

slide-2
SLIDE 2

What are good high-level proof languages that make it easier to mechanize metatheory?

slide-3
SLIDE 3

What are good high-level proof languages that make it easier to mechanize metatheory?

slide-4
SLIDE 4

Theory Def. Operational Semantics Type System Model Type Theory ... Logic Type Inference Algorithm Program Transformations

slide-5
SLIDE 5

Theory Def. Operational Semantics Type System Model Type Theory ... Logic Type Inference Algorithm Program Transformations Bisimulation Program Equivalence Completeness Consistency Soundness of Prog. Transform. Decidability of Type Checking Type Safety Metatheory

slide-6
SLIDE 6

Theory Def. Operational Semantics Type System Model Type Theory ... Logic Type Inference Algorithm Program Transformations Bisimulation Program Equivalence Completeness Consistency Soundness of Prog. Transform. Decidability of Type Checking Type Safety Metatheory

Mechanized Metatheory implemented in a proof assistant

slide-7
SLIDE 7

Correct proofs are tricky to write.

On paper:

  • Challenging to keep track of all the details
  • Easy to skip over details
  • Difficult to understand interaction between different features
  • Difficulties increase with size

In a proof assistant:

  • A lot of overhead in building basic infrastructure
  • May get lost in the technical, low-level details
  • Time consuming
  • Experience, experience, experience

2

slide-8
SLIDE 8

Mechanizing Normalization for STLC

“To those that doubted de Bruijn, I wished to prove them wrong, or discover why they were right. Now, after some years and many hundred hours of labor, I can say with some authority: they were right. De Bruijn indices are foolishly difficult for this kind of proof. [. . .] The full proof runs to 3500 lines, although that relies on a further library of 1900 lines of basic facts about lists and sets. [. . .] the cost of de Bruijn is partly reflected in the painful 1600 lines that are used to prove facts about “shifting” and “substitution”.” Ezra Cooper (PhD Student)

https://github.com/ezrakilty/sn-stlc-de-bruijn-coq

3

slide-9
SLIDE 9

Mechanizing Normalization for STLC

“To those that doubted de Bruijn, I wished to prove them wrong, or discover why they were right. Now, after some years and many hundred hours of labor, I can say with some authority: they were right. De Bruijn indices are foolishly difficult for this kind of proof. [. . .] The full proof runs to 3500 lines, although that relies on a further library of 1900 lines of basic facts about lists and sets. [. . .] the cost of de Bruijn is partly reflected in the painful 1600 lines that are used to prove facts about “shifting” and “substitution”.” Ezra Cooper (PhD Student)

https://github.com/ezrakilty/sn-stlc-de-bruijn-coq

  • A. Rossberg, C. Russo, D. Dreyer. F-ing Modules. JFP, 2014

3

slide-10
SLIDE 10

Abstraction, Abstraction, Abstraction

“The motivation behind the work in very-high-level languages is to ease the programming task by providing the programmer with a language containing primitives or abstractions suitable to his problem area. The programmer is then able to spend his effort in the right place; he concentrates on solving his problem, and the resulting program will be more reliable as a result. Clearly, this is a worthwhile goal.”

  • B. Liskov [1974]

4

slide-11
SLIDE 11

Abstraction, Abstraction, Abstraction

“The motivation behind the work in very-high-level languages is to ease the programming task by providing the programmer with a language containing primitives or abstractions suitable to his problem area. The programmer is then able to spend his effort in the right place; he concentrates on solving his problem, and the resulting program will be more reliable as a result. Clearly, this is a worthwhile goal.”

  • B. Liskov [1974]

Goal: A d e p e n d e n t t y p e t h e

  • r

y ( s i m i l a r t

  • C
  • q
  • r

A g d a ) t h a t p r

  • v

i d e s t h e r i g h t a b s t r a c t i

  • n

s f

  • r

c

  • m

p a c t l y a n d e l e g a n t l y d e fi n i n g l

  • g

i c s and proofs.

4

slide-12
SLIDE 12

“To know your future you must know your past.” – G. Santayana

slide-13
SLIDE 13

Back in the 80s...

5

slide-14
SLIDE 14

Back in the 80s...

1987 •

  • R. Harper, F. Honsell, G. Plotkin: A Framework for

Defining Logics, LICS’87 1988 •

  • F. Pfenning and C. Elliott: Higher-Order Abstract

Syntax, PLDI’88

  • LF = Dependently Typed Lambda Calculus (λΠ) serves as

a Meta-Language for representing formal systems

  • Higher-order Abstract Syntax (HOAS) :

Uniformly model binding structures in Object Language with (intensional) functions in LF

5

slide-15
SLIDE 15

Representing Types and Terms in LF – In a Nutshell

Types A, B ::= nat | A ⇒ B Terms M ::= x | lam x:A.M | app M N

6

slide-16
SLIDE 16

Representing Types and Terms in LF – In a Nutshell

Types A, B ::= nat | A ⇒ B Terms M ::= x | lam x:A.M | app M N

LF Representation

  • bj: type.

nat: obj. arr: obj → obj → obj. tm: type. lam: obj → (tm → tm) → tm. app: tm → tm → tm. On Paper (Object Language) In LF (Meta Language) lam x:nat.x lam nat λx.x lam x:nat. (lam x:nat⇒nat.x) lam nat λx.(lam (arr nat nat) λx.x) lam x:nat. (lam f :nat⇒nat.app f x) lam nat λx.(lam (arr nat nat) λf.app f x)

Higher-order Abstract Syntax (HOAS):

  • Uniformly model bindings with (intensional) functions in LF
  • Inherit α-renaming and single substitutions

Model

6

slide-17
SLIDE 17

Uniformly Model Binding Structures using LF Functions

Types A, B ::= nat | A ⇒ B | α | ∀α.A Terms M ::= x | lam x:A.M | app M N | let x = M in N | tlam α.M | . . .

7

slide-18
SLIDE 18

Uniformly Model Binding Structures using LF Functions

Types A, B ::= nat | A ⇒ B | α | ∀α.A Terms M ::= x | lam x:A.M | app M N | let x = M in N | tlam α.M | . . .

LF Representation

  • bj: type.

nat: obj. arr: obj → obj → obj. all: (obj → obj) → obj. tm: type. lam: obj → (tm → tm) → tm. app: tm → tm → tm. let: tm → (tm → tm) → tm. tlam: (obj → tm) → tm. On Paper (Object Language) In LF (Meta Language) tlam α. (lam x:α.x) tlam λa.(lam a λx.x) ∀α.∀β.α ⇒ β all λa.all λb.arr a b 7

slide-19
SLIDE 19

Uniformly Model Binding Structures using LF Functions

Types A, B ::= nat | A ⇒ B | α | ∀α.A Terms M ::= x | lam x:A.M | app M N | let x = M in N | tlam α.M | . . .

LF Representation

  • bj: type.

nat: obj. arr: obj → obj → obj. all: (obj → obj) → obj. tm: type. lam: obj → (tm → tm) → tm. app: tm → tm → tm. let: tm → (tm → tm) → tm. tlam: (obj → tm) → tm. On Paper (Object Language) In LF (Meta Language) tlam α. (lam x:α.x) tlam λa.(lam a λx.x) ∀α.∀β.α ⇒ β all λa.all λb.arr a b

LF = Dependently Typed Lambda Calculus λΠ

  • LF functions only encode variable scope

no recursion, no pattern matching, etc.

  • HOAS trees = Syntax trees with binders
  • Benefit: α-renaming and substitution principles
  • Scales: Model derivation trees
  • Hypothetical derivations as LF functions
  • Parametric derivations as LF functions

7

slide-20
SLIDE 20

Sounds cool. . . can I do this in OCaml or Agda?

slide-21
SLIDE 21

An Attempt in OCaml

OCaml

1 type tm = Lam of (tm -> tm) 2 let apply = function (Lam f) -> f 3 let omega =

Lam (function x -> apply x x)

What happens, when we try to evaluate apply omega omega?

8

slide-22
SLIDE 22

An Attempt in OCaml

OCaml

1 type tm = Lam of (tm -> tm) 2 let apply = function (Lam f) -> f 3 let omega =

Lam (function x -> apply x x)

What happens, when we try to evaluate apply omega omega? It will loop.

8

slide-23
SLIDE 23

An Attempt in OCaml and Agda

OCaml

1 type tm = Lam of (tm -> tm) 2 let apply = function (Lam f) -> f 3 let omega =

Lam (function x -> apply x x)

What happens, when we try to evaluate apply omega omega? It will loop. Agda

data tm : type = lam : (tm → tm) → tm

Violates positivity restriction

8

slide-24
SLIDE 24

An Attempt in OCaml and Agda

OCaml

1 type tm = Lam of (tm -> tm) 2 let apply = function (Lam f) -> f 3 let omega =

Lam (function x -> apply x x)

What happens, when we try to evaluate apply omega omega? It will loop. Agda

data tm : type = lam : (tm → tm) → tm

Violates positivity restriction Functions in OCaml and Agda are opaque (black box).

  • We can observe the result that a function computes
  • We cannot pattern match to inspect the function body

8

slide-25
SLIDE 25
  • OK. . . so, how do we write recursive

programs over with HOAS trees? We clearly want pattern matching, since a HOAS tree is a data structure.

slide-26
SLIDE 26

An Attempt to Compute the Size of a Term

size (lam λx.lam λf. app f x) = ⇒ size (lam λf. app f x) + 1 = ⇒ size (app f x) + 1 + 1 = ⇒ size f + size x + 1 + 1 + 1 = ⇒ + + 1 + 1 + 1

“the whole HOAS approach by its very nature disallows a feature that we regard of key practical importance: the ability to manipulate names of bound variables explicitly in computation and proof. ” [Pitts, Gabbay’97]

9

slide-27
SLIDE 27

Back in 2008. . .

slide-28
SLIDE 28

LF and Holes in HOAS trees – Revisited

In LF (Meta Lang.) lam λx. lam λf.app f x lam λx. lam λf. app f x LF Typing Judgment: Ψ

LF Context

⊢ ⊢ M

LF Term

: A

LF Type

10

slide-29
SLIDE 29

LF and Holes in HOAS trees – Revisited

In LF (Meta Lang.) lam λx. lam λf.app f x lam λx. lam λf. app f x LF Typing Judgment: x:tm

LF Context

⊢ ⊢ lam λf.app f x

LF Term

: tm

LF Type

10

slide-30
SLIDE 30

LF and Holes in HOAS trees – Revisited

In LF (Meta Lang.) lam λx. lam λf.app f x lam λx. lam λf. app f x LF Typing Judgment: x:tm

LF Context

⊢ ⊢ lam λf. app f x

LF Term

: tm

LF Type

11

slide-31
SLIDE 31

LF and Holes in HOAS trees – Revisited

In LF (Meta Lang.) Contextual Type lam λx. lam λf.app f x ⌈x:tm ⊢ tm⌉ lam λx. lam λf. app f x ⌈x:tm, f:tm ⊢ tm⌉ LF Typing Judgment: x:tm

LF Context

⊢ ⊢ lam λf. app f x

LF Term

: tm

LF Type

What is the type of app f x ? – Its type is ⌈x:tm, f:tm ⊢ tm⌉.

11

slide-32
SLIDE 32

Contextual Type Theory [Nanevski, Pfenning, Pientka’08]

Meta Context

h: ⌈x:tm, f:tm ⊢ tm⌉ ; x:tm

LF Context

⊢ ⊢ lam λf . h

  • LF Term

: tm

LF Type

  • h is a contextual variable
  • It has the contextual type ⌈x:tm, f:tm ⊢ tm⌉
  • It can be instantiated with a contextual term ⌈x,f ⊢ app f x⌉
  • Contextual types (⊢ ) reify LF typing derivations (⊢

⊢)

12

slide-33
SLIDE 33

Contextual Type Theory [Nanevski, Pfenning, Pientka’08]

Meta Context

h: ⌈x:tm, f:tm ⊢ tm⌉ ; x:tm

LF Context

⊢ ⊢ lam λf . h

  • LF Term

: tm

LF Type

  • h is a contextual variable
  • It has the contextual type ⌈x:tm, f:tm ⊢ tm⌉
  • It can be instantiated with a contextual term ⌈x,f ⊢ app f x⌉
  • Contextual types (⊢ ) reify LF typing derivations (⊢

⊢) WAIT! . . . whatever we plug in for h may contain free LF variables?

12

slide-34
SLIDE 34

Contextual Type Theory [Nanevski, Pfenning, Pientka’08]

Meta Context

h: ⌈y:tm, g:tm ⊢ tm⌉ ; x:tm

LF Context

⊢ ⊢ lam λf . h

  • LF Term

: tm

LF Type

  • h is a contextual variable
  • It has the contextual type ⌈y:tm, g:tm ⊢ tm⌉
  • It can be instantiated with a contextual term ⌈y,g ⊢ app g y⌉
  • Contextual types (⊢ ) reify LF typing derivations (⊢

⊢) WAIT! . . . whatever we plug in for h may contain free LF variables? and we want it to be stable under α-renaming . . .

12

slide-35
SLIDE 35

Contextual Type Theory [Nanevski, Pfenning, Pientka’08]

Meta Context

h: ⌈y:tm, g:tm ⊢ tm⌉ ; x:tm

LF Context

⊢ ⊢ lam λf . h[x/y, f/g]

  • LF Term

: tm

LF Type

  • h is a contextual variable
  • It has the contextual type ⌈y:tm, g:tm ⊢ tm⌉
  • It can be instantiated with a contextual term ⌈y,g ⊢ app g y⌉
  • Contextual types (⊢ ) reify LF typing derivations (⊢

⊢) WAIT! . . . whatever we plug in for h may contain free LF variables? and we want it to be stable under α-renaming . . . Solution: Contextual variables are associated with LF substitutions

12

slide-36
SLIDE 36

Contextual Type Theory1 (CTT) [Nanevski, Pfenning, Pientka’08]

Meta Context (global)

Γ ; Ψ

LF Context (local)

⊢ ⊢ M

LF Term

: A

LF Type

LF Variable Contextual Variable x:A ∈ Ψ Γ; Ψ ⊢ ⊢ x : A x : ⌈Φ ⊢ A⌉ ∈ Γ Γ; Ψ ⊢ ⊢ σ : Φ Γ; Ψ ⊢ ⊢ x[σ]

  • Closure

: [σ]A

  • Apply subst. σ

1Footnote for nerds: CTT is a generalization of modal S4.

13

slide-37
SLIDE 37

The Tip of the Iceberg: Beluga

[POPL’08, POPL’12, ICFP’16,. . .] Main Proof E i g e n v a r i a b l e s Hypothesis Context Variables Renaming Derivation Tree Substitution Scope Binding Contextual Logical Framework LF Γ; Ψ ⊢ ⊢ M : A Proofs as Functional Programs Γ ⊢ ⊢ t : T Terms t ::= ⌈Ψ ⊢ M⌉ | . . . Types T ::= ⌈Ψ ⊢ A⌉ | . . .

14

slide-38
SLIDE 38

Revisiting the program s✐③❡

size ⌈ ⊢ lam λx.lam λf. app f x⌉ = ⇒ size ⌈x ⊢ lam λf. app f x⌉ + 1 = ⇒ size ⌈x,f ⊢ app f x⌉ + 1 + 1 = ⇒ size ⌈x,f ⊢ f⌉ + size ⌈x,f ⊢ x⌉ + 1 + 1 + 1 = ⇒ + + 1 + 1 + 1

15

slide-39
SLIDE 39

Revisiting the program s✐③❡

size ⌈ ⊢ lam λx.lam λf. app f x⌉ = ⇒ size ⌈x ⊢ lam λf. app f x⌉ + 1 = ⇒ size ⌈x,f ⊢ app f x⌉ + 1 + 1 = ⇒ size ⌈x,f ⊢ f⌉ + size ⌈x,f ⊢ x⌉ + 1 + 1 + 1 = ⇒ + + 1 + 1 + 1

Corresponding program:

size : Πγ:ctx. ⌈γ ⊢ tm⌉ → int size ⌈γ ⊢ #p⌉ = 0 size ⌈γ ⊢ lam λx. M⌉ = size ⌈γ,x ⊢ M⌉ + 1 size ⌈γ ⊢ app M N⌉ = size ⌈γ ⊢ M⌉ + size ⌈γ ⊢ N⌉ + 1;

  • Abstract over context γ and introduce special variable pattern #p
  • Higher-order pattern matching [Miller’91]

15

slide-40
SLIDE 40

What Programs / Proofs Can We Write?

  • Certified programs:

Type-preserving closure conversion and hoisting [CPP’13]

Joint work with O. Savary-B´ elanger, S. Monnier

  • Inductive proofs:

Logical relations proofs (Kripke-style) [MSCS’18]

Joint work with A. Cave

POPLMark Reloaded: Strong Normalization for STLC using Kripke-style Logical Relations

Joint work with A. Abel, G. Allais, A. Hameer, A. Momigliano, S. Sch¨ afer, K. Stark

  • Coinductive proofs:

Bisimulation proof using Howe’s Method [MSCS’18]

Joint work with D. Thibodeau and A. Momigliano

16

slide-41
SLIDE 41

Sounds cool. . . but how can we get this into type theories (like Agda)?

slide-42
SLIDE 42

The Essence of the Problem

Meta Context (global)

Γ ; Ψ

LF Context (local)

⊢ ⊢ M

LF Term

: A

LF Type

The strict separation between contextual LF and computations means we cannot embed computation terms directly. Contextual Variable Rule x : ⌈Φ ⊢ A⌉ ∈ Γ Γ; Ψ ⊢ ⊢ σ : Φ Γ; Ψ ⊢ ⊢ x[σ]

  • Closure

: [σ]A

  • Apply subst. σ

17

slide-43
SLIDE 43

The Essence of the Problem and its Solution?

Meta Context (global)

Γ ; Ψ

LF Context (local)

⊢ ⊢ M

LF Term

: A

LF Type

What if we did? Rule for Embedding Computations Γ ⊢ ⊢ t : ⌈Φ ⊢ A⌉ Γ; Ψ ⊢ ⊢ σ : Φ Γ; Ψ ⊢ ⊢ ⌊t⌋σ

  • Closure

: [σ]A

  • Apply subst. σ

17

slide-44
SLIDE 44

A Type Theory for Defining Logics and Proofs [LICS’19]

Joint work with A. Abel, F. Ferreira, D. Thibodeau, R. Zucchini

  • Hierarchy of universes and type-level computation
  • Writing proofs about functions (such as size)

LF (intensional) Γ; Ψ ⊢ ⊢ M : A Computation (extensional) Γ ⊢ ⊢ t : τ q u

  • t

e / b

  • x

⌈ Ψ ⊢ M ⌉ u n q u

  • t

e / u n b

  • x

⌊ t ⌋

σ

see our LICS’19 paper and the extended report for the technical development of the normalization proof.

18

slide-45
SLIDE 45

Sketch: Translation Between STLC and CCC

STLC

tm: obj → type tUnit: tm one. tPair: tm A → tm B → tm (cross A B). tFst : tm (cross A B) → tm A. tSnd : tm (cross A B) → tm B. tLam : (tm A → tm B) → tm (arrow A B). tApp : tm (arrow A B) → tm A → tm B.

Cartesian Closed Categories (CCC)

mor : obj → obj → type. id : mor A A. @ : mor B C → mor A B → mor A C. drop: mor A one. fst : mor (cross A B) A. snd : mor (cross A B) B. pair: mor A B → mor A C → mor A (cross B C). app : mor (cross (arrow B C) B) C. cur : mor (cross A B) C → mor A (arrow B C).

i t m

19

slide-46
SLIDE 46

Sketch: Translation Between STLC and CCC

STLC tm: obj → type. Cartesian Closed Categories (CCC) mor:obj → obj → type itm

A concrete example: itm ⌈ ⊢ tLam λx. tLam

λf. tApp f x⌉

= ⇒∗ itm ⌈x:tm A,f:tm (arrow A B) ⊢ tApp f x⌉

20

slide-47
SLIDE 47

Sketch: Translation Between STLC and CCC

STLC tm: obj → type. Cartesian Closed Categories (CCC) mor:obj → obj → type itm

A concrete example: itm ⌈ ⊢ tLam λx. tLam

λf. tApp f x⌉

= ⇒∗ itm ⌈x:tm A,f:tm (arrow A B) ⊢ tApp f x⌉ Translate an LF context γ to cross product:

ictx:Πγ:ctx.⌈ ⊢ obj⌉

Example: ictx (x1:tm A1, x2:tm A2) =

⇒ (cross (cross one

A1) A2)

20

slide-48
SLIDE 48

Sketch: Translation Between STLC and CCC

STLC tm: obj → type. Cartesian Closed Categories (CCC) mor:obj → obj → type itm

A concrete example: itm ⌈ ⊢ tLam λx. tLam

λf. tApp f x⌉

= ⇒∗ itm ⌈x:tm A,f:tm (arrow A B) ⊢ tApp f x⌉ Translate an LF context γ to cross product:

ictx:Πγ:ctx.⌈ ⊢ obj⌉

Example: ictx (x1:tm A1, x2:tm A2) =

⇒ (cross (cross one

A1) A2)

Translate STLC to CCC

itm:Πγ:ctx.ΠA:⌈ ⊢ obj⌉.⌈γ ⊢ tm ⌊A⌋⌉ → ⌈ ⊢ mor ⌊ictx γ⌋ ⌊A⌋⌉

20

slide-49
SLIDE 49

Translate an LF context γ to cross product

ictx:Πγ:ctx.⌈ ⊢ obj⌉ fn · = ⌈ ⊢ one⌉ | γ, x:tm ⌊A⌋ = ⌈ ⊢ cross ⌊ictx γ⌋ ⌊A⌋⌉;

Example: ictx (x1:tm A1, x2:tm A2) =

⇒ (cross (cross one A1) A2)

21

slide-50
SLIDE 50

Translate an LF context γ to cross product

ictx:Πγ:ctx.⌈ ⊢ obj⌉ fn · = ⌈ ⊢ one⌉ | γ, x:tm (⌊A⌋ with ·) = ⌈ ⊢ cross ⌊ictx γ⌋ ⌊A⌋⌉;

Example: ictx (x1:tm A1, x2:tm A2) =

⇒ (cross (cross one A1) A2)

22

slide-51
SLIDE 51

Translate STLC to CCC

itm:Πγ:ctx.ΠA:⌈ ⊢ obj⌉.⌈γ ⊢ tm ⌊A⌋⌉ → ⌈ ⊢ mor ⌊ictx γ⌋ ⌊A⌋⌉

23

slide-52
SLIDE 52

Translate STLC to CCC

itm:Πγ:ctx.ΠA:⌈ ⊢ obj⌉.⌈γ ⊢ tm (⌊A⌋ with·)⌉ → ⌈ ⊢ mor ⌊ictx γ⌋ ⌊A⌋⌉

23

slide-53
SLIDE 53

Translate STLC to CCC

itm:Πγ:ctx.ΠA:⌈ ⊢ obj⌉.⌈γ ⊢ tm (⌊A⌋ with·)⌉ → ⌈ ⊢ mor ⌊ictx γ⌋ ⌊A⌋⌉

Idea: Write a recursive function pattern matching on m

fn ⌈γ ⊢# p⌉ = ivar γ p | ⌈γ ⊢ tUnit⌉ = ⌈ ⊢ drop⌉ | ⌈γ ⊢ tFst ⌊e⌋⌉ = ⌈ ⊢ fst @ ⌊itm e⌋⌉ | ⌈γ ⊢ tSnd ⌊e⌋⌉ = ⌈ ⊢ snd @ ⌊itm e⌋⌉ | ⌈γ ⊢ tPair ⌊e1⌋ ⌊e2⌋⌉ = ⌈ ⊢ pair ⌊itm e1⌋ ⌊itm e2⌋⌉ | ⌈γ ⊢ tLam λx.⌊e⌋⌉ = ⌈ ⊢ cur ⌊itm e⌋⌉ | ⌈γ ⊢ tApp ⌊e1⌋ ⌊e2⌋⌉ = ⌈ ⊢ app @ pair ⌊itm e1⌋ ⌊itm e2⌋⌉;

23

slide-54
SLIDE 54

Translation of CCC to STLC

Given a morphism between A and B, we build a term of type B with

  • ne variable of type A.

imorph:Π A:⌈ ⊢ obj⌉.Π B:⌈ ⊢ obj⌉. ⌈ ⊢ mor ⌊A⌋ ⌊B⌋⌉ ⇒ ⌈x:tm ⌊A⌋ ⊢ tm ⌊B⌋⌉

24

slide-55
SLIDE 55

Translation of CCC to STLC

Given a morphism between A and B, we build a term of type B with

  • ne variable of type A.

imorph:Π A:⌈ ⊢ obj⌉.Π B:⌈ ⊢ obj⌉. ⌈ ⊢ mor ⌊A⌋ ⌊B⌋⌉ ⇒ ⌈x:tm ⌊A⌋ ⊢ tm (⌊B⌋ with·)⌉

24

slide-56
SLIDE 56

Translation of CCC to STLC

Given a morphism between A and B, we build a term of type B with

  • ne variable of type A.

imorph:Π A:⌈ ⊢ obj⌉.Π B:⌈ ⊢ obj⌉. ⌈ ⊢ mor ⌊A⌋ ⌊B⌋⌉ ⇒ ⌈x:tm ⌊A⌋ ⊢ tm (⌊B⌋ with·)⌉ fn ⌈ ⊢ id⌉ = ⌈x:tm _ ⊢ x⌉ | ⌈ ⊢ drop⌉ = ⌈x:tm _ ⊢ tUnit⌉ | ⌈ ⊢ fst⌉ = ⌈x:tm _ ⊢ tFst x⌉ | ⌈ ⊢ snd⌉ = ⌈x:tm _ ⊢ tSnd x⌉ | ⌈ ⊢ pair ⌊f⌋ ⌊g⌋⌉ = ⌈x:tm _ ⊢ tPair ⌊imorph f⌋ ⌊imorph g⌋⌉ | ⌈ ⊢ cur ⌊f⌋⌉ = ⌈x:tm _ ⊢ tLam λy.(⌊imorph f⌋ with tPair x y)⌉ | ⌈ ⊢ ⌊f⌋ @ ⌊g⌋⌉ = ⌈x:tm _ ⊢ ⌊imorph f⌋ with ⌊imorph g⌋⌉ | ⌈ ⊢ app⌉ = ⌈x:tm _ ⊢ tApp (tFst x) (tSnd x)⌉;

24

slide-57
SLIDE 57

Bridging the Gap between LF and Martin L¨

  • f Type Theory

25

slide-58
SLIDE 58

What we’ve already done – What’s Next

Theory Normalization Decidable equality

  • Categorical semantics
  • . . .

Implementation and Case Studies

  • Build an extension to Coq/Agda/Beluga
  • Case studies:

– Equivalence of STLC and CCC – Homotopy Type Theory (see relations to Crisp Type Theory)

  • Meta-Programming (Tactics)
  • Compilation
  • . . .

26

slide-59
SLIDE 59

Towards More Civilized High-Level Proof Languages

Lesson 1: Contextual types provide a type-theoretic framework to think about syntax trees within a context of assumptions. Lesson 2: Contextual types allow us to mediate and mix between strong (computation-level) function types and weak (HOAS) function types. Lesson 3: Existing proof technique of defining a model for well-typed terms based on their semantic type scales. Taken Together: This is a first step towards bridging the long-standing gap between LF and Martin L¨

  • f type theories.

27