nominal completion for rewrite systems with binders
play

Nominal Completion for Rewrite Systems with Binders Maribel Fern - PowerPoint PPT Presentation

Nominal Completion for Rewrite Systems with Binders Maribel Fern andez Kings College London July 2012 Joint work with Albert Rubio M. Fern andez Nominal Completion for Rewrite Systems with Binders Summary Motivations Nominal


  1. Nominal Completion for Rewrite Systems with Binders Maribel Fern´ andez King’s College London July 2012 Joint work with Albert Rubio M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  2. Summary Motivations Nominal Rewriting Closed nominal rules Confluence and Termination Completion Future work M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  3. First-order languages vs. languages with binders First-order data structures: numbers, lists, trees, etc. available in most programming languages. Few languages provide data structures with binding, needed in type checkers, program analysers, compilers, etc. M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  4. Binding operators: Examples Some concrete examples of binding operators (informally): • Operational semantics: let a = N in M − → (fun a . M ) N M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  5. Binding operators: Examples Some concrete examples of binding operators (informally): • Operational semantics: let a = N in M − → (fun a . M ) N • π -calculus: P | ν a . Q → ν a . ( P | Q ) ( a �∈ fv( P )) M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  6. Binding operators: Examples Some concrete examples of binding operators (informally): • Operational semantics: let a = N in M − → (fun a . M ) N • π -calculus: P | ν a . Q → ν a . ( P | Q ) ( a �∈ fv( P )) • Logic equivalences: P and ( ∀ x . Q ) ⇔ ∀ x ( P and Q ) ( x �∈ fv( P )) M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  7. Binders - α -equivalence Binding operators are defined modulo renaming of bound variables, i.e., α -equivalence. Example: In ∀ x . P the variable x can be renamed. • α -conversion is implicit, but ∀ x . P � = α ∀ y . P — x may occur in P . M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  8. Binders - α -equivalence Binding operators are defined modulo renaming of bound variables, i.e., α -equivalence. Example: In ∀ x . P the variable x can be renamed. • α -conversion is implicit, but ∀ x . P � = α ∀ y . P — x may occur in P . • ∀ x . P = α ∀ y . P { x �→ y } Substitution of a bound name by a term has to avoid capture of other bound names: y fresh? M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  9. Binders - α -equivalence Binding operators are defined modulo renaming of bound variables, i.e., α -equivalence. Example: In ∀ x . P the variable x can be renamed. • α -conversion is implicit, but ∀ x . P � = α ∀ y . P — x may occur in P . • ∀ x . P = α ∀ y . P { x �→ y } Substitution of a bound name by a term has to avoid capture of other bound names: y fresh? • Formal definition. There are several alternatives. M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  10. Formally: Alternatives: • Encode in a first-order rewrite system e.g. use De Bruijn indices, encode alpha using operators such as “lift” and “shift”; explicit substitutions. (-) α -equivalence has to be “implemented” (+) simple notion of substitution, efficient first-order matching M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  11. Formally: Alternatives: • Encode in a first-order rewrite system e.g. use De Bruijn indices, encode alpha using operators such as “lift” and “shift”; explicit substitutions. (-) α -equivalence has to be “implemented” (+) simple notion of substitution, efficient first-order matching • Higher-order rewrite systems (CRS, HRS, ERS, etc.), e.g. app ( lam ([ a ] Z ( a )) , Z ′ ) → Z ( Z ′ ) (+) Binders, functions, implicit α -equivalence (-) Substitution as a meta-operation, using β (-) Unification is undecidable in general M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  12. Alternative: Nominal Approach [Pitts, Gabbay, Urban, ...] Inspired by nominal set theory (Fraenkel-Mostowski). Key ideas: Freshness conditions a # t , name swapping ( a b ) · t . Example: app ( lam ([ a ] Z ) , Z ′ ) subst ([ a ] Z , Z ′ ) → a # M ⊢ ( λ ([ a ] app ( M , a )) → M • Terms with binders • Built-in α -equivalence • Efficient matching and unification algorithms • Simple notion of substitution (“first-order”), non-capturing substitution has to be specified using rewrite rules. • Dependencies of terms on names are implicit. M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  13. Nominal Syntax [Urban,Pitts,Gabbay: TCS’04] • Function symbols: f , g . . . Variables: M , N , X , Y , . . . Atoms: a , b , . . . Swappings: ( a b ) Def. ( a b ) a = b , ( a b ) b = a , ( a b ) c = c Permutations: lists of swappings, denoted π ( Id empty). • Nominal Terms: s , t ::= a | π · X | [ a ] t | f t | ( t 1 , . . . , t n ) Id · X written as X . • Example (ML): var ( a ), app ( t , t ′ ), lam ([ a ] t ), let ( t , [ a ] t ′ ), letrec [ f ]([ a ] t , t ′ ), subst ([ a ] t , t ′ ) Syntactic sugar: a , ( tt ′ ), λ a . t , let a = t in t ′ , letrec fa = t in t ′ , t [ a �→ t ′ ] M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  14. α -equivalence We use freshness to avoid name capture. a # X means a �∈ fv( X ) when X is instantiated. ds ( π, π ′ )# X a ≈ α a π · X ≈ α π ′ · X s 1 ≈ α t 1 · · · s n ≈ α t n s ≈ α t ( s 1 , . . . , s n ) ≈ α ( t 1 , . . . , t n ) fs ≈ α ft s ≈ α t a # t s ≈ α ( a b ) · t [ a ] s ≈ α [ a ] t [ a ] s ≈ α [ b ] t where ds ( π, π ′ ) = { n | π ( n ) � = π ′ ( n ) } • a # X , b # X ⊢ ( a b ) · X ≈ α X M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  15. α -equivalence We use freshness to avoid name capture. a # X means a �∈ fv( X ) when X is instantiated. ds ( π, π ′ )# X a ≈ α a π · X ≈ α π ′ · X s 1 ≈ α t 1 · · · s n ≈ α t n s ≈ α t ( s 1 , . . . , s n ) ≈ α ( t 1 , . . . , t n ) fs ≈ α ft s ≈ α t a # t s ≈ α ( a b ) · t [ a ] s ≈ α [ a ] t [ a ] s ≈ α [ b ] t where ds ( π, π ′ ) = { n | π ( n ) � = π ′ ( n ) } • a # X , b # X ⊢ ( a b ) · X ≈ α X • b # X ⊢ λ [ a ] X ≈ α λ [ b ]( a b ) · X M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  16. Freshness Also defined by induction: π − 1 ( a )# X a #[ a ] s a # b a # π · X a # s 1 · · · a # s n a # s a # s a #( s 1 , . . . , s n ) a # fs a #[ b ] s M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  17. Nominal Rewriting Rewriting on nominal terms. Applications: • equational reasoning on data structures with binding; • algebraic specifications of operators and data structures; • operational semantics of programs; • compilers, program transformations, etc. M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  18. Nominal Rewriting Nominal Rewriting Rules: ∆ ⊢ l → r V ( r ) ∪ V (∆) ⊆ V ( l ) Example: prenex normal forms in first-order logic ⊢ P ∧ ∀ [ a ] Q → ∀ [ a ]( P ∧ Q ) a # P a # P ⊢ ( ∀ [ a ] Q ) ∧ P → ∀ [ a ]( Q ∧ P ) ⊢ P ∨ ∀ [ a ] Q → ∀ [ a ]( P ∨ Q ) a # P a # P ⊢ ( ∀ [ a ] Q ) ∨ P → ∀ [ a ]( Q ∨ P ) a # P ⊢ P ∧ ∃ [ a ] Q → ∃ [ a ]( P ∧ Q ) a # P ⊢ ( ∃ [ a ] Q ) ∧ P → ∃ [ a ]( Q ∧ P ) a # P ⊢ P ∨ ∃ [ a ] Q → ∃ [ a ]( P ∨ Q ) a # P ⊢ ( ∃ [ a ] Q ) ∨ P → ∃ [ a ]( Q ∨ P ) ⊢ ¬ ( ∃ [ a ] Q ) → ∀ [ a ] ¬ Q ⊢ ¬ ( ∀ [ a ] Q ) → ∃ [ a ] ¬ Q Reduction relation generated by (equivariant) nominal matching. M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  19. Nominal matching problem l ≈ α t where V ( l ) ∩ V ( t ) = ∅ has solution (∆ , θ ) if ∆ ⊢ l θ ≈ α t • Nominal matching is decidable [Urban, Pitts, Gabbay 2003] • A solvable problem Pr has a unique most general solution: (Γ , θ ) such that Γ ⊢ Pr θ . • Efficient algorithms: linear in time and space [Calves-F.2008] BTW, nominal unification is quadratic [Calves-F.2010,Levy-Villaret2010]. • But for general NRSs nominal matching is not sufficient: we need Equivariant Nominal Matching — NP [Cheney2004]. • If rules are closed , then nominal matching is sufficient. M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  20. Closed Rules Intuitively: no free names. R ≡ ∇ ⊢ l → r is closed when ( ∇ ′ ⊢ ( l ′ , r ′ )) ? ≈ ( ∇ , A ( R ′ )# V ( R ) ⊢ ( l , r )) has a solution σ (where R ′ is a freshened copy of R ). Given R ≡ ∇ ⊢ l → r and ∆ ⊢ s we write ∆ , A ( R ′ )# V (∆ , s ) ⊢ s R ′ R ∆ ⊢ s → c t when → t and call this closed rewriting . M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  21. Examples The following rules are not closed: g ( a ) → a [ a ] X → X Why? M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

  22. Examples The following rule is closed: a # X ⊢ [ a ] X → X Why? M. Fern´ andez Nominal Completion for Rewrite Systems with Binders

Recommend


More recommend