n3 - Axiomatic Semantics (of IMP, the imperative language...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Axiomatic Semantics (of IMP, the imperative language whose translational semantics we de- fined) References: Kurtz (Ch. 11); Pagan (Ch. 4.3) Summary: For each statement of IMP, we will de- fine its (axiomatic) semantics by giving an ax- iom or rule (of inference). Using these axioms and rules, we will be able to show (i.e., derive) that a given program behaves according to a given specification. 33
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Preliminaries State : The state σ of a program P is a function that maps the program variables (of P) to their values in that state: Example: h x = 1 , y = 2 , z = 3 i , or σ ( x ) = 1 , σ ( y ) = 2 , σ ( z ) = 3 (assuming P has 3 program variables x,y,z ). Usually we have to deal with a set of states: {h x = 1 , y = 2 , z = 1 i , h x = 1 , y = 2 , z = 2 i , h x = 1 , y = 2 , z = 3 i} . 34
Background image of page 2
A better way to specify a set of states is to specify an assertion (or predicate , or condition ) that is satisfied by all the states in the set ( and no others ): [ x = 1 y = 2 1 z 3 ] Assertion Set of states that satisfy the assertion. Examples: [ x = 1 1 y 5 1 z 10 ]: set with 50 elements. [ x = 1 y = 2 ]: an infinite set. [ x = 1 1 y 5 ]: an ‘even bigger’ set. 35
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
[ x = y + z ]: . . . [ x = x ]: The set of all states. true [ x 6 = x ]: The empty set. false Convention : p P ( p is an assertion, P the corresponding set of states.) [ p q ] P Q [ p q ] P Q [ ¬ p ] P (i.e., U - P ) 36
Background image of page 4
We can think of as a relation between two assertions: ( p q ) ( P Q ) ( p true ) ( P U ) ( false p ) P ) We can also think of as giving us a single assertion: ( p q ) ( ¬ p q ) Thus: ( p true ) true ( false p ) true ( p p ) true (??) ( p ⇒ ¬ p ) false (??) ( x 1 x = 2) ?? 37
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
skip , as- signment, sequential composition, if-then-else, while, read and write commands. Only integer variables; no procedures or functions; variables are declared implicitly. The Assertion Language: Boolean expressions of IMP, plus quantifiers. Note: x < y is a syntactic entity when it ap- pears in a program. Elsewhere it is an assertion that is satified by some states and not others. The context will tell which is meant. A state σ satisfies the assertion x < y if (and only if) σ ( x ) is less than σ ( y ). Notation:
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 24

n3 - Axiomatic Semantics (of IMP, the imperative language...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online