1 / 18

Software Specifications

Software Specifications. Dr. David Dampier January 14, 2009. What is an algebra?. An algebra consists of one or more sets (sorts) closed under one or more operations, satisfying some axioms.

leoma
Download Presentation

Software Specifications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Software Specifications Dr. David Dampier January 14, 2009

  2. What is an algebra? • An algebra consists of one or more sets (sorts) closed under one or more operations, satisfying some axioms. • A set (sort) S is said to be closed under some operation, f, if the operation on members of the set produces a member of the set. {f:a → b|aS → bS} • An axiom is a proposition that is not proved or demonstrated but considered to be either self-evident, or subject to necessary decision. Its truth is taken for granted, and serves as a starting point for deducing and inferring other truths. • A multi-sorted Algebra is an algebra with more than one sort. The domain and range of an operation can be from different sorts.

  3. Example of a Specification CLASS SORT Set1 FUNC nil : → Set1 FUNC id : Set1 → Set1 AXIOM id(nil) = nil END Set1 nil id Figure 1.1, Feijs

  4. Algebra with two sorts. T V g g f f g f g Figure 1.2, Feijs

  5. Example of a Multi-Sort Specification CLASS SORT T SORT V FUNC f : T → T FUNC g : T → V END

  6. Algebraic Specifications consist of: • Syntactic Objects • Specifications • Semantic Objects • Models • Meaning Functions • How semantics are interpreted

  7. Specifications can be based on: • Equational Axioms pop(push(x,s)) = (x,s) • Conditional Equational Axioms is_empty(s) = false => push(pop(s)) = s • First Order Axioms FORALL and EXISTS • First Order Axioms + Inductive Definitions FUNC pred : Nat → Nat FUNC succ : Nat → Nat IND FORALL n:Nat ( pred(succ(n)) = n )

  8. Options for Algebras serving as semantic objects • sorts + total functions • For every function f and every value x, f(x) must exist! • Why this is a problem: • 1/0 does not exist • pop(empty) does not exist • sorts + partial functions • Allows for these possibilities • sorts + predicates + partial functions

  9. Names • Sorts • SORT S • A type is a sequence of sort names, S1, …, Sm (m ≥ 0) • S1 # … # Sm • Predicates • PRED Identifier : Type • PRED r : S1 # … # Sm • Functions • FUNC Identifier : Domain Type → Range Type • FUNC f : S1 # … # Sm → V1 # … # Vn

  10. Signatures • A signature ∑ is a set of sort, predicate and functions names such that each sort name ∑ occurring in a name of ∑ is also a member of ∑. “Completeness” SORT Int, FUNC 0 : Int, FUNC 1 : Int, PRED lss : Int # Int, PRED gtr : Int # Int, FUNC add : Int # Int → Int, FUNC sub : Int # Int → Int, FUNC mul : Int # Int → Int, FUNC div : Int # Int → Int Figure 1.3, Feijs

  11. Partial Many Sorted Algebras • A Signature is the basis for Specifications in COLD-K. • Definition: A partial many-sorted algebra A with signature ∑ is a system of set SA, functions fA and relations rA for S, f, r in ∑, such that: • For each sort name S in ∑ we find that SA is a set. The elements of SA are called objects of sort S. • For each function name f : S1 # … # Sm → V1 # … # Vn in ∑ we find that fA is a partial function from S1A × … × SmAto V1A × … × VnA. • For each predicate name r : S1 # … # Sm in ∑ we find that rA is a relation on S1A × … × SmA.

  12. Flat Algebraic Specifications • Definition: A flat algebraic specification consists of a list of definitions, where each definition defines one of the following: • Sort • Predicate • Function • Axiom • The set of names thus defined should be a signature ∑. CLASS definition1 … definitionn END

  13. Predicate Assertions • TRUE Constant Assertion • FALSE Constant Assertion • NOT A If A is an assertion, then NOT A is too. • A AND B Conjunctive Assertion • A ; B Lower Priority Conjunctive Assertion • A OR B Disjunctive Assertion • A => B Implication • A <=> B If and Only If • FORALL x:T A For every x of Type T, A is an assertion • EXISTS x:T A For at least one x of Type T, A is … • X! Definedness X is defined • X = Y Equality • r X Predicate r applied to X

  14. Strictness • Tuple Construction • (X,Y)! => X! AND Y! • Function Application • f(X)! => X! • Predicates • r(X) => X! • Equality • X = Y => X! AND Y! • Uniqueness • X! => X = X

  15. Example : Switch CLASS SORT Switch FUNC on : → Switch FUNC off : → Switch FUNC toggle: Switch → Switch END Something is missing!

  16. Example : Switch CLASS SORT Switch FUNC on : → Switch FUNC off : → Switch FUNC toggle: Switch → Switch AXIOM {SWITCH1} on!; {SWITCH2} off!; {SWITCH3} toggle(on) = off; {SWITCH4} toggle(off) = on END

  17. Example : Switch CLASS SORT Switch FUNC on : → Switch FUNC off : → Switch FUNC toggle: Switch → Switch AXIOM {SWITCH1} on!; {SWITCH2} off!; {SWITCH3} toggle(on) = off; {SWITCH4} toggle(off) = on AXIOM {SWITCH5} NOT on = off END

  18. Questions??????

More Related