1 / 16

Rigorous Software Engineering

A system for registering students at a university. Only registered students are considered legal. Each student has a unique ID. Students with the same major and registered at the same university are regarded as classmates.

wvance
Télécharger la présentation

Rigorous Software Engineering

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. RigorousSoftwareEngineering Assignment3 (exercise2,3.3,3.5)

  2. Exercise2 abstractsigStudent{} sigGraduateextendsStudent{} sigUndergraduateextendsStudent{} sigID{} sigMajor{} sigUniversity{}

  3. abstractsigStudent{ id:oneID, major:oneMajor, university:loneUniversity, isLegal:Bool, classmates:setStudent, }

  4. Descriptions Descriptions Astudentshouldregisteratauniversity,andonlyregisteredstudentsarelegalstudents. EverystudenthasauniquestudentID. Alloy Alloy factlegal_in_university{ alls:Student|(s.university!=none)iff(s.isLegal=True) } factunique_ids{ alldisjs,t:Student|s.id!=t.id } factno_id_without_student{ alli:ID|ones:Student|s.id=i }

  5. Descriptions Studentswiththesamemajorwhoareregisteredatthesameuniversityareregardedasclassmates. Graduatesandundergraduatesareneverclassmates. Alloy factclassmates_have_same_major_and_uni{ alldisjs,t:Student|(s.major=t.majorands.university=t.university and(sinUndergraduateandtinUndergraduateorsinGraduateandtinGraduate) iff(sint.classmates) }

  6. Descriptions Descriptions Theclassmaterelationisnotreflexive(astudentcannotbehis/herownclassmate). Visualizethemodelfor2Universities,3Majors,3Studentsand3IDs. Alloy Alloy factno_self_classmate{ alls:Student|snotins.classmates } predshow{} runshowfor2University,3Major,3Student,3ID

  7. Exercise3.3DorisDay’ssong “Everybody loves my baby but my baby don’t love nobody but me” David Gries has pointed out that, from a strictly logical point of view, this implies ‘I am my baby’. Everybodylovesmybaby(b) assert song { all p: Person| my_baby[p] implies Me = p } predmy_baby[b: Person] { (all p: Person | b inp.loves) and b.loves = Me } Mybabydon’tlovenobodybutme

  8. Exercise3.3DorisDay’ssong “Everybody loves my baby but my baby don’t love nobody but me” David Gries has pointed out that, from a strictly logical point of view, this implies ‘I am my baby’. assert song { all p: Person| my_baby[p] implies Me = p } predmy_baby[b: Person] { (all p: Person | b inp.loves) and b.loves = Me } +b

  9. Exercise3.5ModelingtheTube Station: the set of all stations JubileeStation, CentralStation, CircleStation: for each line, a subset of Station jubliee, central, circle: binary relations relating stations on each line to one another if they are directly connected sig Station {} sigJubileeStationin Station { jubilee: set JubileeStation } sigCentralStationin Station { central: set CentralStation } sigCircleStationin Station { circle: set CircleStation }

  10. Exercise3.5ModelingtheTube Stanmore, BakerStreet, Epping:singleton subsets of Station for individual stations one sig Stanmore, BakerStreet, Epping extends Station {}

  11. Exercise3.5ModelingtheTube (a)Namedstationsareonexactlythelinesasshowningraphic Centralline Jubileeline Circleline Stanmore in (JubileeStation - CentralStation) - CircleStation BakerStreetin (JubileeStation & CircleStation) - CentralStation Epping in (CentralStation - JubileeStation) - CircleStation

  12. Exercise3.5ModelingtheTube (b)Nostation(includingthoseunnamed)isonallthreelines Centralline Jubileeline Circleline no (JubileeStation & CentralStation & CircleStation)

  13. Exercise3.5ModelingtheTube (c)TheCirclelineformsacircle Centralline Jubileeline Circleline ^circle:(s1,s2),(s1,s3),…,(s1,sn),…,(sn-1,sn) all s: CircleStation { ones.circle CircleStationins.^circle } Everystationhasone“next”station,includingthe“last”station. Allstationsthatcanbereachedstartingfroms

  14. Exercise3.5ModelingtheTube (d)JubileeisastraightlinestartingatStanmore Centralline Jubileeline Circleline Stanmoreisthestartingstation,otherstationinJubileecanbereachedfromStanmore JubileeStationin Stanmore.*jubilee all s: JubileeStation { lones.jubilee s not in s.^jubilee } Everystationhasoneorzero“next”station Allstationsthatcanbereachedstartingfroms

  15. Exercise3.5ModelingtheTube (e)there’sastationbetweenStanmoreandBakerStreet Centralline Jubileeline Circleline All(A,B)tuplesthatonecantravelfromAtoBonJubilee let reach = ^jubilee | someStanmore.reach & reach.BakerStreet AllstationsthatcanreachBakerStreet AllstationsthatcanbereachedstartingfromStanmore

  16. Exercise3.5ModelingtheTube (f)ItispossibletotravelfromBakerStreettoEpping Centralline Jubileeline Circleline Epping inBakerStreet.^(jubilee + central + circle) All(A,B)tuplesthatonecantravelfromAtoB AllstationsthatcanbereachedstartingfromBakerStreet

More Related