matching of meta expressions with recursive bindings
play

Matching of Meta-Expressions with Recursive Bindings David Sabel - PowerPoint PPT Presentation

Matching of Meta-Expressions with Recursive Bindings David Sabel Goethe-University Frankfurt am Main, Germany UNIF 2017, Oxford, UK Research supported by the Deutsche Forschungsgemeinschaft (DFG) under grant SA 2908/3-1. 1 Motivation


  1. Matching of Meta-Expressions with Recursive Bindings David Sabel Goethe-University Frankfurt am Main, Germany UNIF 2017, Oxford, UK † Research supported by the Deutsche Forschungsgemeinschaft (DFG) under grant SA 2908/3-1. 1

  2. Motivation automated reasoning on programs and program transformations w.r.t. operational semantics for program calculi with higher-order constructs and recursive bindings, e.g. letrec-expressions : letrec x 1 = s 1 ; . . . ; x n = s n in t extended call-by-need lambda calculi with letrec that model core languages of lazy functional programming languages like Haskell 2/18

  3. Application: Correctness of Program Transformations Program transformation T is correct iff ∀ ℓ → r ∈ T : ∀ contexts C : C [ ℓ ] ↓ ⇐ ⇒ C [ r ] ↓ where ↓ = successful evaluation w.r.t. standard reduction 3/18

  4. Application: Correctness of Program Transformations Program transformation T is correct iff ∀ ℓ → r ∈ T : ∀ contexts C : C [ ℓ ] ↓ ⇐ ⇒ C [ r ] ↓ where ↓ = successful evaluation w.r.t. standard reduction Diagram method to show correctness of transformations: Compute overlaps between standard reductions and program transformations (requires unification, see [SSS16, PPDP]) Join the overlaps ⇒ forking and commuting diagrams Induction using the diagrams (automatable, see [RSSS12, IJCAR]) program program transformation transformation σ ( ℓ ′ ) = σ ( ℓ ′ ) = σ ( ℓ ) σ ( r ) σ ( r ) σ ( ℓ ) standard standard * * reduction reduction σ ( r ′ ) σ ( r ′ ) · · * * 3/18

  5. Requirements on the Meta-Language Operational semantics of typical call-by-need calculi (excerpt) Reduction contexts: A ::= [ · ] | ( A e ) R ::= A | letrec Env in A | letrec { x i = A i [ x i +1 ] } n − 1 i =1 , x n = A n , Env in A [ x 1 ] Standard-reduction rules and some program transformations: (SR,lbeta) R [( λx.e 1 ) e 2 ] → R [ letrec x = e 2 in e 1 ] (SR,llet) letrec Env 1 in letrec Env 2 in e → letrec Env 1 , Env 2 in e (T,cpx) T [ letrec x = y, Env in C [ x ]] → T [ letrec x = y, Env in C [ y ]] (T,gc) T [ letrec Env in e ] → T [ e ] if LetVars ( Env ) ∩ FV ( e ) = ∅ 4/18

  6. Requirements on the Meta-Language Operational semantics of typical call-by-need calculi (excerpt) Reduction contexts: A ::= [ · ] | ( A e ) R ::= A | letrec Env in A | letrec { x i = A i [ x i +1 ] } n − 1 i =1 , x n = A n , Env in A [ x 1 ] Standard-reduction rules and some program transformations: (SR,lbeta) R [( λx.e 1 ) e 2 ] → R [ letrec x = e 2 in e 1 ] (SR,llet) letrec Env 1 in letrec Env 2 in e → letrec Env 1 , Env 2 in e (T,cpx) T [ letrec x = y, Env in C [ x ]] → T [ letrec x = y, Env in C [ y ]] (T,gc) T [ letrec Env in e ] → T [ e ] if LetVars ( Env ) ∩ FV ( e ) = ∅ Meta-syntax must be capable to represent: contexts of different classes environments Env i , environment chains { x i = A i [ x i +1 ] } n − 1 i =1 4/18

  7. Requirements on the Meta-Language Operational semantics of typical call-by-need calculi (excerpt) Reduction contexts: A ::= [ · ] | ( A e ) R ::= A | letrec Env in A | letrec { x i = A i [ x i +1 ] } n − 1 i =1 , x n = A n , Env in A [ x 1 ] Standard-reduction rules and some program transformations: (SR,lbeta) R [( λx.e 1 ) e 2 ] → R [ letrec x = e 2 in e 1 ] (SR,llet) letrec Env 1 in letrec Env 2 in e → letrec Env 1 , Env 2 in e (T,cpx) T [ letrec x = y, Env in C [ x ]] → T [ letrec x = y, Env in C [ y ]] (T,gc) T [ letrec Env in e ] → T [ e ] if LetVars ( Env ) ∩ FV ( e ) = ∅ Meta-syntax must be capable to represent: contexts of different classes environments Env i , environment chains { x i = A i [ x i +1 ] } n − 1 i =1 4/18

  8. Requirements on the Meta-Language Operational semantics of typical call-by-need calculi (excerpt) Reduction contexts: A ::= [ · ] | ( A e ) R ::= A | letrec Env in A | letrec { x i = A i [ x i +1 ] } n − 1 i =1 , x n = A n , Env in A [ x 1 ] Standard-reduction rules and some program transformations: (SR,lbeta) R [( λx.e 1 ) e 2 ] → R [ letrec x = e 2 in e 1 ] (SR,llet) letrec Env 1 in letrec Env 2 in e → letrec Env 1 , Env 2 in e (T,cpx) T [ letrec x = y, Env in C [ x ]] → T [ letrec x = y, Env in C [ y ]] (T,gc) T [ letrec Env in e ] → T [ e ] if LetVars ( Env ) ∩ FV ( e ) = ∅ Meta-syntax must be capable to represent: contexts of different classes environments Env i , environment chains { x i = A i [ x i +1 ] } n − 1 i =1 4/18

  9. Requirements on the Meta-Language Operational semantics of typical call-by-need calculi (excerpt) Reduction contexts: A ::= [ · ] | ( A e ) R ::= A | letrec Env in A | letrec { x i = A i [ x i +1 ] } n − 1 i =1 , x n = A n , Env in A [ x 1 ] Standard-reduction rules and some program transformations: (SR,lbeta) R [( λx.e 1 ) e 2 ] → R [ letrec x = e 2 in e 1 ] (SR,llet) letrec Env 1 in letrec Env 2 in e → letrec Env 1 , Env 2 in e (T,cpx) T [ letrec x = y, Env in C [ x ]] → T [ letrec x = y, Env in C [ y ]] (T,gc) T [ letrec Env in e ] → T [ e ] if LetVars ( Env ) ∩ FV ( e ) = ∅ Meta-syntax must be capable to represent: contexts of different classes environments Env i , environment chains { x i = A i [ x i +1 ] } n − 1 i =1 4/18

  10. Syntax of the Meta-Language LRSX x ∈ Var ::= X Variables (variable meta-variable) | x (concrete variable) s ∈ Expr ::= S Expressions (expression meta-variable) | var x (variable) | ( f r 1 . . . r ar ( f ) ) (function application) where r i is o i , s i , or x i specified by f | D [ s ] (context meta-variable) | letrec env in s (letrec-expression) o ∈ HExpr n ::= x 1 . . . . x n .s (higher-order expression) Environments env ∈ Env ::= ∅ (empty environment) | E ; env (environment meta-variable) | Ch [ x, s ]; env (chain meta-variable) | x = s ; env (binding) Context variables D and Ch -variables have a context class cl ( D ) instances of Ch [ x, s ] : chains x = D 1 [ var x 1 ]; x 1 = D 2 [ var x 2 ]; . . . ; x n = D n [ s ] where D i are contexts of class cl ( Ch ) . 5/18

  11. Binding and Scoping Constraints Operational semantics of typical call-by-need calculi (excerpt) Reduction contexts: A ::= [ · ] | ( A e ) R ::= A | letrec Env in A | letrec { x i = A i [ x i +1 ] } n − 1 i =1 , x n = A n , Env in A [ x 1 ] Standard-reduction rules and some program transformations: (SR,lbeta) R [( λx.e 1 ) e 2 ] → R [ letrec x = e 2 in e 1 ] (SR,llet) letrec Env 1 in letrec Env 2 in e → letrec Env 1 , Env 2 in e (T,cpx) T [ letrec x = y, Env in C [ x ]] → T [ letrec x = y, Env in C [ y ]] (T,gc) T [ letrec Env in e ] → T [ e ] if LetVars ( Env ) ∩ FV ( e ) = ∅ restrictions on scoping and emptiness have to be respected, e.g.: (gc): Env must not be empty; side condition on variables (llet): FV ( Env 1 ) ∩ LetVars ( Env 2 ) = ∅ (cpx): x, y are not captured by C in C [ x ] 6/18

  12. Binding and Scoping Constraints Operational semantics of typical call-by-need calculi (excerpt) Reduction contexts: A ::= [ · ] | ( A e ) R ::= A | letrec Env in A | letrec { x i = A i [ x i +1 ] } n − 1 i =1 , x n = A n , Env in A [ x 1 ] Standard-reduction rules and some program transformations: (SR,lbeta) R [( λx.e 1 ) e 2 ] → R [ letrec x = e 2 in e 1 ] (SR,llet) letrec Env 1 in letrec Env 2 in e → letrec Env 1 , Env 2 in e (T,cpx) T [ letrec x = y, Env in C [ x ]] → T [ letrec x = y, Env in C [ y ]] (T,gc) T [ letrec Env in e ] → T [ e ] if LetVars ( Env ) ∩ FV ( e ) = ∅ restrictions on scoping and emptiness have to be respected, e.g.: (gc): Env must not be empty; side condition on variables (llet): FV ( Env 1 ) ∩ LetVars ( Env 2 ) = ∅ (cpx): x, y are not captured by C in C [ x ] 6/18

  13. Binding and Scoping Constraints Operational semantics of typical call-by-need calculi (excerpt) Reduction contexts: A ::= [ · ] | ( A e ) R ::= A | letrec Env in A | letrec { x i = A i [ x i +1 ] } n − 1 i =1 , x n = A n , Env in A [ x 1 ] Standard-reduction rules and some program transformations: (SR,lbeta) R [( λx.e 1 ) e 2 ] → R [ letrec x = e 2 in e 1 ] (SR,llet) letrec Env 1 in letrec Env 2 in e → letrec Env 1 , Env 2 in e (T,cpx) T [ letrec x = y, Env in C [ x ]] → T [ letrec x = y, Env in C [ y ]] (T,gc) T [ letrec Env in e ] → T [ e ] if LetVars ( Env ) ∩ FV ( e ) = ∅ restrictions on scoping and emptiness have to be respected, e.g.: (gc): Env must not be empty; side condition on variables (llet): FV ( Env 1 ) ∩ LetVars ( Env 2 ) = ∅ (cpx): x, y are not captured by C in C [ x ] 6/18

  14. Binding and Scoping Constraints Operational semantics of typical call-by-need calculi (excerpt) Reduction contexts: A ::= [ · ] | ( A e ) R ::= A | letrec Env in A | letrec { x i = A i [ x i +1 ] } n − 1 i =1 , x n = A n , Env in A [ x 1 ] Standard-reduction rules and some program transformations: (SR,lbeta) R [( λx.e 1 ) e 2 ] → R [ letrec x = e 2 in e 1 ] (SR,llet) letrec Env 1 in letrec Env 2 in e → letrec Env 1 , Env 2 in e (T,cpx) T [ letrec x = y, Env in C [ x ]] → T [ letrec x = y, Env in C [ y ]] (T,gc) T [ letrec Env in e ] → T [ e ] if LetVars ( Env ) ∩ FV ( e ) = ∅ restrictions on scoping and emptiness have to be respected, e.g.: (gc): Env must not be empty; side condition on variables (llet): FV ( Env 1 ) ∩ LetVars ( Env 2 ) = ∅ (cpx): x, y are not captured by C in C [ x ] 6/18

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