a metalanguage for animating inductive definitions
play

A metalanguage for animating inductive definitions M. R. Lakin - PowerPoint PPT Presentation

A metalanguage for animating inductive definitions M. R. Lakin University of Cambridge Computer Laboratory 20 February 2008 M. R. Lakin (Cambridge) MLSOS 20 February 2008 1 / 33 Talk outline Motivationschematic rule-based definitions


  1. A metalanguage for animating inductive definitions M. R. Lakin University of Cambridge Computer Laboratory 20 February 2008 M. R. Lakin (Cambridge) MLSOS 20 February 2008 1 / 33

  2. Talk outline Motivation—schematic rule-based definitions 1 Brief introduction to MLSOS 2 Translating inductive definitions into MLSOS 3 Conclusions 4 Related & Future work 5 M. R. Lakin (Cambridge) MLSOS 20 February 2008 2 / 33

  3. Rule-based definitions A relation is just a set of mathematical objects. We usually define infinite relations using inference rules, as the least set closed under the rules. This involve schematic patterns which we instantiate somehow to produce the underlying mathematical objects. For example: even n even 0 even n + 2 As we can see, this is straightforward in the first-order case. As usual, things get more complicated when we introduce binders. M. R. Lakin (Cambridge) MLSOS 20 February 2008 3 / 33

  4. Definitions involving binders Notions of instantiation are no longer straightforward. Suppose we have a schematic term λ x . λ y . Var x where x and y are schematic pattern variables. Given concrete atoms a and b , which of the following are valid instantiations of that pattern? λ a . λ b . Var a 1 λ a . λ a . Var a 2 M. R. Lakin (Cambridge) MLSOS 20 February 2008 4 / 33

  5. Animating rule-based definitions We are not concerned with proof, but with animating rule-based inductive definitions. This means you get an executable prototype (almost) for free when you define your inductive rules. The prototype does proof-search over the rules, in order to model your programming language. I will present the metalanguage for defining these prototypes later... ..first I will present a formal model of inductive rule-based definitions, which hopefully models informal practice reasonably well. M. R. Lakin (Cambridge) MLSOS 20 February 2008 5 / 33

  6. A language of schematic rules We define a language of schematic patterns, p : p ::= x | () | ( p 1 , . . . , p n ) | K p | � � x � � p ...which are used to build up formulae, ϕ : ϕ ::= R p | x = / = x ′ | ϕ 1 ∧ . . . ∧ ϕ n | true . A nominal inductive definition, N , is a (finite, well-formed) set of schematic rules, R , of the form: ϕ ( R ) R p M. R. Lakin (Cambridge) MLSOS 20 February 2008 6 / 33

  7. Term model semantics We give a semantics to N in terms of ground instantiations, γ , of variables in patterns to produce α -equivalence classes [ g ] α of ground nominal terms: γ ( x ) = { a } γ ⊙ p = [ g ] α γ ⊙ x = γ ( x ) γ ⊙ ( � � x � � p ) = [ � � a � � g ] α γ ⊙ () = { () } γ ⊙ p = [ g ] α ∀ i ∈ { 1 , . . . , n } . γ ⊙ p i = [ g i ] α γ ⊙ (K p ) = [K g ] α γ ⊙ ( p 1 , . . . , p n ) = [ ( g 1 , . . . , g n ) ] α Note that, at this point, distinct variables may be instantiated with the same atom—even if in abstraction position. M. R. Lakin (Cambridge) MLSOS 20 February 2008 7 / 33

  8. Term model semantics For a definition which defines relations R 1 , . . . , R n , we say that a ground term model, H , is an n -tuple ( H 1 , . . . , H n ) of models—one per relation symbol. We define a satisfaction relation H | = γ ϕ as follows: ∀ i ∈ { 1 , . . . , n } . H | = γ ϕ i H | = γ true H | = γ ( ϕ 1 ∧ . . . ∧ ϕ n ) γ ⊙ p = [ g ] α [ g ] α ∈ H i H | = γ ( R i p ) γ ( x ′ ) = { a ′ } a � = a ′ γ ( x ) = { a } H | = γ ( x = / = x ′ ) M. R. Lakin (Cambridge) MLSOS 20 February 2008 8 / 33

  9. Closure under rules To get the set of H which satisfy a definition N , we close under the schematic rules, as follows. ( H | = γ ϕ ) ⇒ ( H | = γ R p ) H | = γ ( ϕ ⇒ R p ) ∀R ∈ N . ∀ γ. P ( R , γ ) ⇒ H | = γ R H | = N The predicate P ( R , γ ) restricts the instantiations that can be required to a particular set of schematic rules. M. R. Lakin (Cambridge) MLSOS 20 February 2008 9 / 33

  10. Restrictions on instantiation There are various choices for predicate P , e.g. P ( R , γ ) � true 1 (any instantiation at all is permitted) P ( R , γ ) � ∀ x , y ∈ av( R ) . x � = y ⇒ γ ( x ) � = γ ( y ) 2 ( γ must be injective on names in abstraction position) P ( R , γ ) � ∀ x , y ∈ vars( R ) . 3 sort ( x ) = sort ( y ) = α ∧ x � = y ⇒ γ ( x ) � = γ ( y ) ( γ must be injective on all names of atom sort) The choice here is largely personal. However, if (1) were chosen, then proof-search using nominal matching would probably not be complete (cf λ a . λ b . a vs λ a . λ a . a ). M. R. Lakin (Cambridge) MLSOS 20 February 2008 10 / 33

  11. An example rule An example: the β -rule (using syntactic sugar for substitution). t ′ 1 [ t ′ 2 / x ] ≡ t 3 ( β ) beta ((App (Lam � � x � � t 1 ) , t 2 ) , t 3 ) Note that the names and λ -terms are both drawn represented using the same syntactic class of schematic variables. We shall see later how they are actually implemented in the metalanguage. M. R. Lakin (Cambridge) MLSOS 20 February 2008 11 / 33

  12. Talk outline Motivation—schematic rule-based definitions 1 Brief introduction to MLSOS 2 Translating inductive definitions into MLSOS 3 Conclusions 4 Related & Future work 5 M. R. Lakin (Cambridge) MLSOS 20 February 2008 12 / 33

  13. What is MLSOS? A minimal calculus for animating rule-based inductive definitions involving binders. A little functional/logic programming language which extends the functionality of FreshML. MLSOS offers operations useful for proof-search computation over inductive definitions, e.g.: support for binders using nominal techniques, 1 pattern-matching using nominal unification 2 (with a few extra rules for name inequality), 3 generation of fresh atoms and metavariables, and 4 branching constructs for proof-search. 5 M. R. Lakin (Cambridge) MLSOS 20 February 2008 13 / 33

  14. MLSOS grammar Nominal Arities, σ ::= α atom sort, | δ data sort, | 1 unit type, | σ 1 * · · · * σ n n -tuple, | � � α � � σ abstraction type. Types, τ ::= σ nominal arity, | ans answer type, | τ → τ ′ function type. M. R. Lakin (Cambridge) MLSOS 20 February 2008 14 / 33

  15. MLSOS grammar Constraints, c ::= v =:= v ′ equality constraint, | a # v freshness constraint, | v = / = v ′ name inequality constraint. Values, v ::= x value identifier, | π X suspension, | () unit, | ( v 1 , . . . , v n ) n -tuple, fun f ( x : τ ) : τ ′ = e | recursive function, | yes success, | K v data construction, | a atom, | � � a � � v atom abstraction. M. R. Lakin (Cambridge) MLSOS 20 February 2008 15 / 33

  16. MLSOS grammar Expressions, e ::= v value, | let x = e in e ′ let-binding, | v v ′ function application, | fresh a : α in e fresh atom, | some x : σ in e new unification variable, | c constraint, | e 1 or · · · or e n n -ary branch. Frame Stacks, S ::= Id empty frame stack, | S ◦ ( x . e ) non-empty frame stack. NB: branches introduce non-determinism. M. R. Lakin (Cambridge) MLSOS 20 February 2008 16 / 33

  17. Operational semantics MLSOS evaluation contexts are of the form N a ∃ X ( c ; S ( e )) . We define a binary transition relation − → M between configurations. As we will see, this relation is non-deterministic... This is necessary to do proof-search. M. R. Lakin (Cambridge) MLSOS 20 February 2008 17 / 33

  18. Operational semantics A few selected operational rules: a ∃ X ( c ; S ( c )) − → M a ∃ X (( c ∪ { c } ); S (yes)) N N if | = c ∪ { c } N a ∃ X ( c ; S (fresh a : α in e )) − → M N a , a : α ∃ X ( c ′ ; S ( e )) ∈ dom ( a ) and c ′ � { a # X | X ∈ dom ( X ) } ∪ c if a / N a ∃ X ( c ; S (some x : σ in e )) − → M N a ∃ X , X : σ ( c ; S ( e [ ι X / x ])) ∈ dom ( X ) if X / N a ∃ X ( c ; S ( e 1 or · · · or e n )) − → M N a ∃ X ( c ; S ( e i )) where i ∈ { 1 , . . . , n } M. R. Lakin (Cambridge) MLSOS 20 February 2008 18 / 33

  19. Operational semantics We define two notions of observation on configurations: a ∃ X ( c ; S ( e )) ↓ N 1 if some branch of execution leads to a terminal configuration (i.e. ′ ( c ′ ; Id ( v )), where c ′ is a satisfiable set of constraints). a ′ ∃ X N a ∃ X ( c ; S ( e )) fails N 2 if all branches of execution leads to a stuck configuration (i.e. ′ ( c ′ ; S ′ ( c ′ )), where c ′ ∪ { c ′ } is an unsatisfiable set of a ′ ∃ X N constraints). These mirror the − → M rules from earlier. M. R. Lakin (Cambridge) MLSOS 20 February 2008 19 / 33

  20. Operational equivalence We write (closed) operational equivalence as ∼ =. Two closed MLSOS expressions e and e ′ are operationally equivalent if their termination and failure behaviour is the same in any context ′ ( c ′ ; S ′ ( − )), i.e. a ′ ∃ X N ′ ( c ′ ; S ′ ( e )) ↓ ′ ( c ′ ; S ′ ( e ′ )) ↓ a ′ ∃ X a ′ ∃ X N ⇐ ⇒ N ′ ( c ′ ; S ′ ( e )) fails ′ ( c ′ ; S ′ ( e ′ )) fails a ′ ∃ X a ′ ∃ X N ⇐ ⇒ N both hold. = ◦ on open expressions by closing, We extend this to a relation ∼ ground substitutions for free value identifiers. M. R. Lakin (Cambridge) MLSOS 20 February 2008 20 / 33

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend