Toward dependent choice: a classical sequent calculus with dependent - - PowerPoint PPT Presentation

toward dependent choice a classical sequent calculus with
SMART_READER_LITE
LIVE PREVIEW

Toward dependent choice: a classical sequent calculus with dependent - - PowerPoint PPT Presentation

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art Toward dependent choice: a classical sequent calculus with dependent types Hugo Herbelin 1 , Etienne Miquey 1,2 1 Team r 2 (INRIA), PPS, Universit e


slide-1
SLIDE 1

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Toward dependent choice: a classical sequent calculus with dependent types

Hugo Herbelin1, ´ Etienne Miquey1,2

1Team πr2 (INRIA), PPS, Universit´

e Paris-Diderot

  • 2Fac. de Ingenier´

ıa, Universidad de la Rep´ ublica, Uruguay

TYPES 2015

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 1/ 19

slide-2
SLIDE 2

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Curry-Howard correspondence

Proof/program correspondence Proof theory Functional programming Proposition Type Deduction rule Typing rule A ⇒ B A → B Γ ⊢ A ⇒ B Γ ⊢ A Γ ⊢ B Γ ⊢ t : A → B Γ ⊢ u : A Γ ⊢ (t)u : B A first extension : Classical logic [Griffin’90] call/cc : ((A ⇒ B) ⇒ A) ⇒ A

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 2/ 19

slide-3
SLIDE 3

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Extending more...

Axiom of Choice ACA : ∀xA∃yBP(x, y) → ∃f A→B∀xAP(x, f (x)) Ingredients : Martin-L¨

  • f’s type theory

Γ, a : A ⊢ p : B Γ ⊢ λa.p : A → B →I Γ, x : T ⊢ p : A Γ ⊢ λx.p : ∀xTA ∀I Γ ⊢ p : A[t/x] Γ ⊢ t : T Γ ⊢ (t, p) : ∃xTA ∃I Γ ⊢ p : ∃xTA(x) Γ ⊢ prf p : A(wit p) ∃E ACA := λH.(λx. wit(Hx),λx. prf(Hx)) : ∀xA∃yBP(x, y) → ∃f A→B∀xAP(x, f (x))

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 3/ 19

slide-4
SLIDE 4

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

... still more ?

