semantics and verification of software
play

Semantics and Verification of Software Summer Semester 2019 Lecture - PowerPoint PPT Presentation

Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics) Thomas Noll Software Modeling and Verification Group RWTH Aachen University


  1. Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics) Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-19/sv-sw/

  2. Recap: Operational Semantics of Blocks and Procedures Outline of Lecture 15 Recap: Operational Semantics of Blocks and Procedures Denotational Semantics of Blocks and Procedures Handling Variable Declarations Handling Procedures Two Examples Justification of Fixpoint Semantics Summary: Blocks and Procedures in Operational/Denotational Semantics 2 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  3. Recap: Operational Semantics of Blocks and Procedures Extending the Syntax Syntactic categories: Category Domain Meta variable PVar = { P , Q , . . . } P Procedure identifiers Procedure declarations PDec p Variable declarations VDec v Commands (statements) Cmd c Context-free grammar: p ::= proc P is c end; p | ε ∈ PDec v ::= var x ; v | ε ∈ VDec c ::= skip | x := a | c 1 ; c 2 | if b then c 1 else c 2 end | while b do c end | call P | begin v p c end ∈ Cmd • All used variable/procedure identifiers have to be declared • Identifiers declared within a block must be distinct 3 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  4. Recap: Operational Semantics of Blocks and Procedures Locations and Stores • So far: states Σ = { σ | σ : Var → Z } • Now: explicit control over all (nested) instances of a variable: – variable environments VEnv := { ρ | ρ : Var ��� Loc } (partial function to maintain declaredness information) – locations Loc := N – stores Sto := { σ | σ : Loc ��� Z } (partial function to maintain allocation information) ⇒ Two-level access to a variable x ∈ Var : 1. determine current memory location of x : l := ρ ( x ) 2. reading/writing access to σ at location l • Thus: previous state information represented as σ ◦ ρ 4 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  5. Recap: Operational Semantics of Blocks and Procedures Procedure Environments and Declarations • Effect of procedure call determined by its body and variable and procedure environment of its declaration: PEnv := { π | π : PVar ��� Cmd × VEnv × PEnv } denotes the set of procedure environments • Effect of declaration: update of environment (and store) upd v � . � : VDec × VEnv × Sto → VEnv × Sto upd v � var x ; v � ( ρ, σ ) := upd v � v � ( ρ [ x �→ l x ] , σ [ l x �→ 0 ]) upd v � ε � ( ρ, σ ) := ( ρ, σ ) upd p � . � : PDec × VEnv × PEnv → PEnv upd p � proc P is c end; p � ( ρ, π ) := upd p � p � ( ρ, π [ P �→ ( c , ρ, π )]) upd p � ε � ( ρ, π ) := π where l x := min { l ∈ Loc | σ ( l ) = ⊥} 5 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  6. Recap: Operational Semantics of Blocks and Procedures Execution Relation I Definition (Execution relation) For c ∈ Cmd , σ, σ ′ ∈ Sto , ρ ∈ VEnv , and π ∈ PEnv , the execution relation ( ρ, π ) ⊢ � c , σ � → σ ′ (“in environment ( ρ, π ) , statement c transforms store σ into σ ′ ”) is defined by the following rules: (skip) ( ρ, π ) ⊢ � skip , σ � → σ � a , σ ◦ ρ � → z (asgn) ( ρ, π ) ⊢ � x := a , σ � → σ [ ρ ( x ) �→ z ] (seq) ( ρ, π ) ⊢ � c 1 , σ � → σ ′ ( ρ, π ) ⊢ � c 2 , σ ′ � → σ ′′ ( ρ, π ) ⊢ � c 1 ; c 2 , σ � → σ ′′ ( ρ, π ) ⊢ � c 1 , σ � → σ ′ (if-t) � b , σ ◦ ρ � → true ( ρ, π ) ⊢ � if b then c 1 else c 2 end , σ � → σ ′ 6 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  7. Recap: Operational Semantics of Blocks and Procedures Execution Relation II Definition (Execution relation; continued) ( ρ, π ) ⊢ � c 2 , σ � → σ ′ (if-f) � b , σ ◦ ρ � → false ( ρ, π ) ⊢ � if b then c 1 else c 2 end , σ � → σ ′ � b , σ ◦ ρ � → false (wh-f) ( ρ, π ) ⊢ � while b do c end , σ � → σ ( ρ, π ) ⊢� c , σ �→ σ ′ ( ρ, π ) ⊢� while b do c end , σ ′ �→ σ ′′ (wh-t) � b , σ ◦ ρ �→ true ( ρ, π ) ⊢ � while b do c end , σ � → σ ′′ (call) ( ρ ′ , π ′ [ P �→ ( c , ρ ′ , π ′ )]) ⊢ � c , σ � → σ ′ if π ( P ) = ( c , ρ ′ , π ′ ) ( ρ, π ) ⊢ � call P , σ � → σ ′ upd v � v � ( ρ, σ ) = ( ρ ′ , σ ′ ) upd p � p � ( ρ ′ , π ) = π ′ ( ρ ′ , π ′ ) ⊢ � c , σ ′ � → σ ′′ (block) ( ρ, π ) ⊢ � begin v p c end , σ � → σ ′′ 7 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  8. Denotational Semantics of Blocks and Procedures Outline of Lecture 15 Recap: Operational Semantics of Blocks and Procedures Denotational Semantics of Blocks and Procedures Handling Variable Declarations Handling Procedures Two Examples Justification of Fixpoint Semantics Summary: Blocks and Procedures in Operational/Denotational Semantics 8 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  9. Denotational Semantics of Blocks and Procedures The Approach Operational semantics: “syntactic” approach • procedure environment holds code of procedure body • semantics of call = “inlining” 9 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  10. Denotational Semantics of Blocks and Procedures The Approach Operational semantics: “syntactic” approach • procedure environment holds code of procedure body • semantics of call = “inlining” Denotational semantics: “semantic” approach • procedure environment holds (partial) storage transformations • semantics of call = function application • variables handled as in operational semantics (by environment and stores) • declarations of recursive procedures handled by fixpoint approach 9 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  11. Handling Variable Declarations Outline of Lecture 15 Recap: Operational Semantics of Blocks and Procedures Denotational Semantics of Blocks and Procedures Handling Variable Declarations Handling Procedures Two Examples Justification of Fixpoint Semantics Summary: Blocks and Procedures in Operational/Denotational Semantics 10 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  12. Handling Variable Declarations Handling Variable Declarations Exactly as in operational semantics: • Variable environments keep location information: VEnv := { ρ | ρ : Var ��� Loc } with Loc := N 11 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  13. Handling Variable Declarations Handling Variable Declarations Exactly as in operational semantics: • Variable environments keep location information: VEnv := { ρ | ρ : Var ��� Loc } with Loc := N • Effect of variable declaration: update of environment and store upd v � . � : VDec × VEnv × Sto → VEnv × Sto upd v � var x ; v � ( ρ, σ ) := upd v � v � ( ρ [ x �→ l x ] , σ [ l x �→ 0 ]) upd v � ε � ( ρ, σ ) := ( ρ, σ ) where l x := min { l ∈ Loc | σ ( l ) = ⊥} 11 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

  14. Handling Variable Declarations Statement Semantics Using Variable Environments • First step: reformulation of Definition 6.3 using variable environments and locations (initially disregarding procedures) • So far: C � . � : Cmd → (Σ ��� Σ) 12 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 15: Extension by Blocks and Procedures II (Denotational Semantics)

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