towards a formal semantics for fhm part 2
play

Towards a Formal Semantics for FHM: Part 2 Joey Capper and Henrik - PowerPoint PPT Presentation

Towards a Formal Semantics for FHM: Part 2 Joey Capper and Henrik Nilsson School of Computer Science, University of Nottingham FPLab Away Day, Buxton, 8th of July 2011 Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day


  1. Towards a Formal Semantics for FHM: Part 2 Joey Capper and Henrik Nilsson School of Computer Science, University of Nottingham FPLab Away Day, Buxton, 8th of July 2011 Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 1 / 18

  2. Introduction What are we trying to achieve? Evaluation of models in FHM. 1 Normalisation of functional level terms 2 Reducing signal level terms 3 Handling of simulation runtime events. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 2 / 18

  3. Introduction What are we trying to achieve? Evaluation of models in FHM. 1 Normalisation of functional level terms 2 Reducing signal level terms 3 Handling of simulation runtime events. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 2 / 18

  4. Introduction What are we trying to achieve? Evaluation of models in FHM. 1 Normalisation of functional level terms 2 Reducing signal level terms 3 Handling of simulation runtime events. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 2 / 18

  5. Introduction Partial Evaluation The evaluation should be partial in some sense. 1 Permit only simple symbolic simplification at the signal level, e.g: β -reduction of signal level products. fst ( x , y ) + z = 0 x + z = 0 � 2 Switch blocks may depend on an event payload. For example, state transfer between structural configurations. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 3 / 18

  6. Introduction Partial Evaluation The evaluation should be partial in some sense. 1 Permit only simple symbolic simplification at the signal level, e.g: β -reduction of signal level products. fst ( x , y ) + z = 0 x + z = 0 � 2 Switch blocks may depend on an event payload. For example, state transfer between structural configurations. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 3 / 18

  7. Introduction Partial Evaluation The evaluation should be partial in some sense. 1 Permit only simple symbolic simplification at the signal level, e.g: β -reduction of signal level products. fst ( x , y ) + z = 0 x + z = 0 � 2 Switch blocks may depend on an event payload. For example, state transfer between structural configurations. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 3 / 18

  8. Introduction Discrete Semantics We are only interested in the discrete aspects of FHM. 1 Not concerned with continuous semantics 2 Want to keep a clean divide between the discrete and continuous aspects, allowing the continuous aspects to specified independently. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 4 / 18

  9. Introduction Discrete Semantics We are only interested in the discrete aspects of FHM. 1 Not concerned with continuous semantics 2 Want to keep a clean divide between the discrete and continuous aspects, allowing the continuous aspects to specified independently. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 4 / 18

  10. Normalisation by Evaluation How do we achieve this? We use Normalisation by Evaluation (NbE), but why? 1 Reduction free view of normalisation 2 Symbolic method, enabling partial evaluation 3 We get use Agda as the meta-language! Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 5 / 18

  11. Normalisation by Evaluation How do we achieve this? We use Normalisation by Evaluation (NbE), but why? 1 Reduction free view of normalisation 2 Symbolic method, enabling partial evaluation 3 We get use Agda as the meta-language! Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 5 / 18

  12. Normalisation by Evaluation How do we achieve this? We use Normalisation by Evaluation (NbE), but why? 1 Reduction free view of normalisation 2 Symbolic method, enabling partial evaluation 3 We get use Agda as the meta-language! Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 5 / 18

  13. Normalisation by Evaluation What is NbE? 1 Closely related to type-directed partial evaluation 2 Proceeds by interpreting terms into an appropriate model 3 Objects of the model are then reified back into the normal forms that represent them. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 6 / 18

  14. Normalisation by Evaluation What is NbE? 1 Closely related to type-directed partial evaluation 2 Proceeds by interpreting terms into an appropriate model 3 Objects of the model are then reified back into the normal forms that represent them. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 6 / 18

  15. Normalisation by Evaluation What is NbE? 1 Closely related to type-directed partial evaluation 2 Proceeds by interpreting terms into an appropriate model 3 Objects of the model are then reified back into the normal forms that represent them. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 6 / 18

  16. Normalisation by Evaluation How do we know our normaliser is correct? The correctness of normalisation can be specified in terms of the equational theory ( ∼ βη ) of the language. Soundness t ∼ βη t ′ = ⇒ norm t = norm t ′ Completeness t ∼ βη norm t Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 7 / 18

  17. Normalisation by Evaluation How do we know our normaliser is correct? The correctness of normalisation can be specified in terms of the equational theory ( ∼ βη ) of the language. Soundness t ∼ βη t ′ = ⇒ norm t = norm t ′ Completeness t ∼ βη norm t Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 7 / 18

  18. FHM language The language We consider an equation based language embedded into the simply typed λ -calculus. Syntax t ::= x q ::= t ⋄ s | t 1 t 2 | s 1 = s 2 | λ x . t | init s 1 = s 2 | sigrel z where q | . . . etc | . . . etc Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 8 / 18

  19. FHM language The language With a signal level language as follows: Syntax s ::= z | suc s | t | fst s | s 1 + s 2 | snd s | s 1 ∗ s 2 | pair s 1 s 2 | zero | . . . etc Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 9 / 18

  20. FHM language Types With a simple language of types: Syntax τ ::= τ 1 ˙ → τ 2 σ ::= ⊤ σ 1 ˙ | SR σ | × σ 2 | Nat | Nat Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 10 / 18

  21. FHM language Equational Theory We need to extend the equational theory ( ∼ βη ): β -convertibility at s : σ . ( sigrel z where q ) ⋄ s ∼ βη q [ s / z ] η -convertibility at t : SR σ . t ∼ βη sigrel z where ( t ⋄ z ) + new congruence rules, and βη for signal level products. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 11 / 18

  22. FHM language Equational Theory We need to extend the equational theory ( ∼ βη ): β -convertibility at s : σ . ( sigrel z where q ) ⋄ s ∼ βη q [ s / z ] η -convertibility at t : SR σ . t ∼ βη sigrel z where ( t ⋄ z ) + new congruence rules, and βη for signal level products. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 11 / 18

  23. FHM language Equational Theory We need to extend the equational theory ( ∼ βη ): β -convertibility at s : σ . ( sigrel z where q ) ⋄ s ∼ βη q [ s / z ] η -convertibility at t : SR σ . t ∼ βη sigrel z where ( t ⋄ z ) + new congruence rules, and βη for signal level products. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 11 / 18

  24. Agda Implementation Term Representation Some signatures: Term representation. STerm (Γ ∆ : Ctx ) : ( σ : SType ) → Set Term (Γ : Ctx ) : ( τ : Type ) → Set EqTerm (Γ ∆ : Ctx ) : Set Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 12 / 18

  25. Agda Implementation The Model A type directed interpretation into the model (roughly!). Nrm is the redex-free representation of terms. First, the signal types. Model interpretation SVal : (Γ ∆ : Ctx ) → SType → Set SVal Γ ∆ Unit = SNrm Γ ∆ Unit SVal Γ ∆ Nat = SNrm Γ ∆ Nat SVal Γ ∆ ( σ 1 ˙ × σ 2 ) = SVal Γ ∆ σ 1 × SVal Γ ∆ σ 2 Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 13 / 18

  26. Agda Implementation The Model And the functional types. Model interpretation Val : (Γ : Ctx ) → Type → Set Val Γ Nat = Nrm Γ ∆ Nat Val Γ ( τ 1 ˙ → τ 2 ) = Val Γ τ 1 → Val Γ τ 2 Val Γ ( SR σ ) = SVal Γ σ → EqNrm Γ ∆ Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 14 / 18

  27. Agda Implementation It is now possible to give our interpreter. Interpreter type signatures � · � s : STerm Γ ∆ σ → Env Γ → Env ∆ → SVal ∆ σ � · � : Term Γ τ → Env Γ → Val Γ τ Env is just an environment of values for each variable in the indexing context. Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 15 / 18

  28. Agda Implementation The final step is to take our representative in the model, and convert it back into a normal form. Reification reify : Val Γ τ → Nrm Γ τ reify s : SVal ∆ σ → SNrm ∆ σ Composition of interpretation and reification is normalisation! Joey Capper and Henrik Nilsson (UoN) Verified FHM Semantics FPLab Away Day 16 / 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