SlideShare a Scribd company logo
Chapter 11
MAPS
Introduction
• Computing systems often involve relating two
types of value together. In Chapter 3 you were
introduced to the idea of a function; you saw that
a function is a set of assignments from one set to
another. A map is closely related to the concept
of functions. A map is a special sort of set, one
which contains a set of maplets. Each maplet
connects an element of one set to an element of
another set; the first set is referred to as the
domain, the second is referred to as the range.
Notation
• Consider Table 11.1, which shows the state of
a number of different temperature sensors
that monitor the condition of various items in
a laboratory. The condition of each item can
be either LOW, NORMAL or HIGH.
Notation
• We can express the Table 11.1 as a map,
which we might call sensors. This will be a
mapping from a set of sensors to the set of
possible conditions. We do this as follows.
– sensors = {A ↦ LOW, B ↦ NORMAL, C ↦ NORMAL, D ↦
HIGH, E ↦ NORMAL, F ↦ NORMAL}
• In general terms
– m = {a ↦ y, b ↦ x, c ↦ x, d ↦ z}
Notation
• Two important points should be noted here:
• By definition, all the domain elements in a
map are unique.
• The ordering of the maplets is not significant –
the map m above could be specified, without
changing the meaning, as:
– m = {d ↦ z, a ↦ y, c ↦ x, b ↦ x}
• You should also note that the empty map is
written as: {↦}.
Map Operators
• In order to illustrate the use of the various
map operators that exist, we will define the
following three maps, all of which map from
some previously defined set (the members of
which are represented here by lower case
letters) to the set of natural numbers.
– m1 = {a ↦ 1, b ↦ 2, c ↦ 2, d ↦ 3, e ↦ 4}
– m2 = {a ↦ 2, f ↦ 1, c ↦ 7}
– m3 = { f ↦ 2, g ↦ 6}
Domain and Range operators
• The domain operator, dom, returns the set of
all the domain elements of the maplets. The
range operator, rng, returns the set of all the
range elements.
– dom m1 = {a, b, c, d, e}
– rng m1 = {1, 2, 3, 4 }
– dom m2 = {a, f, c}
– rng m2 = {1, 2, 7}
The Union operator
• The union operator, U, behaves in a similar way
as it does with sets. So
– m1 U m3 = {a ↦ 1, b ↦ 2, c ↦ 2, d ↦ 3, e ↦ 4, f ↦ 2, g
↦ 6}
• The union operator is defined only if no two
domain elements are the same; if this is not the
case, then union is undefined (otherwise we
would lose the uniqueness of the keys). Thus the
following two expressions are undefined:
– m1 U m2 ---------undefined
– m2 U m3 ---------undefined
The Override operator
• In the case where two or more domain
elements are the same in both maps, we can
use the override operator (†). This behaves in
the same way as the union operator, but if the
domain element of a maplet is the same in
both sets, then the second maplet wins. Thus
– m1 † m2 = {a ↦ 2, b ↦ 2, c ↦ 7, d ↦ 3, e ↦ 4, f ↦
1}
– m3 † m2 = { f ↦ 1, g ↦ 6, a ↦ 2, c ↦ 7}
Domain restriction operator
• A domain restriction operator, , is defined
with two operands (parameters). The first is a
set and the second is a map. The result yields
a map that contains only those maplets whose
domain element is in the set. For example
– {a, c, e} ◁ m1 = {a ↦ 1, c ↦ 2, e ↦ 4}
– {e, f } ◁ m2 = {f ↦ 1}
– {} ◁ m3 = {↦}
Domain deletion operator
• The domain deletion operator, , behaves in a
similar way, but in this case deletes the maplet
in question:
– {a, c, e} ⩤ m1 = {b ↦ 2, d ↦ 3}
– {e, f} ⩤ m2 = {a ↦ 2, c ↦ 7}
– {} ⩤ m3 = { f ↦ 2, g ↦ 6}
Range restriction and range deletion
operator
• The range restriction operator, , and the range
deletion operator, , are similar to the above,
but apply to the last elements of the maplets.
Thus
– m1 ▷ {1, 2} = {a ↦ 1, b ↦ 2, c ↦ 2}
– m3 ⩥ {6, 2} = {↦}
Map application
• Applying a map is the same as applying a
function, and we use the same notation. Thus if
we apply our map to a particular domain
element, then the result is the range element. For
example, once again using the above maps:
– m1(d) = 3
– m2( f ) = 1
– m3( f ) = 2
– m3(x) is undefined
• Using the sensors example from section 11.2:
– sensors(A) = LOW
Using the Map Type in VDM-SL
• To declare a variable to be of type Map we use
a special arrow. For example, to declare a
variable m that maps characters to natural
numbers we would write:
– m : Char ℕ
Specifying a high security building
• Only authorized employees are allowed entry to the
building and each one consists of a user name (which is
unique) and a password, both of which must be
supplied when the individual wishes to enter the
building. If the details are correct, a signal is sent to the
hardware instructing it to open the door, and the
member of staff is recorded as being inside the
building. When the member of staff wishes to leave
the building, the individual supplies his or her user
name, and as long as the user is recorded as being
currently inside the building, a signal is sent to the
hardware to open the door, and the employee is
recorded as having left.
UML Diagram
Thanks

