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 2: Operational Semantics of WHILE I (Evaluation of Expressions) Thomas Noll Software Modeling and Verification Group RWTH Aachen University


  1. Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions) Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-19/sv-sw/

  2. Recap: Syntax of WHILE Outline of Lecture 2 Recap: Syntax of WHILE Operational Semantics of WHILE Evaluation of Arithmetic Expressions Excursus: Proof by Structural Induction Evaluation of Boolean Expressions 2 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  3. Recap: Syntax of WHILE Syntactic Categories WHILE: simple imperative programming language without procedures or advanced data structures Syntactic categories: Category Domain Meta variable Z = { 0 , 1 , − 1 , . . . } z Numbers B = { true , false } Truth values t Var = { x , y , . . . } Variables x Arithmetic expressions AExp (next slide) a Boolean expressions BExp (next slide) b Commands (statements) Cmd (next slide) c 3 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  4. Recap: Syntax of WHILE Syntax of WHILE Programs Definition (Syntax of WHILE) The syntax of WHILE Programs is defined by the following context-free grammar: a ::= z | x | a 1 + a 2 | a 1 - a 2 | a 1 * a 2 ∈ AExp b ::= t | a 1 = a 2 | a 1 > a 2 | ¬ b | b 1 ∧ b 2 | b 1 ∨ b 2 ∈ BExp c ::= skip | x := a | c 1 ; c 2 | if b then c 1 else c 2 end | while b do c end ∈ Cmd Remarks: we assume that • the syntax of numbers, truth values and variables is predefined (i.e., no “lexical analysis”) • the syntactic interpretation of ambiguous constructs (expressions) is uniquely determined (by brackets or priorities) 4 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  5. Operational Semantics of WHILE Outline of Lecture 2 Recap: Syntax of WHILE Operational Semantics of WHILE Evaluation of Arithmetic Expressions Excursus: Proof by Structural Induction Evaluation of Boolean Expressions 5 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  6. Operational Semantics of WHILE Operational Semantics of WHILE • Idea: define meaning of programs by specifying its behaviour being executed on an (abstract) machine 6 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  7. Operational Semantics of WHILE Operational Semantics of WHILE • Idea: define meaning of programs by specifying its behaviour being executed on an (abstract) machine • Here: evaluation/execution relation for program fragments (expressions, statements) 6 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  8. Operational Semantics of WHILE Operational Semantics of WHILE • Idea: define meaning of programs by specifying its behaviour being executed on an (abstract) machine • Here: evaluation/execution relation for program fragments (expressions, statements) • Approach based on Structural Operational Semantics (SOS) – G.D. Plotkin: A structural approach to operational semantics , DAIMI FN-19, Computer Science Department, Aarhus University, 1981 6 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  9. Operational Semantics of WHILE Operational Semantics of WHILE • Idea: define meaning of programs by specifying its behaviour being executed on an (abstract) machine • Here: evaluation/execution relation for program fragments (expressions, statements) • Approach based on Structural Operational Semantics (SOS) – G.D. Plotkin: A structural approach to operational semantics , DAIMI FN-19, Computer Science Department, Aarhus University, 1981 • Employs derivation rules of the form (Name) Premise(s) [ side conditions ] Conclusion – meaning: if every premise [and all side conditions] are fulfilled, then the conclusion can be drawn – a rule with no premises is called an axiom 6 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  10. Operational Semantics of WHILE Operational Semantics of WHILE • Idea: define meaning of programs by specifying its behaviour being executed on an (abstract) machine • Here: evaluation/execution relation for program fragments (expressions, statements) • Approach based on Structural Operational Semantics (SOS) – G.D. Plotkin: A structural approach to operational semantics , DAIMI FN-19, Computer Science Department, Aarhus University, 1981 • Employs derivation rules of the form (Name) Premise(s) [ side conditions ] Conclusion – meaning: if every premise [and all side conditions] are fulfilled, then the conclusion can be drawn – a rule with no premises is called an axiom • Derivation rules can be composed to form derivation trees with axioms as leaves (formal definition later) 6 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  11. Evaluation of Arithmetic Expressions Outline of Lecture 2 Recap: Syntax of WHILE Operational Semantics of WHILE Evaluation of Arithmetic Expressions Excursus: Proof by Structural Induction Evaluation of Boolean Expressions 7 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  12. Evaluation of Arithmetic Expressions Program States • Meaning of expression = its value (in the usual sense) • Depends on the values of the variables in the expression 8 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  13. Evaluation of Arithmetic Expressions Program States • Meaning of expression = its value (in the usual sense) • Depends on the values of the variables in the expression Definition 2.1 (Program state) A (program) state is an element of the set Σ := { σ | σ : Var → Z } , called the state space. Thus σ ( x ) denotes the value of x ∈ Var in state σ ∈ Σ . 8 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  14. Evaluation of Arithmetic Expressions Evaluation of Arithmetic Expressions I Remember: a ::= z | x | a 1 + a 2 | a 1 - a 2 | a 1 * a 2 ∈ AExp 9 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  15. Evaluation of Arithmetic Expressions Evaluation of Arithmetic Expressions I Remember: a ::= z | x | a 1 + a 2 | a 1 - a 2 | a 1 * a 2 ∈ AExp Definition 2.2 (Evaluation relation for arithmetic expressions) If a ∈ AExp and σ ∈ Σ , then � a , σ � is called a configuration. Expression a evaluates to z ∈ Z in state σ (notation: � a , σ � → z ) if this relationship is derivable by means of the following rules: Axioms: � z , σ � → z � x , σ � → σ ( x ) Rules: � a 1 , σ � → z 1 � a 2 , σ � → z 2 where z := z 1 + z 2 � a 1 + a 2 , σ � → z � a 1 , σ � → z 1 � a 2 , σ � → z 2 where z := z 1 − z 2 � a 1 - a 2 , σ � → z � a 1 , σ � → z 1 � a 2 , σ � → z 2 where z := z 1 · z 2 � a 1 * a 2 , σ � → z 9 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  16. Evaluation of Arithmetic Expressions Evaluation of Arithmetic Expressions II Example 2.3 a = (x+3)*(y-2) , σ ( x ) = 3, σ ( y ) = 9: 10 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  17. Evaluation of Arithmetic Expressions Evaluation of Arithmetic Expressions II Example 2.3 a = (x+3)*(y-2) , σ ( x ) = 3, σ ( y ) = 9: � (x+3)*(y-2) , σ � → 10 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  18. Evaluation of Arithmetic Expressions Evaluation of Arithmetic Expressions II Example 2.3 a = (x+3)*(y-2) , σ ( x ) = 3, σ ( y ) = 9: � x+3 , σ � → � y-2 , σ � → � (x+3)*(y-2) , σ � → � a 1 , σ � → z 1 � a 2 , σ � → z 2 where z := z 1 · z 2 � a 1 * a 2 , σ � → z 10 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

  19. Evaluation of Arithmetic Expressions Evaluation of Arithmetic Expressions II Example 2.3 a = (x+3)*(y-2) , σ ( x ) = 3, σ ( y ) = 9: � x , σ � → � 3 , σ � → � x+3 , σ � → � y-2 , σ � → � (x+3)*(y-2) , σ � → � a 1 , σ � → z 1 � a 2 , σ � → z 2 where z := z 1 + z 2 � a 1 + a 2 , σ � → z 10 of 22 Semantics and Verification of Software Summer Semester 2019 Lecture 2: Operational Semantics of WHILE I (Evaluation of Expressions)

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