{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

13 AxiomaticSemantics

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

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

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

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

View Full Document
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.
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

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

View Full Document
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
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."

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

View Full Document
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
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 postcondition

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

View Full Document
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.
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.

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

View Full Document
Example { x = 0} x := x+1 { x = 1} Can we use the assignment axiom to show this triple is valid???
Example { x = 0} { x+1 = 1} x := x+1 using the axiom: x := x+1 { x = 1} { x = 1}

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

View Full Document
Example {x = 0} { x = 0} {x+1 = 1} 1} x := x+1 using the axiom: x := x+1 { x = 1} { x = 1}

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online