More Related Content

Similar to ch 11-part 1.pdf

Javascript Array map method
Javascript Array map methodJavascript Array map method
Javascript Array map method
tanerochris
 
Merge sort
Merge sortMerge sort
Merge sort
Rojin Khadka
 
Robotics_Final_Paper_Folza
Robotics_Final_Paper_FolzaRobotics_Final_Paper_Folza
Robotics_Final_Paper_Folza
Alex Folz
 
Matrices and row operations 12123 and applications of matrices
Matrices and row operations 12123 and applications of matricesMatrices and row operations 12123 and applications of matrices
Matrices and row operations 12123 and applications of matrices
mayaGER
 
Karnaugh map peresentation
Karnaugh map  peresentationKarnaugh map  peresentation
Karnaugh map peresentation
AbdulRehmanKaleem1
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2
bilawalali74
 
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
hyacinthshackley2629
 
Lwrb ms
Lwrb msLwrb ms
Matlabch01
Matlabch01Matlabch01
Matlabch01
Mohammad Ayyash
 
Graph Analytics and Complexity Questions and answers
Graph Analytics and Complexity Questions and answersGraph Analytics and Complexity Questions and answers
Graph Analytics and Complexity Questions and answers
Animesh Chaturvedi
 
Programming with matlab session 6
Programming with matlab session 6Programming with matlab session 6
Programming with matlab session 6
Infinity Tech Solutions
 
Karnaugh maps
Karnaugh mapsKarnaugh maps
Karnaugh maps
Sushil Ranjan
 
Approximate Methods
Approximate MethodsApproximate Methods
Approximate Methods
Teja Ande
 
167c h a p t e r4Optimized Implementation of Logic.docx
167c h a p t e r4Optimized Implementation of Logic.docx167c h a p t e r4Optimized Implementation of Logic.docx
167c h a p t e r4Optimized Implementation of Logic.docx
hyacinthshackley2629
 
Masters Report 3
Masters Report 3Masters Report 3
Masters Report 3
Lloyd Blackbeard
 
JGrass-NewAge LongWave radiation Balance
JGrass-NewAge LongWave radiation BalanceJGrass-NewAge LongWave radiation Balance
JGrass-NewAge LongWave radiation Balance
Marialaura Bancheri
 
A Reflective Implementation of an Actor-based Concurrent Context-Oriented System
A Reflective Implementation of an Actor-based Concurrent Context-Oriented SystemA Reflective Implementation of an Actor-based Concurrent Context-Oriented System
A Reflective Implementation of an Actor-based Concurrent Context-Oriented System
Takuo Watanabe
 
Exp integrals
Exp integralsExp integrals
Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
Sourabh Bhattacharya
 
Report AdvOpticalComm - Pietro Santoro -
Report AdvOpticalComm - Pietro Santoro -Report AdvOpticalComm - Pietro Santoro -
Report AdvOpticalComm - Pietro Santoro -
Pietro Santoro
 

Similar to ch 11-part 1.pdf (20)

Javascript Array map method
Javascript Array map methodJavascript Array map method
Javascript Array map method
 
Merge sort
Merge sortMerge sort
Merge sort
 
Robotics_Final_Paper_Folza
Robotics_Final_Paper_FolzaRobotics_Final_Paper_Folza
Robotics_Final_Paper_Folza
 
Matrices and row operations 12123 and applications of matrices
Matrices and row operations 12123 and applications of matricesMatrices and row operations 12123 and applications of matrices
Matrices and row operations 12123 and applications of matrices
 
Karnaugh map peresentation
Karnaugh map  peresentationKarnaugh map  peresentation
Karnaugh map peresentation
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2
 
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx17, r) -,r I  -l19.t... 121.2t-314 23. ^t -rr - .docx
17, r) -,r I -l19.t... 121.2t-314 23. ^t -rr - .docx
 
Lwrb ms
Lwrb msLwrb ms
Lwrb ms
 
Matlabch01
Matlabch01Matlabch01
Matlabch01
 
Graph Analytics and Complexity Questions and answers
Graph Analytics and Complexity Questions and answersGraph Analytics and Complexity Questions and answers
Graph Analytics and Complexity Questions and answers
 
Programming with matlab session 6
Programming with matlab session 6Programming with matlab session 6
Programming with matlab session 6
 
Karnaugh maps
Karnaugh mapsKarnaugh maps
Karnaugh maps
 
