Higher-Order Semantic Labelling for Inductive Datatype Systems Makoto Hamana Gunma University/University of Tokyo Japan PPDP’07 14th July, 2007. 1
Intro: Termination Proof by Syntactic Method Term Rewriting System (TRS) R : fact ( s ( x )) → fact ( x ) ∗ s ( x ) ⊲ Recursive path ordering (RPO) [Dershowitz TCS’82] proves termination (= SN) by using the precedence fact > ∗ > s > 0 2
Intro: Semantic Labelling for TRSs [Zantema’95] Original TRS R : fact ( s ( x )) → fact ( p ( s ( x ))) ∗ s ( x ) p ( s (0)) → 0 p ( s ( s ( x ))) → s ( p ( s ( x ))) ◮ RPO doesn’t work Semantics: Σ -algebra ( N , { fact N , s N , p N : N → N , · · ·} ) Labelled TRS R : fact i +1 ( s ( x )) → fact i ( p ( s ( x ))) ∗ s ( x ) p ( s (0)) → 0 p ( s ( s ( x ))) → s ( p ( s ( x ))) ◮ RPO works! Th. [Zantema’95] TRS R is terminating ⇒ R is terminating. 3
This Work ⊲ About higher-order term rewriting ⊲ Inductive Data Type Systems (IDTSs) & Termination criteria: the General Schema [Blanqui,Jouannaud,Okada TCS’02, RTA’00] ⊲ Difficulty: what is a suitable semantic structure for labelling higher-order rewriting systems? ⊲ Contribution: i. Answer ii. Higher-order semantics labelling iii. Applications 4
Inductive Data Type Systems [Blanqui,Jouannaud,Okada RTA’00, TCS’02] Features: ⊲ Rewrite rules on higher-order terms ⊲ Simple types (up to 2nd-order in this work) ⊲ Inductive types (by conditions of types of constructors) ⊲ Metavariables with arities and substitutions, e.g. ap ( λ ( x.M ( x )) , N ) → M ( N ) 5
Idea: Attach Semantics of Arguments in Rewrite Rules Original R f ( l ) → g ( · · · f ( t ) · · · ) ⇓ ] ρ ( l ′ ) ] ρ ( t ′ ) · · · ) Labelled R → g ( · · · f [ f [ [ l ] [ t ] ( M, ≥ ) : quasi-model ( ∀ ( l → r ) ∈ R . [ [ l ] ] ρ ≥ [ [ r ] ] ρ ) ρ : X → M valuation [ [ − ] ] : T Σ X → M 6
What Kind of Semantics for Higher-Order Labelling? ⊲ TRS: (1st-order) Universal algebra ⊲ IDTS: ?? Higher-order version of universal algebra ⊲ Semantics of Higher-order Rewrite Systems by van de Pol [HOA’93]: hereditary monotone functionals, but not complete for termination. The term model is not a model. ⊲ Need to satisfy several requirements 7
What Kind of Semantics for Higher-Order Labelling? s → R t Semantic labels must reflect: ⊲ contexts ] ( s ′ ) → R g [ ] ( t ′ ) g [ [ s ] [ t ] ⊲ binders ] x ( x. s ′ ) → R λ [ ] x ( x. t ′ ) λ [ [ s ] [ t ] ⊲ substitutions map ( x.F ( x ) , cons ( M, N )) → R cons ( F ( M ) , · · · ) ⇓ · · · → R cons [ ] ( F ( M ) , · · · ) [ F ] ][ [ M ] 8
What Kind of Semantics for Higher-Order Labelling? ⊲ Models of λ -calculus? ⊲ But λ -algebra doesn’t satisfy ξ -rule in general [Plotkin JSL’74] M = N λx.M = λx.N ⊲ Right framework: binding algebras and Σ -monoids [Fiore,Plotkin,Turi LICS’99] with order structure ⊲ Σ -monoid = Σ -algebra + monoid ⊲ Free Σ -monoid = higher-order syntax with metavariables [Hamana APLAS’04] ⊲ Algebraic semantics of higher-order rewriting [Hamana RTA’05] ⊲ Typed binding algebra [Fiore PPDP’02] 9
Semantic Labelling ✲ M into a quasi-model ⊲ An assignment φ : Z ⊲ Labelling map φ L : M Σ Z ✲ M Σ Z φ L ( x ) = x φ L ( z ( � t )) = z ( φ L � t ) φ L ( f ( t 1 , . . . , t l )) = f � � f ( φ L t 1 , . . . , φ L t l ) � φ ∗ ( t 1 ) ,...,φ ∗ ( t l ) � ⊲ Labelling Free Σ -monoid terms M Σ Z l → r ∈ R φ L Σ -m.m. labelling map ❄ ❄ φ L ( l ) → φ L ( r ) ∈ R Σ -monoid labelled terms M Σ Z labelled IDTS 10
Higher-Order Semantic Labelling ⊲ Proposition terms Σ 0 s → R t M φ L labelling map ❄ ❄ φ L ( s ) → ∗ ·→ R φ L ( t ) labelled terms M Σ 0 Decr ⊲ Th. [Higher-order semantic labelling] IDTS R ∪ Decr is terminating R is terminating. ⇒ ⊲ “Decreasing rules” Decr f p ( z 1 , . . . , z l ) → f q ( z 1 , . . . , z l ) for all labels p > q 11
Application 1: Simply-Typed λ x -calculus [Bloo,Rose’95] ( λx.M ) N → M � x := N � ( MN ) � x := K � → M � x := K � N � x := K � if x � = y ( λy.M ) � x := K � → λy.M � x := K � x � x := K � → K if x �∈ FV ( M ) M � x := K � → M ⊲ This doesn’t follow the General Schema: ?? @ > −�− := −� − �− := −� > @ ⊲ Labels help! Semantics · · · simply typed λ -terms evaluating all ex. subst. 12
Application 1: Simply-Typed λ x -calculus ( λx.M ) N → M � x := N � ( MN ) � x := K � → M � x := K � N � x := K � ( λy.M ) � x := K � → λy.M � x := K � if x � = y x � x := K � → K M � x := K � → M if x �∈ FV ( M ) ⊲ Labelled rules ap ( λx.s ) t ( λ ( x.M ( x )) , N ) → M ( x ) � x := N � s [ x := t ] ( ap s t ( M ( x ) , N ( x ))) � x := K � st [ x := u ] → ap st [ x := u ] ( · · · ) for s ( → β ∪ ⊲ ) ∗ t Precedence: ap s > −�− := −� t > ap t > λ ⊲ This follows the General Schema, hence SN ⊲ Point: λ -terms form a quasi-model of λ x -calculus ⊲ NB. Not a termination model (i.e. not giving ’ > ’) but useful 13
Application 2: Labelling with Term Model ⊲ Example: λ x -calculus ⊲ (Restricted) term model is a typical model V , ( → R ∪ ⊲ ) ∗ ) ⊲ Take the full term model ( T Σ Def. [Middeldorp,Ohsaki,Zantema CADE’96] A 1st-order TRS R is precedence terminating if ∃ well-founded order (“precedence”) s.t. f ( � t ) → r ∈ R , f > ∀ g ∈ Fun ( r ) Prop. R SN ⇔ term labelled R ∪ Decr precedence terminating ⊲ TRS ok [MOZ’96] ⊲ IDTS fails – subterm property is not closed under substitutions ⊲ Solid IDTS ok new notion 14
Solid IDTS Def. A term t is solid if for each z ( s 1 , . . . , s n ) in t , . all s i do not contain function symbols Def. IDTS R is solid if i. R consists of solid terms only ii. (about strictly positive inductive types and accessibility of variables) Example i. ap ( λ ( x.M ( x )) , N ) → M ( N ) ii. λ x -calculus Prop. Solid IDTS R SN R ∪ Decr precedence terminating ⇔ 15
Application 3: Modularity with HO-RPS HO Recursive Program Schema (RPS) f ( x 1 . . . x i 1 . z 1 ( x 1 , . . . , x i 1 ) , . . . ) → t Th. Termination is modular for the disjoint union of solid IDTS and solid HO-RPS. Proof Labelling with a term model given by normal forms of HO-RPS and show precedence termination. 16
Summary ⊲ Higher-order semantic labelling for IDTSs using Σ -monoids ⊲ Applications: λ x , modularity ⊲ Introduction of solid property - Reasonable extension of FO case Note ⊲ Almost no property is modular for HO rewriting [van Oostrom’05] ⊲ Signature extension doesn’t preserve SN for HO rewriting ⊲ But solid case is ok 17
Why fails? ⊲ Consider labelling with a term model ⊲ Need to establish the property f ( l ) → r ∈ R f f ( l ) θ ( l ) → r ∈ R for r � t f ( l ) θ → R rθ � tθ Take the order on labels: ( → R ∪ ⊲ ) ∗ - TRS ok - IDTS NG, since by z �→ c z ( f ) ⊲ f ⇒ c � ⊲ f 18
Σ -monoids [Fiore,Plotkin,Turi’99] A Σ -monoid consists of ⊲ a monoid object M = ( M, η, µ ) in the monoidal category ( Set F , • , V) (“substitution prod.”) with ⊲ a Σ -binding algebra α : Σ M → M such that Σ( M ) • M st ✲ Σ( M • M ) Σ µ ✲ Σ M α • M α ❄ ❄ ✲ M M • M µ commutes. 19
Recommend
More recommend