A (Linear) Spine Calculus Iliano Cervesato iliano@itd.nrl.navy.mil ITT Industries, Inc @ NRL Washington DC http://www.cs.stanford.edu/~iliano/ Joint work with Frank Pfenning Dagstuhl Seminar on Semantic Foundations of Proof Search April 4 th, 2001
Our Motivations Speed up term manipulation (Linear) higher-order unification (Weak-head) normalization Implementation of Twelf, LLF Type reconstruction Logic programming Theorem proving A Linear Spine Calculus 2
Other People s Motivations Study the -calculus Barendregt Proof-terms for sequent calculi Herbelin Schwitchtenberg Speed-up HOU Nadathur A Linear Spine Calculus 3
Roadmap 1. The -calculus o & T 2. The spine calculus S o & T 3. Translations 4. NIL transitions 5. Uniform provability A Linear Spine Calculus 4
Part I The -Calculus o & T A Linear Spine Calculus 5
o & T Terms x, c x:a. M, x^a. M, <M,N>, <> M N, M^N, fst M, snd M Types a, A B, A o B, A & B, T Generally skipped A Linear Spine Calculus 6
o & T (cont d) Simply-typed fragment of LLF Core of Prolog Lolli Biggest fragment of ILL that admits unique normal forms A Linear Spine Calculus 7
η-long Forms?? Simplifies unification / normalization Efficiency Simpler code No types needed Clarity Preserved by β-reduction Easy to build from type declarations η-rule needed for type reconstruction A Linear Spine Calculus 8
Examples c : (a a) o a & a a X X c f^a a. p:a&a. c^f p f^a a. p:a&a. c ^ (x:a.f x) <fst p, snd p> A Linear Spine Calculus 9
Pre-canonical Typing Γ; Δ - M A M is pre-canonical of type A in Γ and Δ Γ; Δ - M A M is pre-atomic of type A in Γ and Δ A Linear Spine Calculus 10
Term Formation Rules Γ, x:a - M B Γ - x:a. M A B Γ - M B A Γ - N B Γ - M N A Γ, x:a - x A A Linear Spine Calculus 11
Tying it Together Γ - M a Γ - M a Γ - M A Γ - M A Forces extensionality Allows β-redices Remove to force β-normal terms A Linear Spine Calculus 12
Examples Not η-long: η-long X f a a a a x:a. f x a a a a a a a β-redex (x:a. f x) c a a a a A Linear Spine Calculus 13
Reductions (x:a. M) N β [N/x]M (x^a. M) ^ N β [N/x]M fst <M,N> β M snd <M,N> β N + congruences A Linear Spine Calculus 14
Properties Church-Rosser Subject reduction Strong normalization Uniqueness of normal forms A Linear Spine Calculus 15
Part II The Spine Calculus S o & T A Linear Spine Calculus 16
Unification X: logical variables in terms Find subst. σ such that M σ = β N σ Algorithms work on the head of M, N Pre-unification Higher-order patterns h M 1 M n A Linear Spine Calculus 17
First Order vs. Higher Order First Order: f(x, g(a), c) = f(b, Y, c) f ; b X ; c ; NIL Higher-Order: (((f X) (g a)) c) = (((f b) Y) c) f c X b A Linear Spine Calculus 18
Objective Devise representation of -terms that allows efficient head access does not penalize F.O. problems allows simple recursive descriptions is not ad-hoc fst ((snd c) ^ x y) c: A & (B C o D & E) A Linear Spine Calculus 19
Idea h M 1 M n h (M 1 ; M n ; NIL) Assoc. fst ((snd c) ^ x y) spine Assoc. end of spine c (π 2 x ;^ y ; π 1 NIL) A Linear Spine Calculus 20
The Spine Calculus Terms x S, x:a. U, x^a. U, <U,V>, <> Spines NIL, V;S, V;^S, π 1 S, π 2 S Heads x, U, c A Linear Spine Calculus 21
Typing Judgments Γ; Δ - U : A Γ; Δ - S : A > a Term U has type A in Γ and Δ S is a spine from heads of type A to terms of type a in Γ and Δ A Linear Spine Calculus 22
Rules for Terms Γ, x:a - U : B Γ - x:a. U : A B Γ, x:a - S : A > a Γ, x:a - x S : a Γ - U : A Γ - S : A > a Γ - U S : a A Linear Spine Calculus 23
Rules for Spines Γ - U : B Γ - S : A > a Γ - U; S : B A > a Γ - NIL : a > a A Linear Spine Calculus 24
β-reductions (x:a. U) (V;S) β (x^a. U) (V;^S) β <U,V> (π 1 S) β [V/x]U S [V/x]U S U S <U,V> (π 2 S) β V S + congruences A Linear Spine Calculus 25
NIL-reduction (x. f x) c β (x. f (x NIL; NIL)) (c NIL; NIL) (f ((c NIL) NIL; NIL)) NIL β NIL f ((c NIL) NIL; NIL) f c NIL f (c NIL; NIL) (U S) NIL NIL U S A Linear Spine Calculus 26
Properties of NIL-reduction Preserves typing (both directions) Strong NIL-normalization Uniqueness of NIL-normal forms Permutes past β-reductions U V NIL U V NIL A Linear Spine Calculus 27 β β
Part III Translations A Linear Spine Calculus 28
Translating to Spine Notation M S U M \ S S U Pre-canonical Pre-atomic accumulator A Linear Spine Calculus 29
Some Rules destructor M S x:a. M S U x:a. U constructor x \ S S x S M \ NIL S H S M S M S H S H M \ S S U S N S U M \ U;S S V M N \ S S V A Linear Spine Calculus 30
Schematically S o & T o & T S o & T NIL Always produces NIL-normal forms A Linear Spine Calculus 31
Properties of the Translation Sound w.r.t. typing Sound w.r.t. reducibility, but M N β S S V U V NIL β A Linear Spine Calculus 32
Translating from Spine Notation M S U Pre-canonical S \ N S M Pre-atomic accumulator A Linear Spine Calculus 33
Some Rules U S M x:a. U S x:a. M S \ x S M U S N S \ N S M x S S M U S S M NIL \ M S M U S M S \ N M U; S \ N S M S M A Linear Spine Calculus 34
Schematically S o & T o & T NIL Identifies NIL-equivalent terms A Linear Spine Calculus 35
Properties of the Translation Weak inverse of S o & T S o & T Sound w.r.t. typing NIL Weak completeness of S and S Sound w.r.t. reductions Weak completeness of S and S A Linear Spine Calculus 36
Properties of the Spine Calculus Church-Rosser Subject reduction Strong normalization β and NIL reductions Uniqueness of normal forms A Linear Spine Calculus 37
Down to Earth Empirical evaluation Efficiency improvement? Logical status of spine NIL-reduction Logical status of spine calculus A Linear Spine Calculus 38
The Twelf / LLF Experience Noticeable efficiency gains (not only spines) Extends to dependent types Extends to linearity Supports weak normal forms Mixes with explicit substitutions Great for logic programming / compil. A Linear Spine Calculus 39
Part IV NIL Transitions A Linear Spine Calculus 40
A glimpse back to o & T Mismatch between o & T Pre-canonical derivations Γ - M a Γ - M A Γ - M a Γ - M A No trace of rule application A Linear Spine Calculus 41
Explicit Mode Switching M ::= Γ - M a ac M ca M Γ - M A Γ - ac M a Γ - ca M A Witness of rule application A Linear Spine Calculus 42
Reduction Rules (ca (x:a. M)) N β (ca [ca N/x]M) (ca (x^a. M)) ^ N β (ca [ca N/x]M) fst (ca <M,N>) β (ca M) snd (ca <M,N>) β (ca N) β ca (ac M) M (coercion) A Linear Spine Calculus 43
Updating the translation Coercion mapped to NIL-reduction The translations are now exact o & T S o & T NIL ca-ac A Linear Spine Calculus 44
Schematically S o & T o & T ca-ac S o & T NIL o & T ca-ac A Linear Spine Calculus 45
Part V Uniform Proofs A Linear Spine Calculus 46
Uniform Sequent Derivations 1. Apply right rules till RHS a is atomic 2. Chose focus A from lhs 3. Apply left rules till A matches a 4. Repeat Abstract logic programing languages are complete w.r.t. uniform provability A Linear Spine Calculus 47
Intuitionistic Implicational Logic Γ, A B Γ, A A a Γ A B Γ, A a Γ B Γ A a Γ B A a Γ a a Γ A Γ A a Γ a A Linear Spine Calculus 48
Recovering the Spine Calculus Γ, x:a - U : B Γ - x:a. U : A B Γ - U : B Γ - S : A > a Γ - U; S : B A > a Γ, x:a - S : A > a Γ, x:a - x S : a Γ - NIL : a > a Γ - U : A Γ - S : A > a Γ - U S : a A Linear Spine Calculus 49
Extending the Curry-Howard Iso. ND SC Uniform logic Curry-Howard Curry-Howard S S S Term calculi A Linear Spine Calculus 50
Beyond Uniform Provability Howard [ 69] Indirect reference Huet [ 89] The Constructive Machine Herbelin [ 95] LJT : implic. int. logic with focus No η-long forms: spines concatenation Interprets cut as explicit substitutions A Linear Spine Calculus 51
Beyond (cont d) Dyckhoff & Pinto [ 98, 99, 01] Refines Herbelin s work Explicit substitutions Schwichtenberg [ 97] Also and No focus: commuting conversions No concatenation / substitutions A Linear Spine Calculus 52
Details Tech. Report www.cs.stanford.edu/~iliano/byyear/#1997 Forthcoming paper 2001? A Linear Spine Calculus 53