03-05-DescriptiveSpecs-notes

03-05-DescriptiveSpecs-notes - 1 CSE 435: Software...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 1 CSE 435: Software Engineering B. Cheng Note: Adapted from Ghezzi, Jazayeri, and Mandrioli Descriptive specifications Topics: Logic specifications CSE 435: Software Engineering B. Cheng Note: Adapted from Ghezzi, Jazayeri, and Mandrioli Logic specifications Examples of first-order theory (FOT) formulas: x > y y > z x > z x = y y = x x, y, z : (x > y y > z x > z) x + 1 < x 1 x : ( y : y = x + z ) x > 3 x < -6 CSE 435: Software Engineering B. Cheng Note: Adapted from Ghezzi, Jazayeri, and Mandrioli Specifying complete programs A property , or requirement, for P is specified as a formula of the type { Pre ( i 1 , i 2 , ..., i n ) } P { Post ( o 1 , o 2 , ..., o m , i 1 , i 2 , ..., i n ) } Pre: precondition Post: postcondition 2 CSE 435: Software Engineering B. Cheng Note: Adapted from Ghezzi, Jazayeri, and Mandrioli Example Program P that computes greatest common divisor of two integers i 1 and i 2 { i 1 > 0 i 2 > 0 } P { ( z 1 , z 2 : i 1 = o * z 1 i 2 = o * z 2 ) h > o : ( z 1 , z 2 : i 1 = h * z 1 i 2 = h * z 2 ) } CSE 435: Software Engineering B. Cheng Note: Adapted from Ghezzi, Jazayeri, and Mandrioli Specifying procedures { n > 0 } procedure search ( table: in integer_array; n: in integer; element: in integer; found: out bool ); { found ( i : 1 i n table (i) = element ) } { n > 0 #a = n } procedure reverse ( a: in out integer_array; n: in integer ); { i (1 .. n) : (a (i) = olda (n - i +1)) } CSE 435: Software Engineering B. Cheng Note: Adapted from Ghezzi, Jazayeri, and Mandrioli Invariant Predicate stating a condition that must always hold Many forms: Data invariants Path invariants Powerful form of documentation Example: data invariant stating that an array IMPL implements the ADT set i, j : ( 1 i #IMPL 1 j #IMPL i j ) IMPL[i] IMPL[j] Says that no duplicates are stored 3 CSE 435: Software Engineering B. Cheng Note: Adapted from Ghezzi, Jazayeri, and Mandrioli Specifying non-terminating behaviors Example: producer+consumer+buffer Invariant specifies that whatever has been produced is the concatenation of what has...
View Full Document

Page1 / 8

03-05-DescriptiveSpecs-notes - 1 CSE 435: Software...

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

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