CSE503: Software Engineering
David Notkin
algebra StringSpec;
introduces
sorts String, Char, Nat, Bool;
operations
new: () -> String
append: String, String -> String
add: String, Char -> String
length: String -> Nat
isEmpty: String -> Bool
equal: String, String -> Bool
constrains new, append, add, length, isEmpty, equal so that
StringSpec generated by [new, add]
for all [s1, s2, s3: String; c: Char]
isEmpty (new()) = true;
isEmpty (add(s1,c)) = false;
length (new()) = 0;
length (add(s1,c)) = length (s1) + 1
append (s1, new()) = s1
append (s1, add(s2,c)) = add (append(s1,s2), c)
equal (new(), new()) = true
equal (new(), add(s1,c)) = false
equal (add(s1,c), new()) = false
equal (add(s1,c), add(s2,c)) = equal(s1,s2)
end StringSpec