c asl common algebraic specification language casl slang examples n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
C ASL Common Algebraic Specification Language CASL/Slang Examples PowerPoint Presentation
Download Presentation
C ASL Common Algebraic Specification Language CASL/Slang Examples

Loading in 2 Seconds...

play fullscreen
1 / 9

C ASL Common Algebraic Specification Language CASL/Slang Examples - PowerPoint PPT Presentation


  • 128 Views
  • Uploaded on

C ASL Common Algebraic Specification Language CASL/Slang Examples. Peter D. Mosses (BRICS, Aarhus, Denmark) External Relations Coordinator of C O FI: The Common Framework Initiative for algebraic specification and development.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'C ASL Common Algebraic Specification Language CASL/Slang Examples' - nicola


Download Now 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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
c asl common algebraic specification language casl slang examples

CASLCommon Algebraic Specification Language CASL/Slang Examples

Peter D. Mosses (BRICS, Aarhus, Denmark)

External Relations Coordinator of

COFI: The Common Framework Initiative

for algebraic specification and development

slide2
spec NAT_BASIC=%% ~ Specware Language Manual, Fig. 1

sort Nat

op zero : Nat

pred non_zero(x : Nat)(x = zero)

sort Pos = { x:Nat • non_zero(x) }

op succ : Nat  Pos

vars x, y : Nat

• non_zero(succ(x))

• succ(x) = succ(y)  x = y

generated { sorts Pos < Nat ops zero : Nat; succ : Nat  Pos }

axiom x : Pos • y : Nat • x = succ(y)

slide3
%% More concisely:

spec NAT_BASIC=

free typesNat ::= zero |sort Pos;

Pos ::= succ(Nat)

pred non_zero(x : Nat)(x = zero)

slide4
spec PARTIAL_ORDER=%% Specware User’s Guide, Ch. 2

sort E

pred leq : E  E

vars x, y, z : E

• %[transitivity]

leq(x,y)  leq(y,z)  leq(x,z)

• %[reflexivity]

leq(x,x)

• %[antisymmetry]

leq(x,y)  leq(y,x)  x = y

end

slide5
%% Product sorts in (first-order) CASL:

spec ACCOUNT_IMPL=%% Specware User’s Guide, Ch. 2

INTEGERand STRING

then

free type Account ::= make_account(owner:String; balance:Integer)

%% Sum sorts in CASL:

spec ERROR_VALUE= %% Specware User’s Guide, Ch. 2

sortsInteger, Error

free type Return_Value ::= sort Integer | sort Error

slide6
%% ‘Function sorts’ in (first-order) CASL:

spec MAP_SEQ [ sort E op f : E  E ] =%% Specware User’s Guide, Ch. 2

SEQ [ sort E ] with Seq[E], empty_seq, prepend

then

op map[f] : Seq[E]  Seq[E]

vars e : E; s : Seq[E]

• (e:E • f(e) = e)  map[f] (s) = s

• map[f] (empty_seq) = empty_seq

• map[f] (prepend(e,s)) = prepend(f(e), map[f] (s))

slide7
%% Subsorts in CASL:

spec EVEN=%% Specware User’s Guide, Ch. 2

NAT

then

sort Even = { n:Nat • is_even(n) }

op double(n:Nat):Even = plus(n,n) as Even

slide8
%% Partial operations in CASL:

spec DIVISION= %% Specware User’s Guide, Ch. 2

sortReal

sort Nonzero_Real = { r:Real • (r=0) }

free type Real_with_Error ::= error | sort Real

ops div_with_subsort : Real  Nonzero_Real  Real ;

div_with_sum : Real  Real  Real_with_Error ;

div_partial : Real  Real ? Real

vars r, s, t : Real

• div(r, div(s, t)) = div(mult(r, t), s) if (t=0)

slide9
%% Parameterized specifications in CASL:

spec PAIR [ sort D1 ] [ sort D2 ] = %% Specware User’s Guide, Ch. 3

free type Pair[D1,D2] ::= make_pair(first:D1; second:D2)

spec AD_PAIR=

ALPHAand DIGITthen

PAIR [ALPHAfitD1  Alpha ] [DIGITfitD2  Digit ]

spec SET [ sort E ] =sort Set[E]ops …

spec SET_OF_PAIRS [ sort D1 ] [ sort D2 ] =

SET [ PAIR [ sort D1 ] [ sort D2 ] fit E  Pair[D1,D2] ]