0% found this document useful (0 votes)
63 views

Axiomatic Semantics

This document discusses different approaches to formal semantics including operational semantics, denotational semantics, and axiomatic semantics. It focuses on axiomatic semantics which describes the meaning of programs through logical properties (axioms) about program constructs. Key concepts discussed include Hoare triples for specifying preconditions and postconditions, proof rules for reasoning about programs, and using invariants in proofs. An example is provided to prove a while loop computes a product using these axiomatic semantics techniques.

Uploaded by

scvalencia606
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Axiomatic Semantics

This document discusses different approaches to formal semantics including operational semantics, denotational semantics, and axiomatic semantics. It focuses on axiomatic semantics which describes the meaning of programs through logical properties (axioms) about program constructs. Key concepts discussed include Hoare triples for specifying preconditions and postconditions, proof rules for reasoning about programs, and using invariants in proofs. An example is provided to prove a while loop computes a product using these axiomatic semantics techniques.

Uploaded by

scvalencia606
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Axiomatic Semantics

CS 565
Lecture 6
2/04/09

Axiomatic Semantics

Operational semantics describes the meaning of


programs in terms of the execution steps taken by
an abstract machine.
Denotational semantics describes the meaning of
programs in terms of formal mathematical objects.
Axiomatic semantics describes the meaning of
programs in terms of properties (axioms) about
them.

Every language construct is described in terms


of a statement (in logic) about what the
construct accomplishes when it executes.

States
!
"
"
!
!
!
!

!
"
!
!

"

!
!

" !

"

Hoare Triples
!
"
!
!

"
"
!
!
!

Satisfiability
!
"
"
!

"

"

#
!

! !
! !
! !

! !

Examples
!

!
!

Partial correctness
!
!
"
"
"

Soundness
!
"
"
"

!
"

Proof Rules

Skip:
{ P } skip { P }

Assignment:
{ P[t/x] } x := t { P }
Example: Suppose t = x + 1
Then, { x+1 = 2 } x := x + 1 { x = 2 }

Sequencing:
{P} c0 {Q} {Q} c1 {Q}
{P} c0;c1 {Q}

Proof Rules (cont)


!

Example

Example
Prove the program:
z := 0;
n : = y;
while n > 0 do
z := z + x;
n := n 1
computes the product of x and y (assuming y
is not negative).

Invariants

Example

Example

Example

You might also like