Approximate Methods
Approximate MethodsApproximate Methods
Approximate Methods
 
167c h a p t e r4Optimized Implementation of Logic.docx
167c h a p t e r4Optimized Implementation of Logic.docx167c h a p t e r4Optimized Implementation of Logic.docx
167c h a p t e r4Optimized Implementation of Logic.docx
 
Masters Report 3
Masters Report 3Masters Report 3
Masters Report 3
 
JGrass-NewAge LongWave radiation Balance
JGrass-NewAge LongWave radiation BalanceJGrass-NewAge LongWave radiation Balance
JGrass-NewAge LongWave radiation Balance
 
A Reflective Implementation of an Actor-based Concurrent Context-Oriented System
A Reflective Implementation of an Actor-based Concurrent Context-Oriented SystemA Reflective Implementation of an Actor-based Concurrent Context-Oriented System
A Reflective Implementation of an Actor-based Concurrent Context-Oriented System
 
Exp integrals
Exp integralsExp integrals
Exp integrals
 
Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 
Report AdvOpticalComm - Pietro Santoro -
Report AdvOpticalComm - Pietro Santoro -Report AdvOpticalComm - Pietro Santoro -
Report AdvOpticalComm - Pietro Santoro -
 

Recently uploaded

Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)
wonyong hwang
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
Optimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptxOptimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptx
WebConnect Pvt Ltd
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
Yara Milbes
 
Hands-on with Apache Druid: Installation & Data Ingestion Steps
Hands-on with Apache Druid: Installation & Data Ingestion StepsHands-on with Apache Druid: Installation & Data Ingestion Steps
Hands-on with Apache Druid: Installation & Data Ingestion Steps
servicesNitor
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
Tier1 app
 
Computer Science & Engineering VI Sem- New Syllabus.pdf
Computer Science & Engineering VI Sem- New Syllabus.pdfComputer Science & Engineering VI Sem- New Syllabus.pdf
Computer Science & Engineering VI Sem- New Syllabus.pdf
chandangoswami40933
 
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdfTheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
Ortus Solutions, Corp
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
widenerjobeyrl638
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
alowpalsadig
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
kalichargn70th171
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
Anand Bagmar
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
sandeepmenon62
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
dhavalvaghelanectarb
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
VictoriaMetrics
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Peter Caitens
 
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
manji sharman06
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 

Recently uploaded (20)

Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)Hyperledger Besu 빨리 따라하기 (Private Networks)
Hyperledger Besu 빨리 따라하기 (Private Networks)
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
Optimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptxOptimizing Your E-commerce with WooCommerce.pptx
Optimizing Your E-commerce with WooCommerce.pptx
 
The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024The Rising Future of CPaaS in the Middle East 2024
The Rising Future of CPaaS in the Middle East 2024
 
Hands-on with Apache Druid: Installation & Data Ingestion Steps
Hands-on with Apache Druid: Installation & Data Ingestion StepsHands-on with Apache Druid: Installation & Data Ingestion Steps
Hands-on with Apache Druid: Installation & Data Ingestion Steps
 
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISDECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSIS
 
Computer Science & Engineering VI Sem- New Syllabus.pdf
Computer Science & Engineering VI Sem- New Syllabus.pdfComputer Science & Engineering VI Sem- New Syllabus.pdf
Computer Science & Engineering VI Sem- New Syllabus.pdf
 
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdfTheFutureIsDynamic-BoxLang-CFCamp2024.pdf
TheFutureIsDynamic-BoxLang-CFCamp2024.pdf
 
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
美洲杯赔率投注网【​网址​🎉3977·EE​🎉】
 
Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)Photoshop Tutorial for Beginners (2024 Edition)
Photoshop Tutorial for Beginners (2024 Edition)
 
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
A Comprehensive Guide on Implementing Real-World Mobile Testing Strategies fo...
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
 
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptxOperational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
Operational ease MuleSoft and Salesforce Service Cloud Solution v1.0.pptx
 
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024Flutter vs. React Native: A Detailed Comparison for App Development in 2024
Flutter vs. React Native: A Detailed Comparison for App Development in 2024
 
Upturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in NashikUpturn India Technologies - Web development company in Nashik
Upturn India Technologies - Web development company in Nashik
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
 
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdfBaha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
Baha Majid WCA4Z IBM Z Customer Council Boston June 2024.pdf
 
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom KittEnhanced Screen Flows UI/UX using SLDS with Tom Kitt
Enhanced Screen Flows UI/UX using SLDS with Tom Kitt
 
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 