ACA := λH.(λx. wit(Hx), λx. prf(Hx)) In classical logic : H0 := callccα(1, φ(throwα(2, p)) : ∃xP(x) the witness may depend on the context, so do the proof ! reducing a term in different contexts, one might reach a contradiction : (wit(ACA H) 0, prf(ACA H) 0)

  • ∃yP(0,y)

(wit H0, prf H0) (1,

P(0,2)

  • p

)

  • ✘✘✘

∃yP(x,y)

idea : we need to share...

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 4/ 19

slide-5
SLIDE 5

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Toward a solution ?

Restriction to countable choice : ACN : ∀xN∃yBP(x, y) → ∃f N→B∀xNP(x, f (x)) Proof : AC := λH.(λn. wit(Hn), λn. prf(Hn))

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 5/ 19

slide-6
SLIDE 6

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Toward a solution ?

Restriction to countable choice : ACN : ∀xN∃yBP(x, y) → ∃f N→B∀xNP(x, f (x)) Proof : AC := λH.(λn.if n = 0 then wit H 0 else λn.if n = 1 then wit H 1 else ... , λn.if n = 0 then prf H 0 else λn.if n = 1 then prf H 1 else ... )

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 5/ 19

slide-7
SLIDE 7

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Toward a solution ?

Restriction to countable choice : ACN : ∀xN∃yBP(x, y) → ∃f N→B∀xNP(x, f (x)) Proof : AC := λH. let H0 = H 0 in let H1 = H 1 in ... (λn.if n = 0 then wit H0 else λn.if n = 1 then wit H1 else ... , λn.if n = 0 then prf H0 else λn.if n = 1 then prf H1 else ... )

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 5/ 19

slide-8
SLIDE 8

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Toward a solution ?

Restriction to countable choice : ACN : ∀xN∃yBP(x, y) → ∃f N→B∀xNP(x, f (x)) Proof : AC := λH. let H∞ = (H 0, H 1, . . . , H n, . . .) in (λn.nth n H∞, λn.nth n H∞)

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 5/ 19

slide-9
SLIDE 9

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Toward a solution ?

Restriction to countable choice : ACN : ∀xN∃yBP(x, y) → ∃f N→B∀xNP(x, f (x)) Proof : AC := λH. let H∞ = cofix0

fn(H n, f (S(n))) in

(λn.nth n H∞, λn.nth n H∞) We can easily adapt to dependent choice Intuitionistic proof !

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 5/ 19

slide-10
SLIDE 10

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

The recipe : dPAω

A formal system : classical : p, q ::= ... | catchα p | throwα p with dependent types :

formulas : A, B ::= ... | [a : A] → B | t = u, terms : t, u ::= ... | wit p, proofs :p, q ::= ... | prf p

a compartimentalization : Definition : Negative-elimination-free Values : V ::= a | () | λx.p | λa.p | (t, p) | (V , V ) | ιi(V ) N, M ::= ... | λa.p | (N, N) | ιi(N) | prf N | let a = M in N | ...

Γ ⊢ p : ∃xTA(x) p Nef Γ ⊢ prf p : A(wit p) Γ ⊢ p : ∃xTA(x) Γ, x : T, a : A ⊢ q : B Γ ⊢ dest p as((x, a)) in q : B

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 6/ 19

Ref : Hugo Herbelin (LICS’12) A Constructive Proof of Dependent Choice, Compatible with Classical Logic

slide-11
SLIDE 11

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

The recipe : dPAω

A formal system : classical : p, q ::= ... | catchα p | throwα p with dependent types :

formulas : A, B ::= ... | [a : A] → B | t = u, terms : t, u ::= ... | wit p, proofs :p, q ::= ... | prf p

a compartimentalization , call-by-value and sharing : p, q ::= ... | let a = q in p with inductive and coinductive constructions : p, q ::= ... | ind t of [p|(x, a).q] | cofixt

bn p

laziness on the cofix

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 6/ 19

Ref : Hugo Herbelin (LICS’12) A Constructive Proof of Dependent Choice, Compatible with Classical Logic

slide-12
SLIDE 12

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Main properties

Subject reduction If Γ ⊢ p : A and p q, then Γ ⊢ q : A. Normalisation If Γ ⊢ p : A then p is normalisable. Conservativity If A is →-ν-wit-∀-free, and ⊢dPAω p : A, then ⊢HAω p : A Consistency dPAω ⊥

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 7/ 19

slide-13
SLIDE 13

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Normalisation by CPS

A translation · : dPAω → λsomething s.t. : (p q) ⇒ (p →+ q) Interest : highlights on negative translation and side effects If we are lucky : update-induction [Berger’04] Difficulties :

− (Continuation+State)-passing-style − Typing ? − Laziness & cofix ? − Manipulation of contexts : let a =

t

cofix

bx

p = D[a] in ⊲ ...

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 8/ 19

CPS : Ariola et al (FLOPS’12) Classical Call-by-Need Sequent Calculi : The Unity of Semantic Artifacts

slide-14
SLIDE 14

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Sequent calculus : λµ˜ µ

Syntax : (Commands) c ::= p | e (Proofs) p, q ::= a | λa.p | µα.c (Contexts) e ::= α | ˜ µa.c | p · e Call-by-value reduction : λa.p | q · e q | ˜ µa.p | e V | ˜ µa.c c[V /a] µα.c | e c[e/α] Typing rules : Γ ⊢ p : A Γ ⊢ e : A⊥

p | e : Γ cut c : (Γ, α : A⊥

⊥)

Γ ⊢ µα.c : A µ c : (Γ, a : A) Γ ⊢ ˜ µa.c : A⊥

⊥ ˜

µ

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 9/ 19

Ref : Curien/Herbelin (ICFP’00) The duality of computation,

slide-15
SLIDE 15

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Adding sharing

Syntax : (Commands) c ::= p | eτ (Proofs) p, q ::= a | λa.p | µα.c (Contexts) e ::= α | ˜ µa.c | p · e (Environments) τ ::= · | [a = p]τ Call-by-value reduction : λa.p | q · eτ q | ˜ µa.p | eτ µα.c | eτ c[e/α]τ V | ˜ µa.cτ c[a = V ]τ a | Fτ ′[a = p]τ p | Fτ ′[a = p]τ Typing rules : ... + p | eτ : (Γ) ::= τ(p) | τ(e) : (Γ)

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 10/ 19

Ref : Ariola et al (FLOPS’12) Classical Call-by-Need Sequent Calculi : The Unity of Semantic Artifacts

slide-16
SLIDE 16

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Adding cofix

Syntax : (Commands) c ::= p | eτ (Proofs) p, q ::= a | λa.p | µα.c | cofixt

bx p

(Contexts) e ::= α | ˜ µa.c | p · e (Environments) τ ::= · | [a = p]τ Call-by-value reduction :

. . . cofixt

bx p | ˜

µa.cτ ′τ cτ ′[a = cofixt

bx p]τ

a | Fτ ′[a = cofixt

bx p]τ p[t/x][λy. cofixy bx p/b] | ˜

µa.a | Fτ ′τ

Typing rules : +

Γ ⊢ t : T Γ, f : T → N, x : T, b : ∀yf (y) = 0 ⊢ p : A f positive in A Γ ⊢ cofixt

bx p : νt fxA

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 11/ 19

slide-17
SLIDE 17

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Adding dependent types

Syntax : (Commands) c ::= p | eτ (Terms) t, u ::= x | 0 | S(t) | λx.t | t u | wit p (Proofs) p, q ::= ... | cofixt

bx p | λx.p | (t, p) | prf p

(Contexts) e ::= α | ˜ µa.c | p · e | t · e (Environments) τ ::= · | [a = p]τ Call-by-value reduction : . . . prf p | eτ p | ˜ µa.prf a | eτ prf a | eτ ′[a = (t, p)]τ p | eτ ′[a = (t, p)]τ Typing rules : Γ ⊢ p : A[t/x] Γ ⊢ t : T Γ ⊢ (t, p) : ∃xTA ∃I Γ ⊢ p : ∃xTA(x) p Nef Γ ⊢ prf p : A(wit p) prf

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 12/ 19

slide-18
SLIDE 18

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Last but not least

Syntax : (Commands) c ::= p | eτ (Terms) t, u ::= ... (Proofs) p, q ::= ... | (a1, a2) | ιi(p) | subst p q | refl (Contexts) e ::= ... | ˜ µ(a1, a2).c | ˜ µ[a1.c1|a2.c2] (Environments) τ ::= · | [a = p]τ Call-by-value reduction :

. . . (p1, p2) | ˜ µa.cτ p1 | ˜ µa1.p2 | ˜ µa2.c[a = (a1, a2)]τ

Typing rules : Γ ⊢ p : t = u Γ ⊢ q : B[t/x] Γ ⊢ subst p q : B[u/x] subst Γ ⊢ t : T Γ ⊢ refl : t = t refl

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 13/ 19

slide-19
SLIDE 19

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Does this work ?

Γ, a : A ⊢ p : B[a] Γ ⊢ λa.p : [a : A] → B Γ ⊢ q : A Γ ⊢ e : B[q]⊥

q Nef Γ ⊢ q · e : ([a : A] → B)⊥

λa.p | q · e : Γ cut

  • Γ ⊢ q : A

Γ, a : A ⊢ p : B[a] Γ, a : A ⊢ e : B[q]⊥

⊥; {a|q}

p | e : Γ, a : A; {a|q} cut Γ ⊢ ˜ µa.p | e : A⊥

⊥; {.|q}

˜ µ q | ˜ µa.p | e : Γ; {·|·} cut

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 14/ 19

slide-20
SLIDE 20

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

A type system with dependencies list

c : (Γ, α : A⊥

⊥)

Γ ⊢ µα.c : A µ c : (Γ, a : A; {a|p}ε) Γ ⊢ ˜ µa.c : A⊥

⊥; {·|p}ε

˜ µ Γ ⊢ p1 : A Γ ⊢ p2 : B Γ ⊢ (p1, p2) : A ∧ B ∧I c : Γ, a1 : A1, a2 : A2; {(a1, a2)|p}ε Γ ⊢ ˜ µ(a1, a2).c : (A1 ∧ A2)⊥

⊥; {·|p}ε

∧E Γ ⊢ p : Aε+ Γ ⊢ e : A⊥

⊥ ε−; {·|p}ε

p | e : (Γ; ε) cut

where : p | eτ : (Γ) ::= τ(p) | τ(e) : (Γ) A{p|q}ε+ := A[p/•]ε+, q / ∈ Nef → •, p / ∈ A A{p|q}ε− := A[q/•]ε−, q / ∈ Nef → •, p / ∈ A

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 15/ 19

slide-21
SLIDE 21

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Properties

Safe proof substitution Assume Γ, ∆ ⊢ p : A, p Nef then we have : Γ, a : A, ∆ ⊢ q : B ⇒ Γ, ∆[p/a] ⊢ q[p/a] : B[p/a] (+ same property for contexts/commands/terms typing) The same holds for terms and contexts subtitutions. Subject reduction If c : Γ; {·|·} and c c′, then c : Γ; {·|·}.

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 16/ 19

slide-22
SLIDE 22

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

A translation from dPAω

λa.p := λa.p (p)q := µα.p | q · α let a = p in q := µα.p | ˜ µa.q | α (p, q) := (p, q) split p as (a1, a2) in q := µα.p | ˜ µ(a1, a2).q | α Typing preservation If ⊢dPAω p : A, then ⊢dLPAω p : A Remember :

ACN := λH. let H∞ = cofix0

bn(H n, b(S(n))) in(λn.nth n H∞, λn.nth n H∞)

Corollary ⊢ ACN : ∀x∃yP(x, y) → ∃f ∀xP(x, f (x))

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 17/ 19

slide-23
SLIDE 23

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Where are we now ?

dPAω Sequent calculus (¯ λµ˜ µ) λ-calculus Subject reduction Subject reduction Normalisation typing/reduction preservation typing ? reduction ?

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 18/ 19

slide-24
SLIDE 24

Curry-Howard Axiom of Dependent Choice Sequent calculus State of the art

Thank you for your attention

´ Etienne Miquey Toward dependent choice: a classical sequent calculus with dependent types 19/ 19