• Ingen resultater fundet

What is a product?

N/A
N/A
Info
Hent
Protected

Academic year: 2022

Del "What is a product?"

Copied!
3
0
0

Indlæser.... (se fuldtekst nu)

Hele teksten

(1)

Course 02263

Formal Aspects of Software Engineering RSL Products and Bindings

Anne E. Haxthausen DTU Informatics (IMM) Technical University of Denmark

ah@imm.dtu.dk

Anne E. Haxthausen, Spring 2011c 02263 OH3 – p. 1/12

Contents

◆ what is a product? 3

◆ product type expressions 4

◆ product operators 4

◆ product value expressions 6

◆ examples of modeling using products 7

◆ binding and typings 11

c

Anne E. Haxthausen, Spring 2011 02263 OH3 – p. 2/12

What is a product?

Aproductis an ordered finite collection of values of possibly different types.

Examples:

(1,2)

(1,true,′′John′′)

Anne E. Haxthausen, Spring 2011c 02263 OH3 – p. 3/12

Product Type Expressions

type_expr1×. . . ×type_exprn, n≥2 denotes the type consisting of all values

(v1,. . . ,vn), where vi: type_expri Operators:

= 6=

c

Anne E. Haxthausen, Spring 2011 02263 OH3 – p. 4/12

(2)

Product Type Expessions, Examples

Bool×Bool

denotes the type consisting of the values:

(true,true) (true,false) (false,true) (false,false)

Nat×Nat×Bool

denotes the type consisting of the values:

(0,0,true) (0,0,false) (0,1,true) (0,1,false) (1,0,true) (1,0,false) (2,0,true)

...

Anne E. Haxthausen, Spring 2011c 02263 OH3 – p. 5/12

Product Value Expressions

(value_expr1,. . . ,value_exprn), n≥2 syntax semantics

e1 v1

... ...

en vn

(e1,. . . ,en) (v1,. . . ,vn) Examples:

(truefalse, 7 + 2) represents (true, 9)

c

Anne E. Haxthausen, Spring 2011 02263 OH3 – p. 6/12

Example: A System of Coordinates I

scheme SYSTEM_OF_COORDINATES= class

type

Position=Real×Real value

origin : Position=(0.0,0.0),

distance : Position×Position→Real distance((x1,y1),(x2,y2))≡

((x2−x1)↑2.0+(y2−y1)↑2.0)↑0.5 end

Anne E. Haxthausen, Spring 2011c 02263 OH3 – p. 7/12

Test Cases

scheme TEST_SYSTEM_OF_COORDINATES= extend SYSTEM_OF_COORDINATES with class

value

pos1 : Position=(1.0,1.0), pos2 : Position=(1.0,5.0), pos3 : Position=(5.0,1.0) test case

[t1] distance(origin, origin)=0.0, [t2] distance(pos1, pos2)=4.0, [t3] distance(pos1, pos3)=4.0, [t4] distance(pos1, origin) end

Translate to SML and run gives:

[t1] true [t2] true [t3] true

[t4] 1.41421356237

c

Anne E. Haxthausen, Spring 2011 02263 OH3 – p. 8/12

(3)

Example: A System of Coordinates II

scheme SYSTEM_OF_COORDINATES= class

type

Position=Real×Real value

origin : Position=(0.0,0.0),

distance : Position×Position→Real distance(p1,p2)≡

let

(x1,y1) = p1, (x2,y2) = p2 in

((x2−x1)↑2.0+(y2−y1)↑2.0)↑0.5 end

end

Anne E. Haxthausen, Spring 2011c 02263 OH3 – p. 9/12

(Explicit) Let Expressions

let

binding1= expr1, ...

bindingn= exprn in

expr end

c

Anne E. Haxthausen, Spring 2011 02263 OH3 – p. 10/12

Bindings

Examples:

x (x,y) (x,y,z)

((x1,y1),(x2,y2)) (x,(y,z))

Forms:

id

(binding1, ... , bindingn) Use:

◆ typings

◆ let expressions

◆ formal function parameters

◆ ...

Anne E. Haxthausen, Spring 2011c 02263 OH3 – p. 11/12

Typings

Examples:

x : Real (x,y) : Position a, b : Real Basic Form:

binding : type_expr Context condition:

binding must match type_expr Derived form:

binding1, ... , bindingn: type_expr Use:

value definitions (e.g. value x : Real)

◆ quantified expressions (e.g.∀x : Realx = x)

◆ ...

c

Anne E. Haxthausen, Spring 2011 02263 OH3 – p. 12/12

Referencer

RELATEREDE DOKUMENTER

– Knowledge of both formal and informal assessment methods for assessing engineering work – Knowledge of using assessment data to give feedback to students for improving

The application of the developed software has also been demonstrated, by performing bounded model checking on an RSL specification, using both the RSL translator and the

She is a member of the research group GEPPS (Group of Engineering of the Product Process and Services) (Brazil) since 2005 and has held positions as head of the Department

Copyright © 2008 Danish Technological Institute Page 16 of 20 Figure 8: Class diagram depicting the structure of each Concrete

Therefore, the technical problem of the project is how does a software infrastructure for software defined buildings look like in the retail sector.. What loads of a store can

The purpose of the MSc in Engineering (Software Engineering) is to, on a scientific basis, educate engineers who can independently take responsibility for and contribute to

Fully aligned - all aspects, (almost) all product groups Strongly aligned – most products fully aligned..

Formal Aspects of Software Engineering RSL Lists..