13 AxiomaticSemantics

13 AxiomaticSemantics - A xiomat ic Semant ics Descr ibe pr...

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

View Full Document Right Arrow Icon
Axiomatic Semantics Describe programming language semantics in a way that can be used by programmers to develop correct programs compare with denotational semantics whose main audience is programming language designers Based on assertions and axioms Many concepts can be used informally
Background image of page 1

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

View Full DocumentRight Arrow Icon
Assertion Boolean valued expression that may mention program variable the assertion may be valid (have value true, holds) or invalid (have value false, does not hold) at some point during program execution depending on the values of the program variables at that point.
Background image of page 2
Example: x = y + z If at some point, x=3, y=1, z = 2, then the assertion holds If at another point, x=4, y=1, z=2, then the assertion does not hold. The assertion true is satisfied by any program state The assertion false is not satisfied by any program states
Background image of page 3

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

View Full DocumentRight Arrow Icon
We often write assertions at a particular point in the program text The idea is that the assertion should hold at that point during the program execution Generally, we care about assertions that will hold in any execution of the program
Background image of page 4
This seminal idea is due to Robert Floyd 1967: "Assigning Meanings to Programs“ Floyd (1926-2001) received a BA in liberal arts at age 17 taught himself to program while working as a computer operator on the night shift. started publishing papers in early 60’s became a full professor of computer science at Stanford at age 32 without a PhD. Received Turing award in 1978 for "for having a clear influence on methodologies for the creation of efficient and reliable software, and for helping to found the following important subfields of computer science: the theory of parsing, the semantics of programming languages, automatic program verification, automatic program synthesis, and analysis of algorithms."
Background image of page 5

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

View Full DocumentRight Arrow Icon
Idea lives in modern programming languages in the assert statement For example in Java: assert expr 0 assert expr 0 : expr 1 expr 0 is evaluated, if false an AssertionError exception is thrown Assertions only evaluated when enabled java –ea –esa myprog
Background image of page 6
C.A.R. Hoare developed ideas further into axiomatic semantics based on a calculus of pre- and postconditions (1969) Hoare also won a Turing award. Specify a program with a Hoare triple {precondition} program {postcondition} Meaning: if the program starts in a state where the precondition is valid, then its final state will satisfy the
Background image of page 7

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

View Full DocumentRight Arrow Icon
Axioms and inference rules allow us to prove that a triple is valid The axioms and inference rules implicitly define the meaning of a program.
Background image of page 8
Assignment axiom { Q[V := E] and E is defined } V := E { Q } where Q[V := E] is Q with all occurrences of V replaced by E The assignment axiom essentially says that whatever is true about E beforehand, is true about V afterwards.
Background image of page 9

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

View Full DocumentRight Arrow Icon
Example { x = 0} x := x+1 { x = 1} Can we use the assignment axiom to show this triple is valid???
Background image of page 10
Example { x = 0} { x+1 = 1} x := x+1 using the axiom: x := x+1 { x = 1} { x = 1}
Background image of page 11

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

View Full DocumentRight Arrow Icon
Example {x = 0} { x = 0} {x+1 = 1} 1} x := x+1 using the axiom: x := x+1 { x = 1} { x = 1}
Background image of page 12
Note that {true} V := E
Background image of page 13

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

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/09/2009 for the course COP 5555 taught by Professor Staff during the Fall '08 term at University of Florida.

Page1 / 170

13 AxiomaticSemantics - A xiomat ic Semant ics Descr ibe pr...

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

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