ch 11-part 1.pdf

  • 2. Introduction • Computing systems often involve relating two types of value together. In Chapter 3 you were introduced to the idea of a function; you saw that a function is a set of assignments from one set to another. A map is closely related to the concept of functions. A map is a special sort of set, one which contains a set of maplets. Each maplet connects an element of one set to an element of another set; the first set is referred to as the domain, the second is referred to as the range.
  • 3. Notation • Consider Table 11.1, which shows the state of a number of different temperature sensors that monitor the condition of various items in a laboratory. The condition of each item can be either LOW, NORMAL or HIGH.
  • 4. Notation • We can express the Table 11.1 as a map, which we might call sensors. This will be a mapping from a set of sensors to the set of possible conditions. We do this as follows. – sensors = {A ↦ LOW, B ↦ NORMAL, C ↦ NORMAL, D ↦ HIGH, E ↦ NORMAL, F ↦ NORMAL} • In general terms – m = {a ↦ y, b ↦ x, c ↦ x, d ↦ z}
  • 5. Notation • Two important points should be noted here: • By definition, all the domain elements in a map are unique. • The ordering of the maplets is not significant – the map m above could be specified, without changing the meaning, as: – m = {d ↦ z, a ↦ y, c ↦ x, b ↦ x} • You should also note that the empty map is written as: {↦}.
  • 6. Map Operators • In order to illustrate the use of the various map operators that exist, we will define the following three maps, all of which map from some previously defined set (the members of which are represented here by lower case letters) to the set of natural numbers. – m1 = {a ↦ 1, b ↦ 2, c ↦ 2, d ↦ 3, e ↦ 4} – m2 = {a ↦ 2, f ↦ 1, c ↦ 7} – m3 = { f ↦ 2, g ↦ 6}
  • 7. Domain and Range operators • The domain operator, dom, returns the set of all the domain elements of the maplets. The range operator, rng, returns the set of all the range elements. – dom m1 = {a, b, c, d, e} – rng m1 = {1, 2, 3, 4 } – dom m2 = {a, f, c} – rng m2 = {1, 2, 7}
  • 8. The Union operator • The union operator, U, behaves in a similar way as it does with sets. So – m1 U m3 = {a ↦ 1, b ↦ 2, c ↦ 2, d ↦ 3, e ↦ 4, f ↦ 2, g ↦ 6} • The union operator is defined only if no two domain elements are the same; if this is not the case, then union is undefined (otherwise we would lose the uniqueness of the keys). Thus the following two expressions are undefined: – m1 U m2 ---------undefined – m2 U m3 ---------undefined
  • 9. The Override operator • In the case where two or more domain elements are the same in both maps, we can use the override operator (†). This behaves in the same way as the union operator, but if the domain element of a maplet is the same in both sets, then the second maplet wins. Thus – m1 † m2 = {a ↦ 2, b ↦ 2, c ↦ 7, d ↦ 3, e ↦ 4, f ↦ 1} – m3 † m2 = { f ↦ 1, g ↦ 6, a ↦ 2, c ↦ 7}
  • 10. Domain restriction operator • A domain restriction operator, , is defined with two operands (parameters). The first is a set and the second is a map. The result yields a map that contains only those maplets whose domain element is in the set. For example – {a, c, e} ◁ m1 = {a ↦ 1, c ↦ 2, e ↦ 4} – {e, f } ◁ m2 = {f ↦ 1} – {} ◁ m3 = {↦}
  • 11. Domain deletion operator • The domain deletion operator, , behaves in a similar way, but in this case deletes the maplet in question: – {a, c, e} ⩤ m1 = {b ↦ 2, d ↦ 3} – {e, f} ⩤ m2 = {a ↦ 2, c ↦ 7} – {} ⩤ m3 = { f ↦ 2, g ↦ 6}
  • 12. Range restriction and range deletion operator • The range restriction operator, , and the range deletion operator, , are similar to the above, but apply to the last elements of the maplets. Thus – m1 ▷ {1, 2} = {a ↦ 1, b ↦ 2, c ↦ 2} – m3 ⩥ {6, 2} = {↦}
  • 13. Map application • Applying a map is the same as applying a function, and we use the same notation. Thus if we apply our map to a particular domain element, then the result is the range element. For example, once again using the above maps: – m1(d) = 3 – m2( f ) = 1 – m3( f ) = 2 – m3(x) is undefined • Using the sensors example from section 11.2: – sensors(A) = LOW
  • 14. Using the Map Type in VDM-SL • To declare a variable to be of type Map we use a special arrow. For example, to declare a variable m that maps characters to natural numbers we would write: – m : Char ℕ
  • 15. Specifying a high security building • Only authorized employees are allowed entry to the building and each one consists of a user name (which is unique) and a password, both of which must be supplied when the individual wishes to enter the building. If the details are correct, a signal is sent to the hardware instructing it to open the door, and the member of staff is recorded as being inside the building. When the member of staff wishes to leave the building, the individual supplies his or her user name, and as long as the user is recorded as being currently inside the building, a signal is sent to the hardware to open the door, and the employee is recorded as having left.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.