Uploaded by hejterxd

2013 Book ModellingComputingSystems

advertisement
Undergraduate Topics in Computer Science
Faron Moller
Georg Struth
Modelling
Computing Systems
Mathematics for Computer Science
Undergraduate Topics in Computer Science
Undergraduate Topics in Computer Science (UTiCS) delivers high-quality instructional content for undergraduates studying in all areas of computing and information science. From core foundational and
theoretical material to final-year topics and applications, UTiCS books take a fresh, concise, and modern approach and are ideal for self-study or for a one- or two-semester course. The texts are all authored
by established experts in their fields, reviewed by an international advisory board, and contain numerous examples and problems. Many include fully worked solutions.
For further volumes:
www.springer.com/series/7592
Faron Moller r Georg Struth
Modelling
Computing Systems
Mathematics for Computer Science
Faron Moller
Department of Computer Science
Swansea University
Swansea, UK
Georg Struth
Dept. Computer Science
University of Sheffield
Sheffield, UK
Series editor
Ian Mackie
Advisory board
Samson Abramsky, University of Oxford, Oxford, UK
Karin Breitman, Pontifical Catholic University of Rio de Janeiro, Rio de Janeiro, Brazil
Chris Hankin, Imperial College London, London, UK
Dexter Kozen, Cornell University, Ithaca, USA
Andrew Pitts, University of Cambridge, Cambridge, UK
Hanne Riis Nielson, Technical University of Denmark, Kongens Lyngby, Denmark
Steven Skiena, Stony Brook University, Stony Brook, USA
Iain Stewart, University of Durham, Durham, UK
ISSN 1863-7310 Undergraduate Topics in Computer Science
ISBN 978-1-84800-322-4 (eBook)
ISBN 978-1-84800-321-7
DOI 10.1007/978-1-84800-322-4
Springer London Heidelberg New York Dordrecht
Library of Congress Control Number: 2013943907
© Springer-Verlag London 2013
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of
the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology
now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection
with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and
executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s
location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable
to prosecution under the respective Copyright Law.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication
does not imply, even in the absence of a specific statement, that such names are exempt from the relevant
protective laws and regulations and therefore free for general use.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors
or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Printed on acid-free paper
Springer is part of Springer Science+Business Media (www.springer.com)
CONTENTS
v
Contents
xiii
Preface
0 Introduction
! " # $ % & ' ( ) * + ' , " , $ * . , & / .
Part I: Mathematics for Computer Science
2 Sets
* " $ , 4 ' !
6 ' (
)
)
15
1 Propositional Logic
' 0 #22
' # 2 ' /$
* 2 0 3 3 & ( 4% ) ' # 2
1 ' ' - " 2 5 ' # 2 $2
* #22
$
( 4% / 2 ) 2 $ #5
# 2 4% 1 & 1
17
1
)
)
1
)
57
)
(
(
vi
CONTENTS
3 Boolean Algebras and Circuits
. &$' , $ !
. &$'
0% " 1 ( $ ! $ "
#2 $ " &!! . 1 3"' &!! $ . 1 3"' ." ! $ 4) &!! ." ! $ 5" &!! "
$ & 0 $ % &!!
*- 87
/
//
//
/
/
/
/
/
4 Predicate Logic
! ! 5 6 ' 7" 8 ! . " ! 6 '
, 7" 8
*- 7" 8
. " !! 7" 8
9" ) 7" 8
# ! $ ! ( $ &!!
*- 109
/
/
5 Proof Strategies
& 5 *- ) $ ) ) $ ) 3$
) $ ) :" ) $ ) :" ) $ ) 7" 8
, 7" 8
!
*+" , 131
! ! !! ! !"
# ! $ % &$' ( ) !
( $ *+" , , " !
&!!
*- CONTENTS vii
6 Functions
! "
$%& ' " $%& ' ( )* + )
!( , ! - !( 155
#
7 Relations
. /
" . /
& . /
& 1 2 ' /
$%& ' /
!( % / ' + /
3& + . /
/ 4 2
1 4 2 /
).%% .%% /
! 2 /
' /
2
/
2
$ 3 179
0
0
0
0
0
00
0
#
#
8 Inductive and Recursive Definitions
0 1 2 . ) 0 1 2 . ). ) 0 - 5 "% 0 1 2 . !.& 0
1 2 . " 0 / 2 " 0 / 2 3 00 201
#
#
#
#
0
#
% 9 Proofs by Induction
223
$ 2 ' 6 1 2 2 3% . )( 1 '%
!( 1 '%
0
viii CONTENTS
!
,
" # $ # %&& ' ( * + * -'(& %( # & -' 10 Games and Strategies
")" +..
") ") ") %( ") /' ") 0 . ")! # & -' .%
!
!
)
"
251
)
!"
Part II: Modelling Computing Systems
11 Modelling Processes
""" 1&& $ 2 "" %( "" # 1 """ $ & 0 "" # ' "" "" % "" 0 0 "" -3 &2 0 "" # & -' 12 Distinguishing Between Processes
"" $ 0 & + " ( + -3 & " 0 & 4& " 0 & %& " $ 0 & + 4 5 $
"" 7 &
" 7 & 0 & + " # & -' 277
2 02
6
279
,"
,!
)
)
309
)
"
"
"
,
CONTENTS
ix
13 Logical Properties of Processes
! " #$ % & ' ( )' * , -! .' / 01 333
%+
%
%
14 Concurrent Processes
. ( #2 $ ( 01 3 ' % $ . ' & , 01 357
%,
+
%
%
/
,
,
,,
381
/
/
/
/
/%
/,
//
9+
9
9
9,
9/
9/
9/
99
+
15 Temporal Properties
% . ' 4 % 2 5 % ! 5 % 6 5 6
% # $ % .$ # $ 07 % )1 . % 8( % $
- )1 % 1' )1 %% 01 . ' 4
%% 2 5 %% ! 5 %% 6 5 6
% ) )1 %, 01 Solutions to Exercises
405
Index
493
List of Figures
!
" # %& ' ( #
$
)) $
$
$
$
$
* ,- ¿ / 0 / 1
2 '# 3
& 4 & 50 # 6
,♂- # ,♀- .
.
.
7 $
8 # 0 #& .
9# : 6
6
6
6
6
6+
6$
61
# 0 # #& # 0 # 8& & +1
$$
$1
$
$.
16
1
!
# %( ;:< :=:7 >## =78 $ # 1 +
$ (! # 1 7 6
$
.
.1
.
+$
+.
1
1
xii LIST OF FIGURES
! HML " HML #
$ % $ & ' $ ( $
#
#
#
#$
##
#
#
" )( ) ) * # * +! , - . +! ( / +! ( $
$
$
$
$
$
Preface
!
$ ) $ $
,
(
# $ + * $ "
* + %& %& '
! "
( $
- .
. %
&
$ ' $ / $ # ' $ # ) /
0 %
,
xiv Preface
! " #$$%
& ' ( " ) * " + " & , - - , ! & ( , ! . / , ( ! & , ) ! 0 , ) 1 / ' . & , ! Æ 2 ) 1 // ) - Preface
% &
(
$ # "
#
) *
.
% (
,
$&
)
! #
-
( " ++ $ $
$ $ $ " # $
(
!
% $ &
#
'
(
" ##
" ## xv
#
xvi
Preface
Specification Implementation
Synthesis Verification !
" # " # !
$ % && &&
!
' ( ! ) ( " ( * + , . /
0 ( " % " " Æ
Chapter 0
Introduction
!
" #
$ & % % ' ( ) *
+ ' ( , - . / (
Æ 0
+ 1 % ( F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_1, © Springer-Verlag London 2013
2
Introduction
!
"
Æ $ %
% " # $ &
%
0.1
Examples of System Failures
"
0.1.1
' ( Clayton Tunnel Accident
)
* Examples of System Failures
3
Æ ! " #
" $ % & " ' $ ( )*
+ ,-., )/ 0 ,1.
' # 2 3 $ ' #
-!4* -!,* -!/4 5 " 6 ' 7 6 " 8 -!)- -!/, -!/* # " 6 ( 9 6 6 $ 6 ( 3 : 0 5 : 4
Introduction
! "
! # " " $ % ! &
' " " " "
" " " ( ' " ) *
+, - ' . / 0 12234
0.1.2
USS Scorpion
5 6378 " 99 9 33 " "
" " " " : " &
+, 0 ; < = $
633>4
" *
& ' " * : : 0.1.3
Therac 25 Radiotherapy Machine
1? +638?*8@4 *
Examples of System Failures
5
! " #$
% & $ ' 26() *+,* - *../)
0 &
1 2& ) 3 4 5 & 2& ) ) 2&
& 6 7) 0 0 )
0
8 8) 9 &
: % : ) &
& % &
; : 1 #< &
$ &
' &
1 #0 : &
' 1 " 5 5 0.1.4
London Ambulance Service
% ; *.. $ " !$=) 0 $"!$= % > 6
Introduction
! " #$ # %% & " # ' ( # ) # % ' ( *! ! # + , - . / 0
' ( . ( 1 2/// .( 3 45 %6678
$
! # , - # " 9 1
0.1.5
Intel Pentium
: 2 3 3. %665 ; : " #
; "
#
# $ " %77 < #
! * 8 = >
<
Examples of System Failures
7
Ü Ý ! " # $ % ! &" " ' '!( )*! +! , - *
0.1.6
Ariane 5
. / ! 0 % 1 - -2 !
)! 3 -2 4 - 5 )
- % %+ 4 . %+ - 6 -2 - " - 76 %- -2 " 0 % -2 - 76 % - !
0 ! - - - 88 - -2 9 7 " 7 % 7 % 0 ! - + % 1 7 6 " - % *
" % 5 - - - +7 +7 7 7 7 +7
1 4 0 % 1 - % - - 7 % 6 -- ! - 1 0: 7 1 * 1 - 5- ! - ! 76 6 76 - 6 0 . +
- 6! % % % 6 76 1 7 % %+ 4! 6 - % 0 7 6 % %+ 4 " - % % - 6 % 1 " 1 ) .;6 ' % & -+
- % % % - 6 (
7 - 1 < & - ; 6 % % - 6 % - 0
- 6 ( . - = > - 1 -6 % - & -- ! - % - +
6 ; 6( &1 ) .;6 ' !(
http://esamultimedia.esa.int/docs/esa-x-1819eng.pdf*
0.1.7
Needham-Schroeder Protocol
? - - . ! 6 - - 6 ! - 6 -6 6 % 6 6 ! - 6 - - ! 6 - % 6 - -6 "
8
Introduction
!"# $ % & ' "
( " & ) & & * & + ,- & . & '/01 '2 3 4 & '//2 . ' - & ( & "
& ) & & 5 & & & System, Model, Abstraction and Notation
9
!" # $
% & ' (
)!*+ ,*, ,*) & ,-- +
. / / Æ 0 / Æ 1 2 . / 3 . ' 1
4 5 6 0.2
System, Model, Abstraction and Notation
% ( % ( % ( %( . 6
/ 10
Introduction
System
! " ! # $ % % % $ " ! & ' ( ! ) * ! Model
+,- . +/- $ 0 $ ! System, Model, Abstraction and Notation
)
* ' #(% '
!
& #$% ¯
" ¯
Æ 11
Abstraction
, + - 12
Introduction
! " # $ %&' ((( ) * + !, - . $ % !& !&& / 0 / 1 2 3 4
5
/ 6
3 !78, # # 1 / 2 9 !78! : 4
; %4 / 4
< = 4
/ . 5 Notation
4
0 >4
* 6 > - 9 " ?@ . 4 !7'(4!7'7 6 Specification, Implementation and Verification 13
! ! " # $ % & 0.3
Specification, Implementation and Verification
" # ' ! " ( ) Specification " * Implementation ' " # ' + Verification ' " '
" , - ' " & 14
Introduction
!
Part I
Mathematics for
Computer Science
Chapter 1
Propositional Logic
# "
$ " $ % " ! & ' " " " )! ( $ % & %
%! & "
! "#
" # )
" *
! ! " # % % + ! , - ( (
! " & - . ! *
% " ! % % " " % " % & ) ( " & % " ( % " " ! % " " "
%% 1% " %
" " ( " $
! " . % %% " " $ " %
% 0
" /) " " " "
% " " F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_2, © Springer-Verlag London 2013
18
Propositional Logic
" ! "
# 1.1
Propositions and Deductions
$ %
Either this man is dead or my watch has stopped.
&
My watch is still ticking.
Therefore
'
This man is dead.
(
)
" * # statements propositions (
)
+
This man is dead.
or
% My watch has stopped.
% $ "
deduction
inference
# conclusion
+
# Propositions and Deductions
premises
19
atomic propositions This man
is dead propositional connectives or Example 1.1
$&' ( ( ! ( + ( + ( - ,
( ( + + ( (
. (
( + . ( + + ) 1 (
0 ( ) *
( ( *
+ . / # ( ) *
+ " # $%
+ ( ( + ( 20
Propositional Logic
Exercise 1.1
(Solution on page 405)
! " #
$ " %% & % ' ( ) * ) + , - ! ! . % / ! ! .0 ! 1.!
% .0 / . 1 ' % % . % 2
%! % ! % + Exercise 1.2
(Solution on page 405)
1 % %% ' 3 %! 1 1 . % -1 1 . % 4 3 %%
' 3 %! 1 1 . % 4 3 %%
4 1 1 . % ' ! %
4 %
4 $ 4 . % 1%
5 1 % 1%
4 . 4 . % 1%! 6 % 1%
7 % 1%
4 . The Language of Propositional Logic
21
Exercise 1.3
(Solution on page 406)
! " # " $ " " %# &
" ' " " %# &
( " " %# &
) " # %# &
" 1.2
The Language of Propositional Logic
syntax
*
object language
meta + language + ,
* - * . * sym * ,
bols
formulæ - - 22
Propositional Logic
1.2.1
Propositional Variables
! "
( '!#)
&
¾
# %
variables
# $
&
) ,- ' Propositional
$ ' # *
( Dead
+
.
,
.
,
,
.
,
) ,. 0 .
1.2.2
,. ) ,.
propositional connectives
() , . () , . ( ) , . (
.
(
&/
Negation
negation
(
)
' 1
+
Example 1.3
Dead
( ) ) Dead ( ( The Language of Propositional Logic
23
Exercise 1.4
(Solution on page 406)
!
" $! % ! &'
#
1.2.3
Disjunction
disjunction $ ' ( (
) disjuncts *
Example 1.4
Dead Watch + Dead Watch , Dead Watch Example 1.5
- - - , 24
Propositional Logic
RookMoved KingMoved
KingMoved
RookMoved Exercise 1.5
(Solution on page 406)
! # $% &'
$% ('
& $( )'
$* ('
% $( +'
$+ ,'
"
$ ' - / 2
3 8
1 $ ' 2
- 4 Exercise 1.6
3 . 0 1 3 $
51 ##6
&7'
(Solution on page 406)
# 9
& ! 8 1 2
: 3 ; 2
% < 1 ! The Language of Propositional Logic
1.2.4
25
Conjunction
conjunction conjuncts Example 1.6
Dead Watch ! Dead Watch " # $
% Exercise 1.7
(Solution on page 407)
& ( )* +,
+ )- .,
* )- 0,
1.2.5
'
)* -,
)/ -,
)0 1,
Implication
2 implication
3
26
Propositional Logic
Æ ¯ ¯
¯
premise
conclusion Example 1.7
SignalDanger
SignalDanger
TrainStop TrainStop Exercise 1.8
(Solution on page 407)
JoelHappy
JoelHappy
AmandaHappy
AmandaHappy
" # $ Exercise 1.9
AmandaHappy
JoelHappy
!
(Solution on page 407)
% &
' (
The Language of Propositional Logic
1.2.6
27
Equivalence
equivalence Ô ¸ Õ Ô
Õ Ô Õ Ô
Õ Ô
Õ Ô
Õ ¯Ô
¯Ô
¯Ô
Õ
Õ
Æ
Õ
¸ µ !
Ô ¸ Õ Ô µ Õ
Ô´Õ
" Õ µ Ô# Example 1.9
$ TrainEnter TunnelClear TrainEnter ¸ TunnelClear 1.2.7
The Syntax of Propositional Logic
% & ' propositional formula
¯ atomic formula È É
Ê ¯ compound formula ( ))
* true " #
false " #
& syntax * !
( )) wellformed formula "wff #
+ ( )) " # Ô
Õ metavariables
28
Propositional Logic
Ô
Õ
true
false
È
Ô
ÔÕ
Ô
ÔÕ
Ô
ÔÕ
ÔÕ
Ô
Ô
Õ
Ô
Õ
Õ
Õ
1.2.8
Parentheses and Precedences
!
% $ ' " #
" #
" " ) ( " È
É Ê
" ( %
.
" ) (
Ô
%
Õ
×
" " % %
É Ê
È
%
%
$ -
" " $
$
Ö
,
$
(
$ %
" É Ê " È
% , ! & * + % & ! & $ $ & ! & ( ! & %
% ( ( $
" $
/
The Language of Propositional Logic
29
Example 1.10
! " # & $ ' )
$ % (
% )
* +
)
' , Exercise 1.10
(Solution on page 407)
- . / 0102 3 / 04 & (
5 /
30
Propositional Logic
1.2.9
Syntax Trees
syntax tree È É È É È
É
È
!
É
È É È É ! "
$ " È É
& ! È É # È É " È É $ È É
# È É # È É È É È
É È É
%
È É È É & Example 1.11
' È É
Ê É
( È
É
É
Ê
The Language of Propositional Logic
É
È
É É Ê É Ê É È É Ê É !! Ê
31
"
È
É Ê É
Example 1.12
# #
È É ! " $$
È É È É È É È É È É É É &
# Exercise 1.12
È É *
+
,
%
%
! ! %' ( È É É È È É È È É È È É Ê Ë È É Ê È É È Ê
$ )
(Solution on page 407)
!
!
32
Propositional Logic
1.3
Modelling with Propositional Logic
Example 1.13
...
if CabinPressure < MinPressure then PrepareForLanding;
if FlightHeight < MinHeight then PrepareForLanding;
...
...
if (CabinPressure < MinPressure and FlightHeight < MinHeight)
then PrepareForLanding;
...
! Pressure Height " Land PrepareForLanding # $Pressure Land%
$Height Land%
$Pressure
Height%
Land
# Land Height Land " Pressure Height Land # Pressure Height Land " # & ' & Pressure
$Pressure Height% Land
Modelling with Propositional Logic
33
Example 1.14
! !
" ! ! ¯
! !
¯
! !
!
!
! !
!
!
! !
# $% & ' ( ! ) " * $+,%'$+-+ '
" .. ! ) Exercise 1.14
(Solution on page 408)
" /& 0 $ & 1 '
34
Propositional Logic
Æ $
'
(
)
!"" # % & # " # * # +, - . " Exercise 1.15
(Solution on page 410)
/ " +, 0
#
1 RightToCastleRight
2 # 1 MayCastleLeft 1 MayCastleRight
2 # 1 KingMoved / #"
LeftRookMoved 1 RightRookMoved
/ 1 #"
PieceBetweenLeft 1 PieceBetweenRight
/ " 1 KingAttack / " RightToCastleLeft
Ambiguities of Natural Languages
¯ LeftSquareAttack RightSquareAttack
¯ KingMoveLeftAttack KingMoveRightAttack
35
Exercise 1.16
(Solution on page 410)
! " # # $ $ % & '"
( " JonF )Joel* $ JonO )Joel* ! $ FonJ )Felix* $ FonO )Felix* ! $ OonJ )Oskar* $ OonF )Oskar* $ + % # ( "
1.4
$ )Oskar* Ambiguities of Natural Languages
, # - &&. /
" - 0 Æ 36
Propositional Logic
Example 1.16
“Everyone who sits quietly for the next hour
will get an ice cream when we stop for petrol.”
!
" “Anyone who misbehaves will not get ice cream.”
# $ % &
# #
$ ' ( $ Example 1.17
) “You may have coffee or tea with your meal.”
* + “You may have coffee with your meal
or you may have tea with your meal.”
# , , - Ambiguities of Natural Languages
37
!
" " !
“You may have coffee with your meal
and you may have tea with your meal.”
# !
!
“You may have coffee with your meal
and you may have tea with your meal,
but not both.”
$ % ! ! & You may have coffee with your meal
& You may have tea with your meal
(
'
'
(
# ! ! ! ! )* + ' ( ,
! modality may do ! ! ! & You have coffee with your meal
& You have tea with your meal
! '- ( 38
Propositional Logic
“You have coffee with your meal
or you have tea with your meal,
but not both.”
“You have coffee but not tea with your meal
or you have tea but not coffee with your meal.”
“You do not have both coffee and tea with your meal.”
“You do not have coffee with your meal
or you do not have tea with your meal.”
! " #
$
Example 1.18
%
&
+
$ ! ' $ )
*
( $ “If Carlos is a man, then Carlos is the King of Spain.”
, $ +
“If Carlos is a woman, then Carlos is the King of Spain.”
-
%
$ +
#
Ambiguities of Natural Languages
39
“If Carlos is a woman, then Carlos is the Queen of Spain.”
“If I told you once, I told you a hundred times!”
! “If he ever pays me back, then I’ll be a monkey’s uncle!”
" ! # Example 1.19
$ “If you understand implication, then you will pass the exam.”
% $ & ' $ ! ( ) * $ + , $ - # . 40
Propositional Logic
Exercise 1.19
(Solution on page 411)
! "
Exercise 1.20
(Solution on page 411)
1.5
#
"
Truth Tables
$
'
&
%
%
# (
*
negation
' *
T
truth table )
F
F
T
# +
T
F
Truth Tables
41
$
'
F
F
T
T
F
T
F
T
F
T
T
T
&
'
F
F
T
T
F
T
F
T
&
'
T
T
F
T
F
F
T
T
F
T
F
T
F
F
F
T
%
&
$
'
%
F
F
T
T
F
T
F
T
&
T
F
F
T
$
%
$
%
Example 1.20
!
“Everyone who sits quietly for the next hour
will get an ice cream when we stop for petrol.”
" Quiet # You sit quietly
Ice # You get an ice cream
$ Quiet Ice % & % !
'
Quiet Ice
F
F
F
T
T
F
T
T
&
Quiet Ice
T
T
F
T
$
%
ÓÒÐÝ Quiet Ice % 42
Propositional Logic
! " #$
Exercise 1.21
(Solution on page 411)
% &' (() *
“If you understand implication, then you will pass the exam.”
! Example 1.21
+ , , , , # - Cat . Catherine goes to the party
Jim . Jim goes to the party
Jules . Jules goes to the party
+ # Cat
Jim Jules ! + , , # / Cat Jim Jules 0 ! Truth Tables
'
$
Jules
Jim
Cat Jim Jules
F
F
F
F
T
T
T
T
&
F
F
T
T
F
F
T
T
Jules
Cat
T
T
T
F
T
T
T
F
Jules
%
Cat Jim
Jules
Jules
T
T
T
T
T
T
T
F
Jim
F
F
F
T
F
F
F
T
Cat Jim
Jules
Jim
F
T
F
T
F
T
F
T
43
Jim
! " #
F
F
T
T
F
F
T
T
F
F
F
T
F
F
F
T
F
T
F
T
F
T
F
T
´¼µ
´½µ
(4)
´¿µ
´½µ
´¾µ
´½µ
Jim
%
%
$
T
T
T
F
T
T
T
F
Jules
T
T
T
T
T
T
T
F
´¼µ
%
F
F
F
F
T
T
T
T
´¼µ
Cat
& ( Cat Jim Jules
F
F
F
F
F
T
F
T
F
F
T
T
T
F
F
T
F
T
T
T
F
T
T
T
&
$ '
' Cat
Jim Jules
44
Propositional Logic
Jim
Jim
Jules
Cat
Jules
Jim
Jules
Exercise 1.22
(Solution on page 412)
! È " É" Ê Ë #
Ò $ Exercise 1.23
#
#
È É
È É È É
È É Ê Ë Exercise 1.24
(Solution on page 413)
'( )
ÔÕ
'
ÔÕ
Ô Õ
F
F
T
T
F
T
F
T
F
T
T
F
&
(Solution on page 412)
% &
$ "
ÔÕ
" "
*
$
%
Ô Õ
% ( &&+
ÔÕ
, (
Equivalences and Valid Arguments
1.6
45
Equivalences and Valid Arguments
Cat Jim Jules
Cat Jim Jules
! Cat Jim Jules Cat Jim Jules Cat Jim Jules
Cat Jim Jules " # $ logically equivalent tautology valid contradiction unsatisfiable %
& & satisfiable Example 1.24
" ' ! ( #
F
T
T
F
T
T
F
T
T
F
F
F
( ( ) * + + 46
Propositional Logic
Exercise 1.25
(Solution on page 413)
!
"
%
%
&
# '
$
()
Either this man is dead or my watch has stopped.
My watch is still ticking.
Therefore
"
This man is dead.
# Dead
+ %
%
Watch
*
%
Watch &
- % Dead
F
F
T
T
Watch F
T
T
T
%
'
Dead Watch
F
F
F
T
T
F
T
T
F
T
F
T
Watch F
F
T
F
T
F
T
F
F
T
F
T
$
T
T
T
T
$
Dead
F
F
T
T
%
. /)
My dog doesn’t bark.
My dog bites.
)
If my dog barks, then my dog doesn’t bite.
, &
Therefore
# )
Dead
#
Algebraic Laws for Logical Equivalences
'
Barks Bites
F
F
F
T
T
F
T
T
Barks
F
F
T
T
T
T
T
F
&
T
F
T
F
F
T
F
T
T
T
F
F
Bites Bites
F
F
T
T
F
T
T
T
F
T
F
T
%
counterexample
(Solution on page 414)
!"
##$ %
& Pressure
Land Height
Land
' &
Pressure Height
&
Pressure Height
) Land
* Land(
1.7
$
Barks
T
T
F
F
Exercise 1.26
47
!" %
Algebraic Laws for Logical Equivalences
+
* -
* "
$
* ./0
, & 12
$
. / 0
& $
.
/ $
0
&
#1
/
#0
&
12
/ &
/ (
48
Propositional Logic
!
"
!
"
!
"
!
"
De Morgan’s Laws
!
"
!
"
!
!
"
true
true
false
true
"
!
"
Implication Law
"
"
false
false
!
!
Absorption Laws
true
Excluded Middle Laws
Contradiction Laws
!
Tautology Laws
Double Negation Law
!
Distributivity Laws
Idempotence Laws
Associativity Laws
Commutativity Laws
false
"
"
!
"
Algebraic Laws for Logical Equivalences
49
Contrapositive Law
Equivalence Law
" & !
$ %
# ' ' ( Example 1.26
) ' ' !
true true
) ' ' true
Example 1.27
) !
50
Propositional Logic
true
true
true
Exercise 1.27
true true
(Solution on page 415)
! "
#
$
%
&
1.8
Additional Exercises
! ' )!* ), (
+
). )
(+
- +
+
Additional Exercises
51
! " ! # " $ %
% " "
& % " & & ' # %( ) ** +
Æ , -
* ** + . **& +
+
. *
/*
**
. ** " ** ½ +
. ** ¾ +
/*
*
**&
*
. ** /*
*
**& *
)
0
*
**
1 2 3
4 5 4
52
Propositional Logic
" # #
#
" $
% &
! $
CatAway
' '
! MicePlay
'
'
! ! '
! ( ) $
*
“Every card with a circle on one side
always has stripes on the other side.”
' +
" Wason Selection Test
. * /(00 1 ,
2345
Additional Exercises
53
! ! " #
$
%&
' ()(*! (+, & ! ' ! . &
& / 0 1 & ! 2
& ' 3 & 3 & ! ! ()(*
(+,
4 ) # & & 5
!
& /2
2 ! !
2 ! & $
6 5 ! & ! ! 9 5 ) " & ! ) 7 ) ! 87 5 $ " 7 $
: )
3 ;
5 3 ! &
& !
# 3 &
& 5 3 &
&
5 3 !
) < & !
& !
&
&
& 2
54
Propositional Logic
' ! "
,
++
,
30
1
1
!
0 .
-
0 ' 1 "
) 4
! .
1 0 0 &
#* 2
( ( /
' ( '
#$ % )
1
1 ! ! Additional Exercises
! " # %
!
! $ ) ( * % )
! " ! +/0
! %
! .& !
% 0 %
%
% +, - & ' (
+1 - 55
& ! Chapter 2
Sets
! "
#
$ % & % &
% &
% &
'
% &
% & # % (&
% & 2.1
'
Set Notation
)
set
* members
# * elements cardinality # *
'
false true +
,
- ./
+
+
0 1 2 ) ) 3 4 5 6 ! +
F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_3, © Springer-Verlag London 2013
58
Sets
! " #
¯
$ %
% ( $$ $ $(
&& '
'
) *
+ + , - + . ) $( $ / ' ) 0 1 2
3
4 set-builder notation #
#
5 3
6 Example 2.1
#
$ 0 / #
#
0 / 1 7 #
# 1 7 #
#
#
#
Membership, Equality and Inclusion
59
!
"
! " # $
$ # " ! " # $
%
!
% & ' ( Exercise 2.1
(Solution on page 416)
) " % !
* # % $ % + ,--- . % / 0 Æ 2.2
Membership, Equality and Inclusion
( 1
2 Membership
3 $ 3 ". 4 3 $ 3 ". 5
60
Sets
" Exercise 2.2
!
!
(Solution on page 416)
# $ % & % &$
& !
!
)!
Exercise 2.3
' % ( ) ' % ) ( ) * !
) * !
(Solution on page 416)
#& % $+
) !
) ) !
) ) !
!
!
! )
)!
!
!
*!
,&
- equal . ! , $ & $ $ $ &
/ ! "$ (
(
!
0 $ 1 $Æ& - &2 & !
Exercise 2.4
(Solution on page 416)
#& % 3$ +
Membership, Equality and Inclusion
¯
61
subset superset
!
" #
$ % & Example 2.4
" !
" '
' Venn diagrams ( & ) * + , * + * + , - . & / '
universe of discourse ) 0 1!
62
Sets
Í
!" ## $ # % #" &'
# ! ( ' #&! & !& ( & # )& " ( )& " ) Exercise 2.5
(Solution on page 416)
*# &) )&&' && & +
, &! $& ' # & )&&' # & &) ! & &) '# &!$& - reflexive & )& $" - antisymmetric - transitive ) ) .&&$ " ' # & # & ( #& " & & )& # Sets and Properties
2.3
63
Sets and Properties
Primes ! Primes " Primes #$ $ % " $ & ' #$ $
( ! $ ) $ $ "
" " ( ! #$ $ Example 2.5
* $ & $ $ $ ' +$$!
,
- Animals Humans $ Humans Animals "
( Humans Animals Example 2.6
. $ "
Ê
/ $$
64
Sets
Ê
Ê
Ê
Ê
! " Example 2.7
#
"
$ "
#'
%
" (
&
!! " 2.3.1
% &
$
#'
) $ % & (
#' (
Russell’s Paradox
)
*
-
" ! !
"
"!
+
'
. - " . )
. #
/ 0!!
*
," )
" "
!! " 1 Operations on Sets
¯
65
! Russell’s Paradox " # $ !
% & ' # # ( &
Exercise 2.7
(Solution on page 416)
) # ' * +
2.4
+ , + ( "- . Operations on Sets
$ & $ 2.4.1
Union
union / 0'
) '
66
Sets
Í
Example 2.8
!
Example 2.9
" % & % & '
2.4.2
# $ # $ (
Intersection
intersection "% !
*
" )
*
"
Í
Example 2.10
!
Operations on Sets
67
Example 2.11
disjoint ! " " Theorem 2.11
Inclusion-Exclusion Principle
2.4.3
" Difference
difference # $
Í
Example 2.12
% & ' ( ) & ( * + %,
% ' ) 68
Sets
Example 2.13
! " #$ ! ! 2.4.4
Complement
complement %# ' ' & (
(
& '$
' & $ )# &$ # * Í
Example 2.14
+'& ' ' , - $
, - $
, -
Example 2.15
+'& ' ' $ & & !
! . & & Operations on Sets
Exercise 2.15
69
(Solution on page 416)
! " # #
# $ % # $ %
# $ % #
# $ % #
2.4.5
(Solution on page 417)
#
#
#
#
#
Exercise 2.16
&
!
(
(
+
(
(
' #
!
!
! )" ) '" )" ) '" *
! ! *
*
*
*
Powerset
, powerset $ % $ % "' #
, "!
$ %
#
( " ! $ % $ %#
+ ) ' "' # ( ') ¬Ò $ % "' ¬Ò $% - #
70
Sets
Example 2.16
! " # $% &'
# $% &'
( ( ) # $% &' ( # $% # &' # ( $% &' $% ( &' ( # $% &' # &' ( # $% &'
# $% ( $% &' ( ( % Operations on Sets
¯
71
¯
Example 2.17
$ % & ' (
! "! # " Friends
# $ % & ' "!
! Friends
! ! ) "!
" ./ (
Exercise 2.18
)
Friends
Friends
! Friends
,
0 1
2 ! "! Exercise 2.19
(Solution on page 418)
. (
(Solution on page 417)
+ *
" " " $ & # % ' Exercise 2.17
* 1
(Solution on page 418)
3 ! 1
$ -
72
Sets
2.4.6
Generalised Union and Intersection
!
" !
% !
" "
"
# $
! "
" % !
$
%
!"
Ë
Ì
%
%
$ (
)
$
Ë
% % Ì $
&
$
Ë % Ì Ë ! " % Ì ! "
%
Ë
Ì
% % Ì * + %
# %
'
!
Ë
Example 2.19
+ ,+'-' ClassLists ,+'-' ClassLists # Students
Ordered Pairs and Cartesian Products
Students
73
Ë ClassLists
Ì ClassLists Exercise 2.20
(Solution on page 418)
Ì
2.5
¬Ò
Ë
¬Ò
Ordered Pairs and Cartesian Products
ordered pair first coordinate second coordinate ! " # $ ! # ! $ % " & Cartesian product ' ( Ê Ê Ê ¾ ! Example 2.20
) *+ , *+ ,
' - + + + 1
1 + 1 1
+ 1
*+ , *+ , .)/ 0 + + 74
Sets
Example 2.21
Keys Values Keys Values ! " # $ # %
IDNumbers & '( )*+,-
'. " /0+)-
'1 *23)-
'! 4*5+-
! " %
CapitalCities & '. 6 -
'6 7 -
'( -
' -
8 Æ . " & ' - % ' - # $ # Ê & Ê Ê Ê 9 $ & & ¿
Ordered Pairs and Cartesian Products
75
Example 2.22
Example 2.23
pixel ! ! "# $$% # & " # ' RGB model
( % !¿ % ! ) Ê * % % # + # , % % % # - % % % % % % . (
*
Pixel
) ! ! ) % !¿
Colour
( Point
) Pixel Colour
# " ( Exercise 2.23
(Solution on page 418)
" /0 # / 0 1(
76
Sets
2.6
Modelling with Sets
Example 2.24
! " # $ % & ! ' ( ) Exercise 2.24
(Solution on page 418)
* !
,
1
2
3
+ , - !!. /
" 0 /) " " /
4 Modelling with Sets
77
Exercise 2.25
(Solution on page 419)
All babies are illogical.
Nobody is despised who can manage a crocodile.
Illogical persons are despised.
! ! !! Exercise 2.26
(Solution on page 420)
All oceans are full of water.
No ponds are oceans.
Therefore no ponds are full of water.
Example 2.26
! " #$ !
" " ! %& ! '( " ! ) *" %% " ! " ! + * ,
- ! " ,
,
,
, , ,
,
78
Sets
¯ ! ¯ " ! # $ ¯ %# && ! ' ( ¯ ) ! ' * ¯ &+ &, '
- ¯ , &* ' + ¯ ) -, !
, . /
(
,
*
+
$
% . / - , $ * + ( 0 , # ! . /
Algebraic Laws for Set Identities
¯
¯
79
¯
¯
¯¯¯ ¯ ¯
¯
¯
¯
¯
¯ ¯
¯ ¯¯ ¯¯
¯
¯ ¯ ¯¯ ¯ ¯ ¯¯
¯¯ ¯ ¯ ¯ ¯¯ ¯
¯
¯
¯
2.7
Algebraic Laws for Set Identities
! "
" # $ Commutativity Laws
%
% Associativity Laws
& ' % &
' & ' % & ' Idempotence Laws
%
%
Distributivity Laws
& ' % &
' &
'
& ' % & ' & '
De Morgan’s Laws
&
' %
Double Complement Law
& ' %
80
Sets
Universe Laws
Empty Set Laws
Complement Laws
Absorption Laws
Exercise 2.27
(Solution on page 420)
! Example 2.27
#
" Exercise 2.28
(Solution on page 420)
$ % &
! ' ( ! #
! ! ! Logical Equivalences versus Set Identities
81
Í
Example 2.28
! " #
$ " " " #
% #
Exercise 2.29
(Solution on page 421)
& #
2.8
Logical Equivalences versus Set Identities
' $ ( $ ) *#+ ) ) ,#+# - . .#
Commutativity Laws
Commutativity Laws
" " Associativity Laws
Associativity Laws
! ! ! ! ! " ! ! " ! Idempotence Laws
Idempotence Laws
" 82
Sets
Distributivity Laws
Distributivity Laws
De Morgan’s Laws
De Morgan’s Laws
Double Negation Law
Double Complement Law
Tautology Laws
true true true
Contradiction Laws
false false false
Excluded Middle Laws
true
false
Absorption Laws
Universe Laws
Empty Set Laws
Complement Laws
Absorption Laws
false true Additional Exercises
83
Example 2.29
Implication Law true ! "
Exercise 2.30
(Solution on page 421)
# $ Contrapositive Law % Equivalence Law " "
& $ ' $ ( Exercise 2.31
(Solution on page 421)
) "
* + 2.9
Additional Exercises
, % - . / . / 0 1 2 % . 0 1 ) 3
" " 84
Sets
! ## # $ " % ## & ' ##
) !
+
*
,
,
- .
(
(
* " $ & ##
" $ & symmetric difference
#
# 0 / ## # Additional Exercises
# $
%
85
!
! "
%
&
&
&
) ' ( !(
% , .' (
%
% .' ' . ( % % *
!
#
"
!
! "
'
' $ ' '
6 .
7
,-
2
!
3 !
' (
! '
* 2 %
#
2 %
( ! !
% !
$
! # 8' ( * 9
%
* % !
' % !
( %
( ' '
autological
( * :
" *
" % % *
* $
$
! !
/ 5
' ! * ( ! " '
( ! ' ( '' % 1
.' 2 ,-
1 %
' 4 3 ' ! /
0
' +
!
*'
" '
"
1 ! 1 $ ' /( ' -
( '
%
*
*
:
8
* *
( ( * 9
' % 8
$ ( * .(
heterological " ! 9
" ' % 8 "9
7
86
Sets
Chapter 3
Boolean Algebras and Circuits
algebras Boolean
! " #
& ' "
&
logic gates % ' ( T
' ( * F
% &
$
% ( ) 3.1
' ( ! Boolean Algebras
Boolean algebra
% & + ¼
'
( zero
'
( unit sum product complementation " + Laws of Boolean Algebra
¼
'
"
-
F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_4, © Springer-Verlag London 2013
. &
, (
88
Boolean Algebras and Circuits
Commutativity:
Associativity:
Distributivity:
Identity:
¼
Complement:
¼
! " # $ # " !!
%" " Example 3.1
The Boolean Algebra of Sets
& & & & ' # & & & & ! #
$ ! & & ! !( " ) ! *+
Commutativity:
Associativity:
Distributivity:
Identity:
Complement:
¼
Boolean Algebras
Example 3.2
89
The Boolean Algebra of Propositions
false true !
" # $ % &'
¼
Commutativity:
Associativity:
Distributivity:
!
!
!
!
false
true
Identity:
Complement:
Example 3.3
!
!
! ! !
!
true
false
The two-valued Boolean Algebra
($ $ # '
¼
) $ $ Exercise 3.3
(Solution on page 421)
* ( + $ $ $ , -$ !! $ ¼
¼
¼
90
Boolean Algebras and Circuits
3.2
Deriving Identities in Boolean Algebras
! " # $
! %& Theorem 3.3
Further Distributive Laws
Ü ' Ý Þ ( ÜÞ ' ÝÞ
ÜÝ ' Þ ( Ü ' Þ Ý ' Þ Proof:
" ) Ü ' Ý Þ ( Þ Ü ' Ý ( ÞÜ ' ÞÝ
( ÜÞ ' ÝÞ
Theorem 3.4
Idempotence Laws
Ü'Ü ( Ü
ÜÜ ( Ü
Proof:
" ) Ü ' Ü ( Ü ' Ü*
(
(
(
(
Theorem 3.5
! Ü ' ÜÜ ' Ü Ü ' ÜÜ
Ü'+
¼
¼
Ü
Domination Laws
Ü'* ( *
Ü+ ( +
! Deriving Identities in Boolean Algebras
91
Ü Ü Ü Ü Ü Ü Ü ÜÜ
Proof:
¼
¼
¼
Theorem 3.6
Absorption Laws
ÜÝ Ü
Ü Ü Ý Ü
Ü
Ü ÜÝ Ü ÜÝ
Ü Ý ÜÝ Ü
Ü
Proof:
Theorem 3.7
Ü
Ý ÜÞ
Proof:
Ý
Ý Ü Ý Ý Ü Þ ÝÜ ÝÞ
ÞÜ ÞÝ
Þ Ü Ý Þ Ü Þ Þ
ÜÝ
ÜÞ
Ý
Þ
92
Boolean Algebras and Circuits
Ü Ü ÜÜ ! " Ý # Ü ¼
¼
¼
Theorem 3.8
Uniqueness of Complement
ÜÝ
Proof:
ÜÝ Ü Ü
Ü
ÜÜ ¼
Ý
¼
Ü
¼
¼
$ Ü Ý ÜÝ ÜÝ ÜÜ
¼
ÜÜ
! %& Ý Ü ÜÝ
¼
¼
Theorem 3.9
Involution Law
'Ü ( ¼
¼
Ü
Proof:
Ü
¼
'Ü ( Ü Ü
Ü 'Ü (
¼
¼
¼
ÜÜ
! %& 'Ü ( Ü
¼
¼
¼
¼
¼
Exercise 3.9
¼
(Solution on page 422)
) ¼
Theorem 3.10
¼
De Morgan Laws
'Ü Ý ( 'ÜÝ( ¼
ÜÝ
¼
Ü
¼
¼
¼
Ý
¼
The Duality Principle
93
Æ Ü ÝÜ Ý Ü Ý Ü Ý !"" # " $% & Ü Ý Ü Ý Ü ÝÜ Ý ÜÜ Ý ÝÜ Ý Ý Ü
Ü Ý Ü Ý Ü Ý Ü Ü Ý Ý Ý Ü Proof:
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
Exercise 3.10
(Solution on page 422)
' & " ÜÝ Ü Ý ÜÝ Ü Ý
( ) ÜÝ ÜÞ Ü Ý Ü Þ Ý Þ
$ ) ÜÝ Ü Ý * Ü Ý ÜÝ Ü Ý Ý
¼
¼
¼
¼
¼
¼
¼
¼
3.3
¼
The Duality Principle
+ " , & dual " &&
& - & "
& , & " " # " Ü Ý Þ ÜÝ Þ # & " , & ¼
Theorem 3.11
¼
The Principle of Duality
# " " " " " Proof:
94
Boolean Algebras and Circuits
Example 3.11
Ü Ü Ý # Ü "Ü Ý Ü "Ý
Ü Ý"
Ü"
Ü
Ü ÜÝ ! Ü
$
%&' ' ' ) Ü!
ÜÜÝ ) ($
' ' + , ' + , Exercise 3.11
$
* (Solution on page 423)
- / ÜÝ Ü¼ Ý ¼ ¼
ÜÝ
¼
0 #
ÜÝ
Ü Þ
% #
Ü Ý
" 1
' ( # ' * $
' (
Ü
" ' ܼ Ý Ü
'
Ü Ý
¼
Ý
Ý
Ü Þ
¼
Ý
Þ
"
ÜÝ
¼
ܼ Ý
Ý
.( %/"
Logic Gates and Digital Circuits
3.4
95
Logic Gates and Digital Circuits
bits ! " # $ % Example 3.12
"! & "!
' ( & # ( " ) *
( "! ) ( ( + ( " 96
Boolean Algebras and Circuits
OR gates AND gates NOT gates OR gate Ü
Ý ÜÝ ÜÝ !
Ü
Ý
" Ü
Ý
Ü Ý
AND gate Ü
Ý ÜÝ !
Ü Ý Ü
Ý
" Ü
Ý
Ü Ý
NOT gate Ü Ü ¼
Ü ¼
!
Ü!
Ü
" Ü
Ü
¼
# Ü Ý
! !
!
!
Ü Ý
!
Ü Ý
! !
!
!
ÜÝ
!
!
!
Ü
!
Ü
¼
!
$ & % ' (& )) * ÜÝ ÜÝ # %
Logic Gates and Digital Circuits
97
Example 3.13
! "
Ü
Ý
Ú
Þ
Ù
Û
# Ü$ Ý Þ # Ü Ý %& Ù ' ÜÝ ( $
Þ %)# Ú ' Þ # Ù Ú * )+ * Û ' Ù , Ú # - $ $ Û ' ÜÝ , Þ # "
¼
¼
Ü Ý Þ
Ù Ú
Û
.
.
.
.
/
/
/
/
.
.
.
.
.
.
/
/
/
.
/
.
/
.
/
/
.
.
/
/
.
.
/
/
.
/
.
/
.
/
.
/
/
.
/
.
/
.
/
.
0 $ Ü'/$ Ý '. Þ '/$ %& .$ %)# 1 )+ .$ Û ."
Ü'/
Ý'.
Þ'/
.
.
Û'.
# * Û ' ÜÝ , Þ È É Ê $ $ ¼
98
Boolean Algebras and Circuits
Example 3.14
¯
¯
¯
¯
¯
! "# $ "# $ "# $ ! %& $ ' ! %& ! $ ' (
(
(
(
)
)
)
)
(
(
)
)
(
(
)
)
(
(
(
(
(
(
)
)
(
(
(
(
(
)
)
)
(
(
(
)
(
)
)
)
" $
'
$
(
)
(
)
(
)
(
)
(
(
(
(
(
)
(
)
(
(
(
)
(
(
(
)
'
'
$
'
' Logic Gates and Digital Circuits
Exercise 3.14
exclusive-OR gate
XOR gate
!
!
!
!
!
# Exercise 3.15
¨
!
¨
"
Exercise 3.16
¨
"
! # %
(Solution on page 424)
&
#
(Solution on page 423)
¯
¯
¯
$
(Solution on page 423)
99
'
! (
! (
! # ' ! 100 Boolean Algebras and Circuits
3.5
Making Computers Add
3.5.1
Binary Numbers
¯
, ¯
+ * ! $ &
%
' (
)*+,
¯
¯
$ % # ! " ,
% -
$
+ * ) $
"$ ) ! "
)*+,
.
* + , )
/
/
/
¿
¾
½
¼
.
.
.
.
* + , )
.
)
.
*
.
+
.
,
)*+,
0 !"
-
(
'
'
% Making Computers Add 101
¯
¯
¯
¯
¯
!
"
!
"
#
$% & & &% & &%
*
& & (
& & ( &% & '
& +
%
%) %
Example 3.16
( , &%)
¯
& - ,
( #
¯
& #
( -
¯
¯
-
( ( & & . ¢
¢
& , -
¢ -
-
¢ ¢
¢
!
¢ ¢
"
¢ ¢
¢ ¢
,
&% )
102 Boolean Algebras and Circuits
3.5.2
Adding Binary Numbers
Example 3.17
!!!"! !"!!" # $
½ ½ ½
!!!"!
!"!!"
!!""!!
! " ! ! % Exercise 3.17
(Solution on page 424)
% &
#
' ( )# #
¿ ¾ * *# $
Making Computers Add 103
3.5.3
Building Half Adders
! "#$% & % ' half
adder ( ) & * % + % , - .+ , / %
) % +
¼
¼
¼
¼
¼
¼
/ ¼
¼
¼
+
/ ¼
0 12 +
, / ¼
¼
, + 12 % 1( (3 4 + ' 4 ) 0 ) 5 6 % & +
104 Boolean Algebras and Circuits
!
" # $ % #& ¼
¼
¼
¼
¼
¼
¼
¼
¼¼
¼
¼
¼
¼
¼¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
' $ ( ) ) # * + 3.5.4
Building Full Adders
' ! ! , ( - "
, full adder ./
0 1 2 $ Making Computers Add 105
!"# " # " #
" # " #
$ %& '( ÜØ
Ø
'( ÝÞ
¼ ¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
3.5.5
¼
¼
¼
¼
¼
¼
Putting It All Together
' ) * + ,* ,* ¿¾ -* '(
.(
.(
.(
/ 0 ) % 106 Boolean Algebras and Circuits
3.6
Additional Exercises
! ! "
# $ # % & & ' & ( lcm ") gcd ") $ &
¼
* + $ # * , # #
-. # / 0 ¬Ò " & ( + ! !"1 2 ! ! ¼
% " " 3 4
¼
! ( $ ¼
"
, " " 3 $ & $ ! ( $ &
¼
¼
"
NAND gate 0 & &
&
&
!"5
$ &
$ & ) " 6 78 67 " 3 66 9
NOR gate 0 & &
&
&
&
&
&
( ¼
!"5
$ !
Additional Exercises 107
! " "
# $ # " % &
! ¼
' " " ( % % # % % % ¼
¼
¼
¼
# # #& ( # ) #
* +( , " " # . #
# + )" + , )"
/ " 01 + 01 + , & )" "2 &
" 3 multiplexer ¼ ½ ) 4
108 Boolean Algebras and Circuits
× Ü ¼ ܽ
Ö
ܼ
Ö
ܽ
×
× Ü¼ selector Ö Ü½ ×
Ö ! × Ü¼ " ×ܽ #
¼
Chapter 4
Predicate Logic
! " #
$ % "
4.1
& "
" " quantifiers
&
predicates
&
" Predicates and Free Variables
'
( Ü
#
Ü
) #
Ü
* Ü
"
* predicate " " "
È
. "
" (
#
È
"
Ü
" #
" È +Ü,
È
Ü "
F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_5, © Springer-Verlag London 2013
- * Ü
$ " 110 Predicate Logic
&
free variable '
* "
&
# ! # $ % # ! ' ))
truth set
"
(
Example 4.1
+ ,
"
- . / , , . +
0
, "
1
# . , - / .
+ , . , 2 0
1 0 1
# $
0 1 0
1
# 3 3 # 4
Quantifiers and Bound Variables 111
Example 4.2
! "
! #$ Exercise 4.2
"
(Solution on page 424)
%
& ' (
& ' (
& ' (
& ' * & (
#
)
4.2
Quantifiers and Bound Variables
+ , - $ . / 0 1 ! , / - $
. / 0
112 Predicate Logic
Children
! " % " & " #Ü$
%
% %
& " #
(
'
# $
$
%
"
#$
#
$
% " #Ü$ " Ü ) " %
" #
$
# $ #$ #
$$
#
$
# $ #$ #
$$
#
$
# $ $$
#
$
# $ #$ #
#
#
#$ #
#
* )
)
)
2 +
#/$
#0$
-
#11$
' Ü
" " #Ü$ -
" % , #.$
% % % " $$
#
% Ü
# $ ' #1.$
Ü
, , % , Quantifiers and Bound Variables 113
! quantification
!! ! !
" #! 4.2.1
Universal Quantification
$! ! ! È Ü Ü %
Ü È Ü
!! Ü È Ü
&
" ! #! (
È Ü '
Ü
universal quantification ) !
( Ü *+ !
,
"
Ü Ü
!! " ! ! -
#!
! !
Ü Ü
Ü !
'
! ' ! ! ! ! !
' '" ! .
/
% ! ' ! & Ü0
Example 4.3
#! %
Ü À Ü
!
À Ü
1
Ü ! !
bound variable &
114 Predicate Logic
Example 4.4
!" Ü Ã Ü É Ü Ã Ü # Ü ÉÜ # Ü !" " " " " " " Ã Ü É Ü " Ü $ Ã Ü $ Ü $ ÉÜ % Ü
& ÉÜ " " & " ' !" !" Ü Ã Ü É Ü Ü Ã Ü É Ü " Quantifiers and Bound Variables 115
Ü
Example 4.5
Exercise 4.5
(Solution on page 424)
! " # % &
' (
4.2.2
$
$
$
Existential Quantification
) 116 Predicate Logic
Ü È Ü
È Ü Ü
Ü Ü Ü
"
# $
!
Ü%
Ü Ü Ü "
! ! !
# ! ! "
# Example 4.6
& '
Ü À Ü
À Ü
&
! À Ü ! *+ ! ! ' ! ) ,
& # & Ü (
,
Example 4.7
& '
Quantifiers and Bound Variables 117
Ü
Exercise 4.7
(Solution on page 424)
! " Exercise 4.8
(Solution on page 425)
'
'
!
"# !
# $ % &
118 Predicate Logic
4.2.3
Bounded Quantifications
bounded quantification ! ! "
# $
# ! " Quantifiers and Bound Variables 119
Example 4.8
!
'
! &
&
' ()* +
, ¾ , ¾ &
$ , $¾ &
& '
# $%&
, ¾ , ¾ " ' -
'
&
& Example 4.9
. '
// # ((% ' )$ 0 & 1 2 3 -
& & ' & 6Oskar7 8
, -
& 5
5 3 6Joel7 9 3
3 0 4
0 1 2
,
4 4
' '
' 9
6Oskar 7 9 6Felix7
1 &
( # #
) ' 120 Predicate Logic
Oskar Exercise 4.9
(Solution on page 425)
!
"
4.3
Rules for Quantification
# $ ($ )& & $ $ % $
% $ & ' &
$ $ $ % $
% $
' &
* + , $%
($ - ($ - $% $ '
) - .$&
) - .$ /$ 0 *
Rules for Quantification 121
Example 4.10
Ü !Ü"
# $ $ # !Ü" Ü # % & '
Children ( ) ) % % * ! " ! "
' ! ) " # '
! "
* # ! " ! "
+ % # % ,
' ! "
# $ $ # ! " #
% # '
! "
* # ! " ! "
Exercise 4.10
(Solution on page 425)
# ) # %
) * - ) 122 Predicate Logic
! " # $ % &
' ' # $ (
ÜÈ Ü ÉÜ ÜÈ Ü ÉÜ
)
ÜÈ Ü ÉÜ
ÜÈ Ü ÉÜ
ÜÈ Ü
ÜÈ Ü
ÜÈ Ü
ÜÈ Ü
* ÜÉÜ
ÜÉÜ
ÜÉÜ
ÜÉÜ
+ , È Ü ÉÜ ' Ü$ È Ü ' Ü ÉÜ ' Ü
" $ È Ü ' Ü ÉÜ ' Ü$ È Ü ÉÜ ' Ü
+ , È Ü ÉÜ '
' Ü ÉÜ Ü$
È Ü ' Ü
!$ È Ü ' $ ÉÜ ' $ È Ü ÉÜ ' Ü
- % $
Ü Ü Ü
" % (
Ü Rules for Quantification 123
Ü
Ü Ü ! "
Ü
¼
# $ " % & " & ' (" & & " & )
& & * ) " ) " ) ! "
# ¼
+ $ " % & & & (" & & & , - ) " '
$ ) - * - % .
" ) * )
/ - 124 Predicate Logic
Example 4.11
Ê Ê
! " !! ! " ! !
! # ! ! 4.4
Modelling in Predicate Logic
! $ ! % Example 4.12
& ' !(( )# $ All babies are illogical.
Nobody is despised who can manage a crocodile.
Illogical persons are despised.
! * !
! + + + + Modelling in Predicate Logic 125
Ü ! " " Exercise 4.12
(Solution on page 426)
# $ % &
' (
Example 4.13
# ) * +, -- . .
/ ! , . * 0 & -- $ -- # ) $ ! 1 " 1 2 , 1 ! 3 4.5
. 6 . ."
126 Predicate Logic
¯
¯
¯
! " # $ % & ' $ % (
) # )
* # $ + ,%
$. %
$0 0%
$ / .%
$/ . .%
$, 0 %
$- . 0%
$+ / %
$ %
$ -%
$. / %
$0 .%
$ , 0%
$/ / ,%
$, -%
$- 0 %
$+ ,%
$ . +%
$0 - %
$ - ,%
$/ + /%
$, / %
$- , -%
1* # " # $0 + +%
$- %
Additional Exercises 127
)
* ! !
! #$!
! %&!
#$! !
#$! #$!
#$! %&!
%&! !
%&! #$!
%&! %&!
"
#
'
$
%
(
&
+ , -- 0 " ., , , ., 1 , , # ., , , 2 , .,
*
/ ,
3 , 1
,
,
Exercise 4.13
(Solution on page 426)
4, 4 --
4.5
) #
Additional Exercises
5 ./
1
, ,
+ . *
128 Predicate Logic
Ü ! "#
' (
"
* "#
$ % &%
"#)
$
"$
%
% %
)
% $ % $ %
%
&% $ )
+ "#
%
"
%
"$ $
% , , ¾ ¾ Ê
%
Additional Exercises 129
"
! ! # $ % &
' ( ) * (* * ) * + * (* !, - & . * +
/0 1 2
!"
# $ %"
# & !"
& & $ %"
. &
// 1 2
! # '& ! "
( ! '' "
# '& "
. &
/3 # ! "
(
!"
#! '' "
& '' "
Chapter 5
Proof Strategies
proof
!
" #
'
'
/2 3 ) 1 / F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_6, © Springer-Verlag London 2013
* (
( , ' - .
1 )
( + theorems
& ( % " # $ Æ )0 132 Proof Strategies
proof strategies ! " # $ 5.1
A First Example
! % &
& ! &
Í
' Theorem 5.1
' ( ) * &
Proof:
+ ,
A First Example 133
Ü
Æ ! " ! # ! ! $ # $ # % & $ '
(
! ) $ # $ introduction strategies # $ # ! * ' ( $ + 134 Proof Strategies
! "
" #$ % Exercise 5.2
&
(Solution on page 427)
' ( 5.2
Proof Strategies for Implication
) " * +
, , - Proof Strategies for Implication 135
'
$
%
&
Example 5.2
! " ! # $
% % & ' % ' %
# $
( % Proof:
% %
% % ) % ' % % * 136 Proof Strategies
Example 5.3
Proof: Exercise 5.3
(Solution on page 427)
! '
$
&
%
Example 5.4
"# $ %
%
% Proof:
&
Proof Strategies for Implication 137
modus ponens $
'
&
%
modus tollens $
'
&
%
!
" ## $! % & ''(
138 Proof Strategies
Example 5.5
Proof:
Exercise 5.5
(Solution on page 427)
! " #
5.3
Proof Strategies for Negation
" $ " % $ $ $ $
'
$
&
%
" " " " $ " & $ " Proof Strategies for Negation 139
'
$
&
%
proof by
reductio ad absurdum contradiction
Example 5.6
! " Proof.
# "
¾ ¾ " ¾ ¾
¾
$ % & '( ) " ¾
* ¾ " ¾ " %)¾ " +¾ ¾ " ¾ ,
& - & & .. (' - 140 Proof Strategies
Example 5.7
Proof. ½ ¾ ¿ ½ ¾ ¿ ½ ! ! " ! ! ! ! ! ! ! !# Example 5.8
! $ ! ! !
! % ! ! &
! '
" ! ! ! ' ( !
!) ! !! ( ! Proof. $ ! * ! ! # Proof Strategies for Negation 141
A Different Proof. !
Example 5.9
" Proof.
Exercise 5.9
¾
#
(Solution on page 427)
" 142 Proof Strategies
Exercise 5.10
(Solution on page 428)
5.4
Proof Strategies for Conjunction and Equivalence
'
$
%
! " &
'
$
'
$
%&
%
# $ % % &
&
Example 5.10
Proof Strategies for Conjunction and Equivalence 143
Ü
Proof:
Example 5.11
Proof:
$
'
%
&
$
'
'
&
$
%
&
%
144 Proof Strategies
5.5
Proof Strategies for Disjunction
É Æ '
$
'
È
$
È É &
É
È É %
&
%
È É È Ê É Ê È É $
'
Ê
Ê
È É
&
È
É
%
Example 5.12
Ò Ò¾ ! " #
Proof:
$ Ò Proof Strategies for Disjunction 145
¯
¾
¯
¾
¾ ¾
¾
¾
" ! " ¾
¾ #
"
'
! $ " " $
&
%
Example 5.13
% ¾ ¾ & ¾
' ( Proof:
Exercise 5.13
% ! (Solution on page 428)
" 146 Proof Strategies
Exercise 5.14
(Solution on page 429)
'
$
! " #
&
%
Example 5.14
Proof.
" #
" # $ " # % " # " #
" # Proof Strategies for Quantifiers 147
Ü
Example 5.15
Proof.
Exercise 5.15
¾ ¾ ¾ (Solution on page 429)
Exercise 5.16
! " " (Solution on page 429)
# ! ¾ $ % & ' ¾ ! ( ) *
Exercise 5.17
+
,
. )
!
. *
Proof: / . ) ! . *
0
1 5.6.1
(Solution on page 430)
Fact: " . $( 5.6
.)
"
!
. *
. $( . )
!
. *
Proof Strategies for Quantifiers
Universal Quantification
/ # , , 2#
3 2
! , ! / 4 , 2
3 0 , , , ! 3 ! , 0 , ! 148 Proof Strategies
'
$
&
%
! "# $ % & ' ( ) * + # ,' '
$
&
%
Example 5.17
. / / + 0
Proof.
Proof Strategies for Quantifiers 149
Example 5.18
Proof.
Exercise 5.18
(Solution on page 430)
5.6.2
Existential Quantification
! " # $ # $
% & % % # 150 Proof Strategies
'
$
&
%
! " #
! $ % $
'
&
%
Example 5.19
)
& ' ( *( ' *)
Proof. ' ( ' ( ( ' + + ) ( ' , ) ' *) ( (
* ( ' , *( ' *)(
(
Proof Strategies for Quantifiers 151
Æ ! " # $
% % $ $ & # $
" ' " ( ) " (
( +
Exercise 5.19
) "
"
(
*
) % $
) )
(
, #
% (
)
(Solution on page 430)
.
- / " " # ) ()* Example 5.20
0
( ) (
" "
A Strange Proof of Existence
Fact:
Proof.
" 1 $ " 2" 34 5
" #
&
&
¾
¾
6 # # ¾
6 ¾ ¾
(¾¾)
¾
¾
¾
152 Proof Strategies
Exercise 5.20
(Solution on page 431)
!"
5.6.3
Uniqueness
# $ % & $ ! ' (
) ( $ Example 5.21
& ( Proof. * ( +!
# ( + ! ( ++!! ( ' $ ( $ + ! ( $
( + ! ( ¾
¾
¿
¾
¾
¾
¾
¾
¾
¾
Example 5.22
, & ! ) Proof. * ( Additional Exercises 153
Ë
Ë Exercise 5.22
(Solution on page 431)
5.7
Additional Exercises
!"
Ê # %! & & " " &&
' %! ! " && ( ) ' $ && ! ! !" !" , . ) *
. 0 " #
¾
- & / $ ' "
"
$
! !" * & + %!
! " $
(
154 Proof Strategies
É È È É È
È
Ê É Ê
É È Ê É Ê
Ü È Ü É Ü Ü È Ü É Ü Ü È Ü É Ü Ü È Ü É Ü Ü È Ü Ü ÉÜ
Ü È Ü Ü ÉÜ
Ü È Ü Ü ÉÜ
Ü È Ü Ü ÉÜ
Ü È Ü Chapter 6
Functions
6.1
% " ! "
$ % !
#
" &
Basic Definitions
! (
" )
* + " ( , - '
function
Example 6.1
. "
/ -//" F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_7, © Springer-Verlag London 2013
156 Functions
¯
¯
¯
¯
¯
¯
¯
!
"
#
# "
&#
$
(
)*
++
.
$%
'
"
,
-
"
/0 # # Class
1
# ' , #
( -
# Marks
1
+
% 2 " ++
! &# )* .
)# score
Class
Marks
##0 30
( # score
( 1
0 # 0
5 6 score
' 1
score
score
4 # (
score # # ! 1
"
* * 5 #
* # ## *
7 * # 7 /0 * 0 5 # 30
Basic Definitions 157
Ü
domain argument ½ ¾
! range
%
range
% ! #" " $
range
image
range
& " # " $
arity binary function infix codomain value & preimage ½
½
' ½
½
( ½
Example 6.2
) " ) " *
* % ) " * )
% "
%
*
+ ) " ½
) *
) * ½
) * 158 Functions
Exercise 6.2
(Solution on page 431)
score ! " # Example 6.3
$
& "
% id '
' id () * " ' ¬Ò ( )
' * (& % % )
+ - .# " ( )
Exercise 6.3
*
% " " ,
!
! / '
'
(Solution on page 432)
" " Humans ,
! "% ( )
(
-
(
0
)
)
(
)
Example 6.4
, ,
! "
% %% #
! 'Ê
Ê %
% Basic Definitions 159
¿
Ü
¿
¿
Ê Ê ! ! "# ! ¿ $ ! ¿
%
& # # ' ( '
) "# " *!( ! + graph
( graph ( ( # *# graph (
!# , *!( score ! -*! (
graphscore , % , . + /
0 - % /
1 2
/ 3 /
&! . # 44 $ ! % 5
¿
graph (
¿
Ê 160 Functions
Theorem 6.4
graph graph graph graph !
graph graph
Proof:
graph graph ! graph graph graph graph Exercise 6.4
(Solution on page 432)
6.2
"# $%&
One-To-One and Onto Functions
'
(
) * # ¿ + , + ,
- ) ¼
¼
Definition 6.4
one-to-one 1-1 injective ¼
¼
¼
¼
! ¼
¼
!
One-To-One and Onto Functions 161
Exercise 6.5
¼
¼
¼
(Solution on page 432)
score Class Marks
# Ê Ê
$ ¾ % $ ¾ ! "
Definition 6.5
Exercise 6.6
onto
surjective range (Solution on page 432)
score Class Marks
# Ê Ê
$ ¾ % Æ Æ
$ ¾ & ! $ ! ! ! !
! ! "
! '
Definition 6.6
Exercise 6.7
(Solution on page 432)
bijection
( !
162 Functions
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
¯
Definition 6.7
! " inverse
! " ! " "
!
! "
Example 6.7
! " Ê
Ê # &!$ ' (
)! " $ ) % & " *&
!
" $ % & *&! " *& &!$ " )
+ range ! # range !
Composing Functions 163
Example 6.8
! " # $ % & # & &
& ½ '
" ( & &
) '
* & & ½ '
Exercise 6.8
(Solution on page 433)
&
6.3
+ ,-
Composing Functions
# & 164 Functions
¯
Æ Æ
Æ Definition 6.8
composition Æ Æ ! Æ " Æ Æ Æ Exercise 6.9
(Solution on page 433)
# $ % & #
$
%
&
#
$
%
&
#
$
%
&
#
$
%
&
Composing Functions 165
Æ Æ Æ Æ Æ Æ
¾
Æ ·½
¼ id ½ Æ id ! ! " ! ! " # " " # Theorem 6.9
Proof:
& Æ
$" Æ Æ % $ ! ! ' ! ! Theorem 6.10
& $
$
' (
Æ
Exercise 6.11
(
$" Proof:
Exercise 6.10
Æ
Æ )
Æ (Solution on page 433)
)* Æ
½ id (Solution on page 433)
)* ½
Æ
id 166 Functions
Exercise 6.12
(Solution on page 433)
6.4
Æ Æ Æ Æ Comparing the Sizes of Sets
! " # $ " # %& ' (( ) * + , - $ " # %& ' . " # * ' + " #
, $
- %&
/ ) $ " # %& ' * + , - ) 0 ) 1 # " # ) $ " # %& ' 2 & (( 0 & & " Comparing the Sizes of Sets 167
' "
! % &
# $
! ! "
Definition 6.12
'
(
"
!
(
"
! (
!
Theorem 6.12
Proof:
¼ Ý
)
&
range# $
#$ range#
Ý '
+
!
# $ !
+
!
,
$ ¼
** !
# $
¼ 168 Functions
Theorem 6.13
Schröder-Bernstein Theorem
! " # $ $ ½ ½ Proof:
½
½
½
½
½
½
½ range ½ range % #
$ ½ $
½ & " ½
# $ !
½ #
$ ' ' # $ ½
½
½
½ ' # $ ' # $ ½
# $ ½
½
½
( # $ $ # ) $ Comparing the Sizes of Sets 169
¯
½
½ ½ ½ ½
! ½
½
½ " Example 6.13
& '
'
$
#
+
$
,
%
-
.
/
0
1
+#
#
$
%
.
0
+#
+$
+%
+.
+0
$#
( 3 +
$ ,
2
" finite '
'
Definition 6.13
( " ) * ( $ %
) * #
170 Functions
cardinality countably infinite
countable uncountable
Example 6.14
!
"
#
$
% ! !
& ' (( ) * ' ++
,' Exercise 6.14
(Solution on page 433)
- * .,/+ " 0
Exercise 6.15
½
*
(Solution on page 434)
1 * ' ) * ) ,/+ 2 )
/ / / 3 ) / /' / + ' ) / / Comparing the Sizes of Sets 171
Example 6.15
! " ! # ! $ %
&$ '' %
&$ ( %
&$) * +
& #
$
, -
"
#
$
+
.
&
/
0
1
"-
"
"
#
"
"
#
"
$
$
"
+
"
$
#
#
$
"
+
"
.
.
"
'' 2* 172 Functions
Exercise 6.16
(Solution on page 434)
Example 6.16
! " " # ! $ %& & % % ¼½
& & ' ( % $ " % ) &
The Knaster-Tarski Theorem 173
½ ¾ $
$
!
" #
! % (
! #
! & " ! . &
" ! ' (Solution on page 434)
/
! 0 / ! 6.5
Exercise 6.17
*+ , - + " " )
! !
(
!
! 0
0
# ! The Knaster-Tarski Theorem
)
+ . + ! " ! ! "+
"+
1 ! ! &
Definition 6.17
0 monotonic fixed point 174 Functions
¯
least fixed point
greatest fixed point
Example 6.17
Exercise 6.18
(Solution on page 434)
# $ %" ! "
%"
%
& % % % '" "
Theorem 6.18
Knaster-Tarski Theorem
Proof:
( %
Ë
Ì
#*+
& G
' G
,
Ë
G
G - " G
G '
."
&' (
% " ) " #$
G % '
/
" '" G ." G 0 % ' " G
G
'
G
% The Knaster-Tarski Theorem 175
G
G
G G G G G G
G
G G
! " " " Theorem 6.19
½ ·½ Ë
¾
#
·½ #
·½ # Ë
¾
#
# # # $ %& %'(
½ ¼ ) ¼ # ¼ ½
½ ) Proof: #
#
½ ½ #
·½ #
*
+
#
¼ ½ ¾ #
·½ #
, " * 176 Functions
Exercise 6.20
(Solution on page 434)
! " # ½ ·½ $ % & 6.6
Additional Exercises
! ' ( ( && & & ! $ ) ( & ½( ¾ ¿ && graph ½ ! $ ) graph ¾ ! $ ) graph ¿ ! $ ) ' **( ( + $ , & ** **
** ( & &
** ) - && ! $ ' (
**( . % / !0 ! ! 1 ! ! && 1 "
+ Additional Exercises 177
Æ Æ Æ Ê Ê Æ Æ Æ Æ ¾ Æ ! "
# Æ id id Æ id # $ %
'
Æ ( ' Æ '
& " & "
(
) ) ( ) ) (
) ) ( ) ) Æ
(
( ' Æ
(
( * ! "
( ( ' +,& - & " ( (# ..
/ # ( 0 " ( ' , ,& " && " & )1 2 (#
& ( & ( ( ( ( ( % " # & " ( && , # (# +" # ( (# (
( +" # (
3 (
&& && 178 Functions
"
# ! '( " ! '( " !
! ! %& !
$ L % ) '
$(
) '
$(
Chapter 7
Relations
! " # " # $ ! % " # 7.1
& ! "#
Basic Definitions
' (
)
“student , in course , scored a grade of ”
' ( * ) ' ( +
-ary relation !
' , ( !
F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_8, © Springer-Verlag London 2013
180 Relations
Example 7.1
# % # # # !
$ # "
! # & '
) $ http://www.imdb.com
(
*( )+
#
,
$ -
,
,
./ /'
/.
./
0
,
,
59 ,
,
Exercise 7.1
/&
/=
1
:
$ # :
/4
!
./'. 6 5 !
# $ < 1
!1
2
# # :
-
'34. 5 6 7 !
'348 5 6 7
,
-
#
< '/ '' ; # ( )
(Solution on page 435)
> # ) # :
(
Binary Relations 181
Title
Year Star
Director
!
% & ' ( "$)"
$ -" . / !
# & -$
0 1
'
! ' 2 !!
, '
" # $
!
, '
" # $
3 / 4 " 3
, '
5 # . $0""
3
3
, '
5 # . 8
3
, '
5 # 3!
-$ $ 5 # $ 7
3
-$ $ 5 # % # 4
+ 9" ' $ -0 !
+ 9" , 0$$" + 9" ' .0$ + 9" ' $ -0 ' /"$ - ' "
" # $
# * + $ , &$
$
7
$"
-
"
1 6"
$ 4
! .$ 3 " , : $- ; 2; 3
6 7 " - !
7.2
Binary Relations
" # $ % & ' #
' & & (& Binary
¯
#
182 Relations
¯ ¯ infix source on target to from homogeneous heterogeneous Example 7.2
"
"
!
!
!
"
"
"
# # # $ $ $ # % $ % % %
"
Example 7.3
& ! '
( ) ! ( *! ! ! Children Flavours
Flavours
& ) *! + , ,' , - "
(
Children
Binary Relations 183
! "
# $ % & '
! "
Children Flavours
Exercise 7.3
(Solution on page 435)
($ ) ' $ * & +% ,"- )! ' & '
* "
* ' ! % ' . ) . /
) '0 "
) $
. ' % ' . ) . /'/ . )
. $ & $ . 1 "" "
) )
' % ' % ) $
$ . ) . $ . ! "
Example 7.4
$ +% ,"2 % $.
184 Relations
Children
Flavours
Example 7.5
Exercise 7.5
(Solution on page 435)
!" #$% " & % '
& (
) & " & & % *
+ " & %
% % % ! Binary Relations 185
Example 7.6
!
" !
# $ ! % % # $
& " ! #
! % ' ' #$
&
" " &
!
!
! % &
" " !
!
! % &
# # ! % Exercise 7.6
(Solution on page 436)
( )* 7.2.1
Functions as Binary Relations
+ ' $ # *, # $
graph &
$
& 186 Relations
Ê Theorem 7.6
Ê ! graphÊ " graphÊ Ê " graphÊ
Ê
" graph Proof:
7.3
Operations on Binary Relations
# $ # ! 7.3.1
Boolean Operations
% ! & ' ( )* " Operations on Binary Relations 187
! " "
# $% # $&
Exercise 7.7
(Solution on page 437)
' (
(
)
* +
,
½
¾
¿
¾
½
¾
¾
¾
¿
7.3.2
½
¾
¿
¾
¿
½
Inverting Relations
- . ( - inverse
! ½
½
½
188 Relations
Example 7.7
Children Flavours ½ Flavours Children !
½
!
" # ! $ "
% #! $ ½ & Exercise 7.8
(Solution on page 437)
' ½ " 7.3.3
(
Composing Relations
% ) )" ) &"
" % &
%* % + " composition
Æ
, Æ - # $ ) # $ # $ . % " % Æ &
%* / %
& / %" %* Æ
Operations on Binary Relations 189
Æ !
Example 7.8
" Æ # $ % Æ " Æ Exercise 7.9
(Solution on page 437)
& '% ( 7.3.4
The Domain and Range of a Relation
domain ) domain*
range range*
+ " * + ,
+ " * + # Example 7.9
- 190 Relations
Ü domain
domain range range
Exercise 7.10
not all (Solution on page 438)
domain range range 7.4
Properties of Binary Relations
7.4.1
Reflexive and Irreflexive Relations
! " # $ $ $ $ % Definition 7.10
reflexive irreflexive & & ' & ( & Properties of Binary Relations 191
Exercise 7.11
(Solution on page 438)
7.4.2
Symmetric and Antisymmetric Relations
! ! "
#$ ## Definition 7.11
symmetric % &
antisymmetric ' % & ' ( # $ ' % &
Exercise 7.12
(Solution on page 438)
7.4.3
"
Transitive Relations
$ $
) $ ( ## $$ ) ## Definition 7.12
transitive % & 192 Relations
Exercise 7.13
(Solution on page 438)
Example 7.13
! " # $ $ " % # # # # # & ' # $ # # $
( $ $ )
# $ * + )
# # $ * , $ # Exercise 7.14
(Solution on page 439)
, $ " " # )
# - .# # $ 7.4.4
Orderings Relations
/ # , '
0 1 2 ! % & 3 # $ $ # 1 # , $ , , 3 # 1
Properties of Binary Relations 193
¯
¯
¯
Definition 7.15
partial order total order !
Example 7.15
"
# "
"
7.4.5
$%
!
& '
' & Equivalence Relations
( ( ) *
194 Relations
Æ Definition 7.16
equivalence relation Example 7.17
¯ ¯
Example 7.18
! " # $
" # $ Exercise 7.18
(Solution on page 439)
% & % & % & ' ( " # $ ) " # $ * " # $ " )# Exercise 7.19
(Solution on page 439)
+ , $
Properties of Binary Relations 195
½ ¾ ½ ¾ ½ ¾ ½ ¾ ¾
½
7.4.6
Equivalence Classes and Partitions
! "#$ % ! ! & ' & (
) Definition 7.20
partition Ë ¾ blocks % ! " ! Example 7.20
' % ! "#$ & ! ! ! ( & * & *
! +, ! - ! * ! & . ! & ) ! % ! % & &
Exercise 7.21
(Solution on page 439)
' % ! * & % / ! ' * % !
! % * ( ! ! "#$ - & * * !! & ! * 196 Relations
Definition 7.21
equivalence class Ê Ê Theorem 7.22
Ê
Proof:
Ê !
Ê " # # Ê $ # % # #
%
Ê Ê Ê
Exercise 7.23
& Ê Ê Ê '
(Solution on page 440)
( # Exercise 7.24
!) *"
+
(Solution on page 440)
, $. " $ "- Additional Exercises 197
Ü
! " # 7.5
Additional Exercises
!$ ! , )
)
& '
) !
( 0
%
%
2 ! 3 ! ½
¾
2 ! (
(
(
(
% 6 !$ 1
3 ! +
! -
!
!
!
! $
! -
4 5 !$ 1
3 ! $ 3 ! ! %
&1 6 %
.
* , +
#
% #
&1 ! ( ' * &1 (
- . / * %
( ) * +
! %!
$ 198 Relations
( )
Æ . -
id
/ & !" - 0 +
1 2 +0 2 ½
*
½
½
½
½
id
symmetric closure
+ , % transitive closure
-
Æ
reflexive closure
*
id
!" & & # !" $
Æ + !" ,
# & & ' %&& !" # $ %&& - 0 + , !" ++ 2 ½
*
¾ ¿ ½ +, 3
-
*
Ê
·½ - + , +
5 *
+ +000 && " 4 + +000
Additional Exercises 199
" &' ( &' ) !
"
&' ) $ % " # " !
!
"
*
" +
*
, -
" " #
&' &' ./Ê % ./Ê
./Ê % &' . /Ê
" Chapter 8
Inductive and Recursive
Definitions
! #
# "
8.1
$ % &
#
$ Inductively-Defined Sets
F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_9, © Springer-Verlag London 2013
202 Inductive and Recursive Definitions
! " # $ % &
Children
' ($ ) * +#" , # " ! - $ . ! / ( $ ! !
# # , - %. 0 ! % $ ! % # % % " 1$ 2 /
+#" , ! # /
/ +# # $ 3 % -! ! . ! ! , 4 * "% # #!
# " $ ! /
/ +# # " ! !% ,
! 4 ( $ ! " , % - ! . -// ! . ! 5 - #
#! % ! " ! ./
/ 6 # # " #
1$ 2 4
/ +# # # % # , # % 4
) % # % , , "
# $ / 6 % # , /
Definition 8.1
inductive definition basis clause inductive clause Inductively-Defined Sets 203
extremal clause smallest
Example 8.1
! " # $
# % & ' ! ' ' ' ! # ( !) *
% + , ! - # % Exercise 8.1
(Solution on page 440)
.( Example 8.2
-/ 204 Inductive and Recursive Definitions
!" # ! # ! $ " $ # % # & # " # # % # # ' # % # # &
% " % # % Exercise 8.2
(Solution on page 441)
( $ # $ & " # " # % # ' ! )
Exercise 8.3
*%
(Solution on page 441)
# % $ + , - -+ ! "
Example 8.3
*% $ . !" !!# " # $ ! # % " # " # % # ( !!# % " / # !!# # % # Inductively-Defined Syntactic Sets 205
Exercise 8.4
(Solution on page 441)
!" # '( )$
8.2
# # $ % & !"
#
Inductively-Defined Syntactic Sets
#
* " # Children + ( ,- - - # ' " " * . " / / -
" 0
" 0
" # " * # " alphabet # symbols characters # 0
string word length ½ ¾ ¿ " ! " empty word " 1
2 " 206 Inductive and Recursive Definitions
Definition 8.4
A Example 8.4
!
"! # $
!
" # % $
!
!
" # % $
! " # $
" # & Backus-Naur Form 207
! ! " ! ! Exercise 8.5
(Solution on page 441)
# $ % &' (&' 8.3
Backus-Naur Form
) " Backus-Naur Form (BNF) "
*+ ,,! " *+ ,,! - . *+ " ) % ( successor function ! /0 1 *+ ,,! ( 2 3 (
. 4 $ . 5 208 Inductive and Recursive Definitions
Example 8.5
true false !"# $ % true false & ' Exercise 8.6
( (Solution on page 441)
!"# )*) + ! ' , - " . / 01(21 / ' Example 8.6
!"# $ % := ½ ;¾ if then ½ else ¾ while do # % :=
½ ; ¾
if then ½ else ¾
while do ' 3 / ! / 4:=5 / 3 Backus-Naur Form 209
¯
½ ;¾ ¾
¯
½
½
true
¾ ½ ¾ then ½ else ¾ if
½ ½ ¾ false
¯
! % false
" true
# do while
$
$ " % $ # & ' ( ) ( * ( ( i := 0;
s := 0;
while i < n do
i := i + 1;
s := s + i }
% + $
#
i := 0 ;
s := 0;
while i < n do
i := i + 1;
s := s + i }
% $
s := 0 ;
while i < n do
i := i + 1;
s := s + i }
$
#
$
210 Inductive and Recursive Definitions
i := 0 ;
s := 0 ;
while i < n do
i := i + 1 ;
s := s + i
i := 0 ;
s := 0
;
while i < n do
i := i + 1 ;
s := s + i
! " # ! $ i := 0 ;
s := 0
;
while i < n do
i := i + 1
;
s := s + i
% % & ! 8.4
Inductively-Defined Data Types
' ! # ( $ Inductively-Defined Data Types 211
! " #$ % empty list & ' & '
( ) * " ( ) * ( & ) & * ' '
+ ",
" " - " Example 8.7
. " binary trees &½ ¾ '
% leaf internal node &½ ¾ ' ½ ¾ & & ' & & & '' ''
% " /
dictionary & ' & ' " 0 +1 -
" 212 Inductive and Recursive Definitions
Exercise 8.7
(Solution on page 441)
! " 8.5
Inductively-Defined Functions
# $ ! % ! % & ¼ ½ % ! & Example 8.8
$ factorial
( )
'
function '
* (+,
!
- % .' * ( ' * / (0' .
$ % %
Inductively-Defined Functions 213
Exercise 8.8
(Solution on page 442)
! "
¼
# ½
$ %
Example 8.9
& harmonic numbers !
# # #
# ! '
(
Exercise 8.9
# (Solution on page 442)
! '
Example 8.10
& Fibonacci numbers '
(
(
# & ) ! ! ! $ $ ! ' & *! ! 214 Inductive and Recursive Definitions
!" #
! $ # $ # "
% & ' ()# (
*% + &
#! Liber Abaci " " %# $ # # %% " & %# % #!
Exercise 8.10
(Solution on page 442)
,%% % "(# ## % ## % " % ## '" % ## " - ./! 0 " ! % 1
" ! & # 0 ) # 0 2 successor function .1 3 4 0 # % 5% # # 0 % 6 Example 8.11
7 & 0 #
883
. 1
& %& 9 " 0 8 " " # " 8
. 1 3 :
. .11 3 .. 11
0 4 3 : % " " & " " " " 8
. 41 3 . 1 4 5%
Inductively-Defined Functions 215
Exercise 8.11
(Solution on page 443)
! "
# $ $ $%
" & $ "
Example 8.12
& ' $ "
& ' $ "
( ) & ' $ $ "
' ' Exercise 8.12
½
¾ * ' ½ ' ¾ (Solution on page 443)
" + $ (, ) "
Exercise 8.13
(Solution on page 443)
& append ½
¾ - ½
¾ '" .
* ( )
( /) ( /)"
"
216 Inductive and Recursive Definitions
Exercise 8.14
(Solution on page 443)
! " 8.6
Recursive Functions
# $ # $ " % $& recursive func $ tions ' $ ' %
$ "
& ( ! "$ ) * + * +, - " $ ) + * + ) * ) . * . ) Example 8.14
/ 0 $- 1+& 2 +
+,
) * ++ +
3 $ " $ 4 Æ & ' # ) 1+ + ) + +
Exercise 8.15
(Solution on page 443)
5 / 0 $- 1+& $ ) 1+ + ) + +
Example 8.15
0 2 Recursive Functions 217
! " # # ! " # ! ! " # $ # $ ! # ! " # " # %&' '
* + ( ) (
, - . ' ' &
' /( 0 + .
& ! . ' $ * & . + ( & 1 . $ .
(
.
' .
* & ' %
. (
$ (
$+ . .
% '
+ !+ !
+ 1 . ¾
$!# 2
Collatz conjecture
.
+ ' +
( $!# . ¿
.
%
218 Inductive and Recursive Definitions
8.7
Recursive Procedures
Example 8.16
Insertion Sort
Insertion Sort ! "
# $ "
% & $ ! ' ! ( %" "
)*
+ )*
" + , , Exercise 8.16
(Solution on page 444)
- . ! "
)*
+
" + . ! /% , 0 Recursive Procedures 219
! " " # $ ! " " % % ! Example 8.17
& '
Merge Sort
Merge Sort ! ( '
$ ) *" + , " " -
. / 0 ! # ! $' " + *" + , - 1 1 !
2 '
( ! $ ) *" + . ! ! ! 3 1 1 / 0 ! 220 Inductive and Recursive Definitions
Exercise 8.17
(Solution on page 444)
Towers of Hanoi ! " #
$ %
% &
8.8
Additional Exercises
' ( )
* + & , ' ( . ' ,- / ,- ,01- ,02- ,- 3 4 " " ) ' &
Additional Exercises 221
! " " #
" " $ %& ' " ( )
) *+, -" " " "
. " " /
$ %& " " & " " / " " -" " % " " / " 0 " 1 2 !3 ( 1! 2 3
' " " 1 2 !3 4 5 " " , 0 ," %2 6 /7 6 7
" " " 8" " " -"#9 :/; ," " ,
(
< =
(
(
222 Inductive and Recursive Definitions
♀ ♂
♀
♀
♂
♀
♂
♀ ♂
♀
♀
♀
♀
♂
♀
♂
♀
♂
♀
♂
♂ ♀ ! "# $ # % ! & '( ) " * + '( ) * +&
'( ) & * ¿ &
'( ! "
" & Chapter 9
Proofs by Induction
!
inductive reasoning " #$ % ÜÈ &Ü' Ü
È &Ü' Ü (
) ( ( 9.1
Convincing but Inconclusive Evidence
Ò&Ò*+' -
Ò ,
Claim:
.
2 Ò /
4 +*,*0*
* Ò
1
Ò&Ò*+' ,
3 +*,*0*
* / /
F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_10, © Springer-Verlag London 2013
Ò-
(
224 Proofs by Induction
!! " # $ %& $
"
' & "
¯ Fermat’s Last Theorem & ( ! & " ) ! * + , ! -- " .
/ $ ! ! !
"
# ! $
/ !
0 / 0 "
1 2 2 , 3 ) 4
& ) & ( 4
% 5 67 4
! ! ! & "8 7 & " ) ! ! & !! ! ( ! ( % ! + 9
" 7 ! 2 & ( (! "
¯ Fermat numbers & ¾ " ) 1 2 : : ; 5 < < <
.
! ! $ Convincing but Inconclusive Evidence 225
¼
¾ !" " # "$ % &
' (' ( (
") " " ") ) "" " "" ) *" +
" " " ' ,, '
¯
¯
¯
# -" . ") -" "/
Goldbach’s conjecture # )
% " " # " # ) " " "# " " , . # ,,, ,,, ,,, ,,, ,,, ,,,/ 0 " -"# ) ) "
" " "- " " 1 * 2 "#
) " " " "# " % "
%
((# 3) 4") 56" "$ " . # " ,7/ " ) " " " %# " " "# "# " ¢¢ . "/# ' ¢ ."/ " " 0 (,1 " 56" 1 "$ "$ " " 8,,#,,, 3" # " " &)" ) &
# 56" 1 "$ " (8 9 0 3&
)" " " " " " ¢,
. # "" :"/ " " " (, , 9" "" ) 226 Proofs by Induction
½
¾
! ! ! " # $ %&& '(& '% (( (& ))' ))$ &(* '+'
! , . /0 1 2, * & 3 ! . $$$ % 4 ! 5 5 ! ! Exercise 9.1
(Solution on page 444)
4 ! ! 6 . .
7
, $ ( ) & $ ) * + 8 ! , 7
A Primary School Induction Argument 227
9.2
A Primary School Induction Argument
! " # $ %
&
% %
"
' ! ! ( $ ! ! )
" * ! !
! !" # $ ! ! %
% ( + &
%
%"
+ ! ( ! !
( ! "
, &
! ! ) ! ! " ' " ' &
- . " / ! 0
& % &
%&
&
& %
& 1
&1
, ( $ ! % ( & $ 0 %" * ! %& %
( ! &"
2 ! ! & ( ( ( ( ! % (" 3 & " 4 ! 228 Proofs by Induction
! " # $
% & ' ( ) ! * + % " Exercise 9.2
,
Exercise 9.3
(Solution on page 445)
#
(Solution on page 445)
, - . / 011 + / ! , ! / #
9.3
The Induction Argument
2
! ! !3 ! . mathematical induction ! & ' ¾ 4
0 (Base Case) ! 1 (Induction Step) &1'%
! 50 ! &' µ &50'
%
The Induction Argument 229
inductive
hypothesis ! "# ¼
$ % & # # # # ' # ( )
* # ' + + , # ' # " # # - . " . ' # $
/" " & # #' # $ / . $ % % 0% , # ## # 0
* . # 1 # # 1 $% & ! 2 , $ 230 Proofs by Induction
! '(
( %
$
%
)"
( " # & ) *
' & % %
$ +
% &
( ( & %
( % ( )"
$ (
Example 9.3
Fact:
!
Proof:
Base Case:
#
!
Induction Step:
!
(
,
!
( !
-
!
# (
,
,
,
-
!
-
&
,
-
,
- % &
-,
!
!-
The Induction Argument 231
! " # # # $ # %
&
' ( # ) * * + # $ # # , # Exercise 9.4
(Solution on page 446)
* # , -
¾ ¾ &¾ ¾ . & / ¾
232 Proofs by Induction
Exercise 9.5
(Solution on page 447)
¼
½ ·½ ¾
! " # $ %
& $
Exercise 9.6
(Solution on page 448)
¾
¿
·½
' ·½ (( (( )* " ¾
¿
" ( " ( & + "
$ " " , ,( Example 9.6
Fact:
- ( $ . ( ( / %( 0%( ( Proof:
1 Base Case: - %( ( 0%( ( 2 ( . (
Induction Step: - " $ ( . (
(
0%( ( " ( %( ( *
! 0%( ( %( ( * " %
( 0%( ( The Induction Argument 233
Example 9.7
Fact:
$ Proof:
Æ
!
" # convex % Base Case:
&
"' Induction Step:
Æ
! # * ) ' Æ
! Æ
! ( ) * ) * $ Æ
! Exercise 9.7
!
* Æ
!
Æ
*
+ ) Æ
! (Solution on page 449)
, )
- ) ¾
. / 1
0 , ) )
)
0 ,
)$
*
234 Proofs by Induction
Exercise 9.8
(Solution on page 449)
function if then return else return ! "# ! $% 9.4
%
¾ Strong Induction
& ' % ( ) strong induction * %
+ , & % %
% Example 9.8
-
! !
*
*
Induction Proofs from Inductive Definitions 235
Fact
Proof:
:
even:
odd:
Exercise 9.9
(Solution on page 450)
" # $ %# 9.5
! !
Induction Proofs from Inductive Definitions
& ' # ' $ # (!
!
-
%)! # * + , ! %)! # * ##
# .$
##' )! #
Example 9.9
Fact:
, ##
½
Proof:
¾
Base Case ½
¿
¾
¼
¿
¼ 236 Proofs by Induction
Induction Step:
½
¾
Exercise 9.10
¿
½ ¾ ¿ ½ ½ ½ (Solution on page 450)
Example 9.10
¼ ½ ¾ Fact:
Proof:
·¾ ¼ ½ ¾ ¼ ¼ ¾ Induction Step ¼ ½ ¾ ·½
·¾ ·½
·½ ·¾ ·¿ Base Case
Exercise 9.11
¼ ¾ ½ ¾ ¾ ¾ ¾
#
$
(Solution on page 450)
! " '
" ·½
"
%
&
Fun with Fibonacci Numbers 237
Example 9.11
Fact:
Proof:
¾
½
½
¾
·
¾
!
´
Base Case ! Induction Step: !
Base Case
½·
¾
¾·
¾
½µ·
¾
½
½
½
½
½
¼
½
´
¾µ·
¾
¾
¾
¾
½
½
¾
¾
¾
¾
½
¿
¾
½
¾
½
½
½
¾
¿
¾
¾
" # $ % 9.6
Fun with Fibonacci Numbers
% & &
9.6.1
A Fibonacci Number Test
' & & $ & ( ) * " + $ + ( ) " ,
& !
( - ¾
238 Proofs by Induction
Ü ¾ ¾ Ü ¾ ¾ Ü ! ¾ " ¾ # $
%
& Ü $ '( '
! ¾ " ) ! % ) " * ¾ ( $ % ¾ " ) ! % ) " *# ¾ $ % +!$ ! ! , ! ! ! ) ! "* $
'( ' ! "*¾ #"*" ) !
% ) " ! ¾ $ %
) ! ! "* - ½ "*.
+! $ ) ! $ ! ) ! ! Exercise 9.12
(Solution on page 451)
/! ( 0 ! % Exercise 9.13
! $ * ! - .
- .
(Solution on page 451)
/! ( ! $ ! - . $ ) 0
! % ! - . - . $ * - 1 ! !
! ! 2 3 ) - . .
Theorem 9.13
Fibonacci Test
4 ( ) !
! % % Proof:
quadratic formula
*
( ! $ ) $ 1
! ! !
Fun with Fibonacci Numbers 239
¾
¾
¾ ¾
½
¾
&
#$ %!) & ' ¾ " #$ %! Ü
(
!
¾
&
& & !
& & & * &!
9.6.2
A Carrollean Paradox
+
Exercise 9.14
( ', !
(Solution on page 452)
- ',
'
¾·½ ·¾
& +( 1
.!
// 0
$!
+ 1
2 3 4 $ + & & * $& 1
)
& &5
& * &!
1 2
) )
)
(Solution on page 452)
(
&
! + // Exercise 9.15
240 Proofs by Induction
9.6.3
Fibonacci Decompositions
$"
%&' "
)
*
"
" ! " "
" &
! Example 9.15
! " - + ,
"
Zeckendorf’s Theorem
Fact:
.#
! / %
! " #
(
&' % )
" /
#
0
¾ 0
½ ¾ $"
Proof:
½
$"
/
Base Case
¿ 0
1,
0
)2
0 0 ! // % & 0 0 %
½ 0
! ¾ 0
¿ 0
% 2( Induction Step
½
1
0 1
2(
½
) /
When Inductions Go Wrong 241
½
¾
¿
½
½ ½ ½ ½ ·½
½ ¾ ·½
½
½
¾
¿
Base Case Induction Step ·½ ·½ ½ ! ! " # ! $ ½ ¾ ¿ % ! ½! !
&" ·½ ! " $ ½
½
½
9.7
¾
¾
¾
¿
¼
¿
¿
·½
When Inductions Go Wrong
' " $ " ( (
Example 9.16
) *
+
, 242 Proofs by Induction
Base Case Induction Step ! " # $# # % # & & # range # ' () # & & * ) #
# Example 9.17
Sorites Paradox
+ ,- ) Claim: ! & Proof: .# Base Case / Induction Step: $ 0 +# & # 1 # # 1 0 & sorites paradox heap paradox 2& 3 ,- / ,- ,- # ' # 0 # When Inductions Go Wrong 243
¯
¯
¯
! "
# ! !"
" $
%
Exercise 9.17
(Solution on page 452)
& & '
( %
Base Case
)
* +,
Base Case
)
*
Inductive Step
+,
)
. /
+,
- ¼¼
/
¼
¼
¼
¼¼
¼¼
0 -
,
*
¼
.
¼¼
1
244 Proofs by Induction
9.8
Examples of Induction in Computer Science
Example 9.18
if then return ! else if then
" if then return # else return $ else
% := &
' := &! ( return ) *
+ + " ( , *
& +
. .
! ! "
+ ! " ! +
! %/ ! '/ ! (
! & ! & ! !
0 .
! ! & ! & !
!
Examples of Induction in Computer Science 245
Fact
Proof:
Induction Step Base Case !
"
#
$
$
"
$ $ # % % & ' & structural induction !
Example 9.19
(
& & Fact Proof:
)
(where
# & * ! ):
& ! !
&
& ! structural induction !
+
% ! & :
)
Induction Step Base Case ' ,
& !
246 Proofs by Induction
Proof: :
:
(where
): Example 9.20
Fact Proof: :
!
" ½ ¾ : ! # $!
½ ¾ ½ ¾ ½ $ ¾ $! ½ $! $ ¾ $! ½ $ ¾ $!$!
Exercise 9.20
% ½
9.9
(Solution on page 453)
½ $$ ¾ ½ $ ¾ & ¾ '!# & '!(
Additional Exercises
! % " Additional Exercises 247
¿ ¿ ¿ ¿
¾ ¾ ¾ ¾
!
¾
" #"$ & %& " $$
'
" & ( $)
%& " *( #"
$$
$$ '
+ + +
&
" )!$'
'
'
'
& " & $$ *( #"
$$ '
+
,
& " & $$
- % ! $ ) ) . )!$ / ,
0 "!! ! "$ "& ! 1& $ & "1
")
& ) $ $ 248 Proofs by Induction
! "# ! $ % &
' " % (
)* + % ! "# ! )) , . / ) .
, % - - .
, . .
-
- ! - - % *
"# 0 % . . %
- ½ - ½ . )- , % . % - % . % . , % % %
1 2 % . , 1 Additional Exercises 249
! " # $ % &
' ( ) ( % ( *+
, - . % . /
0 1 23 4 * 4 4
Proof: 6 4 * 4 4
4
4
& 4*& *
5 4 * 4 4
*& 4&
5
5
4
*
& 4*& 5
*
4
&&
4
+ 1 23 250 Proofs by Induction
Ý
Proof:
Base Case
Induction Step:
%& '
Induction Step:
*
! ( ) "
#
*
*
*
*
*
/
*
. '
*
*
* %, - *
.
$
Base Case
+
Proof:
. Ý Chapter 10
Games and Strategies
Games-of-chance
" !
Æ
$
&
( '
' ( ( % !
)
# !
games-of-no-chance
$ " F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_11, © Springer-Verlag London 2013
252 Games and Strategies
10.1
Strategies for Games-of-No-Chance
A B perfect information ! " " " # $ % " " % " " finite game # % $ &' ( $ " ( " " attacker-defender games #
% % # (
" strategy " Strategies for Games-of-No-Chance 253
winning strategy drawing strategy
winning position losing position ! ! " # $
% & ' (
)
*
+
,
. $
% & ' (
)
*
+
254 Games and Strategies
Theorem 10.1
Proof:
! "# $ $ !
¯ ¯ $ $ %& '
$ % Corollary 10.1
Example 10.1
! () * + Strategies for Games-of-No-Chance 255
! ! – " " " # – " " " $ % % – " " " # – " " " " " & & – " ! " ! " # – " " " $ ' ( ( " % % " ) ) " % % " * * 256 Games and Strategies
–
–
!" # !" –
% & & ' !
(
)
+ !"! game tree
'
' -
-
'
$
. -
,
-
!"
! *
, %
$
"
' % –
$
,
Strategies for Games-of-No-Chance 257
¾
¾
¿
¿
¾
¾
¿
¾
¿
¾
¿
¿
¾
¾
¾
¿
¾
¿
¾
¿
¾
¾
¿
¾
¾
¿
! "" " # ""
" " $ %! " % #& %! #
" "& % # %'" "(
% ! "$ # % # "# Exercise 10.1
(Solution on page 453)
) " # !
! ! #
* # % ' # # !
) # $ ! # ! # ! (
$ ! " *
+ % %! ' # # ! % ! + % %! ' # # ,
! % ! % # ! ! ! %# " % # " -(
258 Games and Strategies
Exercise 10.2
not (Solution on page 454)
! " # $ % & ' # ' ' ( )
* " $ # % & + # ,
- ' ( )
Exercise 10.3
(Solution on page 454)
" !* &
. %! !*) * / % ) " !* 0 Strategies for Games-of-No-Chance 259
! " # $ # % # & ' # % " ( $ # Exercise 10.4
(Solution on page 456)
& # % ) one two %
* & %+ %
) % "
* * , * % ! " % % % . ( &
( / 0 % % % & ( 260 Games and Strategies
! " # " "
" " 10.2
Nim
" $ " " % " " " " " "
& # first ( " '
) # " second
" ' " ( ( " * first
" ' * ) + # " first " ' , "
* ) " second " '
Nim 261
!
!
!
!
" Æ !
! % ! ()
!
(
balanced #
&
'
()
! unbalanced # !
!
!
!
&
!
$ ! #
! ! *
( & ! every
! ! &
+ " ! + ! !
! !
!
* ' ( (
* ' ( (
,* ( ' ' 0
(* ' ' (
-* ( ' (
-* ( ' (
.* ( ( (
.* ( ( (
( ' (
' ' '
! ! ! ! !
$ !
/ !
! ! ,-. !
!
some
!
! 1 !
262 Games and Strategies
first second Exercise 10.5
(Solution on page 456)
! " # $ Exercise 10.6
(Solution on page 456)
% & ' & ( & " # ) $ 10.3
Fibonacci Nim
" & * + ,
,
- 2 coins: &
- + +
second Fibonacci Nim 263
second
3 coins:
! " first 4 coins:
# ! ! $ % ! ! $" second 5 coins:
& ! &" first 6 coins:
& ! &" first 7 coins:
# ! ! ' ( ! ! '"
(" second
8 coins:
) ! )" first 9 coins:
* + ! + # !
, - + .. + 264 Games and Strategies
Theorem 10.6
The Fibonacci Number System
½
¾
¿
Proof:
½
¾
Theorem 10.7
not ! " ½
¾
½
" Exercise 10.7
!
10.4
(Solution on page 457)
"
Chomp
# $ % & $ '& $ $ $($ $ )* + , * - $ $* $ %
' $ *$ $ $ '& $ - % $ %
)* $ $ % $ % )* ' $ $ % $
% $ $ $ - $ $ $ * )*
. '& - - $ $
%
# $ & $ / $ - % $ -0
- $ % $$%-
$ # $ $ +& -& $ $ ,& $ - $ % $$%-1 ' $ 2 '*$ $ *
)*& % 3* $ $ * )* $ - $ $
Chomp 265
! " # $ "
" ! % & ! %
% ' ( ) #% * % % & * % $ % % ( ! ( # % # $ + # % ) % , % ( % & ".
/ %Æ ( Theorem 10.8
"" Proof: 0 ( ) # % # # 1 % % ( # ! 266 Games and Strategies
½ ¾
"
!
! !
" " # $ % & '
& % 10.5
Hex
" & ' & (!) *!+ & , & - (!+ *!)
& , & Æ - " &.
& . " / ' &
Æ ' " & ' & &
Hex 267
ÆÆ
ÆÆ
ÆÆ
Æ
Æ
Æ
ÆÆ
ÆÆ
Theorem 10.9
! " " #$ %
#$ Æ% # & # #%
$ $ Æ ## # %
# % ' $ Æ ! # $ Æ # # ! "
% # # " #$ Æ% #
# #$ ( #
#$ Proof:
) #
268 Games and Strategies
Æ Æ Æ
Æ
Æ Æ Æ Æ ÆÆÆÆÆÆÆÆÆ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ
Æ Æ Æ Æ Æ
Æ Æ Æ Æ
Æ
Theorem 10.10
Proof:
! "# $ % &
' & % ( )
Bridg-It 269
10.6
Bridg-It
! " # " Æ #
$ Theorem 10.11
% # & ' #
( # ) ) Æ * # + * # Æ , - Æ Proof:
270 Games and Strategies
Theorem 10.12
Proof:
! " # ! $%
& ' ' ' &( ' ) !' !
' ! ! Exercise 10.12
(Solution on page 459)
* ! ! Additional Exercises 271
10.7
Additional Exercises
!
" # $% & $#% ' # #( $) * + " " " # ! " # , %
+
! " # $% & 272 Games and Strategies
! "
"
*
"
# # $
#
" ' $ #
%
+
, " -
*.
*. ! ,
0 #
"
*.' #
*.
% # # # # /
#
#
*. ! ,
¯
¯
-
, %& ( )
$ "
0 % 1 ( " # "
%
& ! 1 -
#
" 2% 20 2(
Additional Exercises 273
!
" ! ! # $ ! % # ! #& ! # ! % # ' ( !
" ! ! # $ ! % # ! #& ! # ! ( % # ) # '# ! # !
# * # + #
# # # ' ' & & % # '#
# # * # & #
# * # # ! , ' ! " ! ! # - & # ! # , ' & ! #
, '
' # '# ! #
! # * # . + #
# # # #& ' # #
! , ' ... ! " ! ! #
$ & ! ' % & ! / !& / ' & # ' 0 %
# '# ! & & 1 0 ! # ! # 274 Games and Strategies
!
" # $ $ # ! % &
'
!
( #
# ) * + # # # ' ' "
' , not - ( # *
# , -
# . ! . / #
&
' # ' # ' ' ' # 0
1 2 3 # # % *
( 1
1 *
" &
44 5 6 7 8 " ' 5 6 3 ' # - ¼ ¼ ½ ½ ¾ ¾ 9 Additional Exercises 275
¼ ¼
½ ½ ½ ¼ ½ ¾ !
¾ "# $ "%& ' ½ ¾ ¿ (
) #
"# * + , "%& + ,#
- . .) ) . /
$ 0 ) ) 1 . ) ) 2 3 4 5 ¯
¯
Russell 2 ) &
) ) )
2
* $ 0 6 7.)
Part II
Modelling
Computing Systems
Chapter 11
Modelling Processes
# &
(
) 1
,,, '
&
C
6 F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_12, © Springer-Verlag London 2013
C
#
. ' '
/ 0 . + . # ) - . '
( "
# !
% *
%
$ !
'
! ,23
45 280 Modelling Processes
'
'
$
1 2 3 4 5 6 7 8.
7
8
9
4
5
6
CE
1
2
3
C
0
&
&
%
%
!
" # " $% & = " ! $% ' " # (!!!!!!
' " " # #
" ) # # ! $% # *#"+ Ý ,"# " #
Ý "#
! Labelled Transition Systems
281
!
" # $ 11.1
Labelled Transition Systems
% & " '() ' ) ( " # $ # $ ( # $ ! *
+ , #% - * $
" ./ 282 Modelling Processes
labelled transition system Definition 11.1
labelled transition system LTS ! States Actions States states
Actions actions events States Actions States transitions transition relation
Definition 11.2
!"
! States Actions extended transition relation
States Actions States # # Actions Actions
! ! ½ ¾ ¼
¼
Labelled Transition Systems
283
¯ ½
¯
¾
¯
¯
º
Example 11.2
States !
Actions ! " # " # " " # " # " " # " # " " # " #
" # " # " #
#
#
#
$ % % Example 11.3
The Man-Wolf-Goat-Cabbage Riddle
& % ' % % () * " ++, - # . %
284 Modelling Processes
# $ $ ' $ " ' (
)
# %
# * !
" %
& !
!
+
, %
Labelled Transition Systems
285
! ! %&
¯ ¯
' ¯
(
ÓÓÓ
$ ÓÓÓ
ÓÓÓ
ÓÓÓ
ÓÓÓ
ÓÓÓ
ÓÓÓ
ÓÓÓ
ÓÓÓ
)
ÓÓÓ
ÓÓÓ
ÓÓÓ
ÓÓÓ
#$
ÓÓÓ
ÓÓÓ
"
ÓÓÓ
%& ( ##* ( %& + ,- . %&
286 Modelling Processes
Exercise 11.3
(Solution on page 459)
! " ! #
" $ ! " ##
% # $ " " ! & ! ! " # ! $ # '! " ! !
! ( ! ) ! "*
Computations and Processes 287
Exercise 11.4
(Solution on page 461)
(
!" # $% & '"$ " )* $% $ + , +
- , "
/", , /", , /", +" ,
Exercise 11.5
0$ , +" $$*
, $ +1
(Solution on page 461)
" $, "
$2" , " " 3
$
$ + " + + " + +" $
+" +
" $
+ $
*
+ , " " 3 " "
$ $ " $* # " ",
$
" * 4$
" ,*
# $, 11.2
,$ $ + +
$ $ & +"* . +" " ,
+ +% " 1
Computations and Processes
$ + , ,
", ,$ " 5" * 677 !% + $ .% + "
,$ , $
x
" "$ +"
y
:=
x mod y
$
Ü
Ý*
"$ $$ $$,
$
x y
$
,
*%
loop begin
x := x mod y;
if x=0 then return y;
y := y mod x;
if y=0 then return x
loop end
8$ ,
begin:
9-"$: +" $ + 9loop
$ ,
end:
" " $ "* ; -
"$
Ü<=>? Ý <@>
$ . + =>? @>*
9loop
+ , " ? "
288 Modelling Processes
ym
od
ym
od
x
y
od
xm
Ü
Ý
x :=
y
y
Ü
Ý
od
xm
od
xm
Ü
Ý
x :=
x :=
x
Ü
Ý
y :=
y :=
Ü
Ý
Ü
Ý
! " # $%& $'% ( % $'% $ $% Ü) Ý ) * % x := x mod y+ , ! '! $% x
'! %'%% ! Exercise 11.6
(Solution on page 462)
! - ! . / - ! . / 0 - ! . / ( % ' % '% % 1 %% % , ' '%" ' ' % ! % ' 2 % , # ' &+
¯ 2 % # ' &+ ¯ 2 ' ' # % ,&
¯
Computations and Processes 289
! Exercise 11.7
(Solution on page 463)
"# $ % $ % & ' ( Example 11.7
) ' ' Cl
* Cl Cl $% + Cl
Cl
Cl
Cl
Cl
Cl
290 Modelling Processes
Cl !
Cl¿
Cl¾
Cl
Cl
Cl Cl Cl Cl "
# $ % Cl & ¾ ' Cl ¡¡¡
Cl
Cl
Cl
Cl
Cl
( ) Cl Cl * * Cl Exercise 11.8
(Solution on page 463)
+ , Cl Example 11.8
* . ( . !
¯ % . . . ( !
Computations and Processes 291
¯ ¯ ! " " " " # ! $ % & '( Exercise 11.9
(Solution on page 463)
# $ $ )
*
'( $ + $,
Exercise 11.10
(Solution on page 466)
- " 292 Modelling Processes
11.3
A Language for Describing Processes
! " # !
$ ! #
%! &&' # #
( ) * + , ¯ (process) variables - ¯ events actions % ! % ! ! operations + !
11.3.1
The Nil Process 0
, ! 0 nil 0
$ !
Cl¼ %! &&. ! #
( 0 deadlocked A Language for Describing Processes 293
11.3.2
Action Prefix
Cl½
action prefix
0
0
Cl¿
0
0
0
0
" #
0
"
0
! $ 294 Modelling Processes
11.3.3
Process Definitions
defining equation
! "
# ! # process definition
! $ ! $ ¼
¼
A Language for Describing Processes 295
11.3.4
Choice
¯ ¯ choice ! " # ! $ $ % ¼
¼
¼
¼
& ! ' (
)((
% 296 Modelling Processes
Exercise 11.11
(Solution on page 467)
½
¾
! " " # $
$
% # # # & % ' " nil 0 $ % # (
Example 11.11
) * " ' Cl ' " ' Cl ' Cl
$
Cl
Cl
$
0
Cl
$
Cl
A Language for Describing Processes 297
¼
¼
¼
¼
¼
¼
¼
0
¼
! "# Clock# " $ % % & " "' " # " & # $ "# "
% " $ % & # % Cl $ ( Clock
Cl # "# Clock # %( " Clock# % ) $ " ) " ( & # % ( ( Cl $ " $ ( Clock
Cl Cl
& *
Exercise 11.12
(Solution on page 467)
+ ( $ ! " , -
Cl
$ 298 Modelling Processes
Cl
Cl
Cl½
Cl
Cl¼
Clock
Cl
Clock
Exercise 11.13
(Solution on page 467)
! " ! #! $ "# ! ! % "# # & "# ! ! ' ( ) ) *" ' ! "# # Distinguishing Between Behaviours 299
ν
10p.10p.( coffee.collect.Î
+ tea.collect.Î )
Î
10p.( 10p.coffee.collect.Î
+ 10p.tea.collect.Î )
Î
10p.10p.coffee.collect.Î
11.4
10p
collect
+ 10p.10p.tea.collect.Î
tea
coffee
Distinguishing Between Behaviours
10p coffee tea collect !" !
" # $ % ! Î
10p.(coffee.collect.Î + tea.collect.Î )
coffee.collect.Î + tea.collect.Î
collect.Î
&
Î
10p.(coffee.collect.Î
10p
+ tea.collect.Î )
Î ' 10p.10p.(coffee.collect.Î + tea.collect.Î )
! 300 Modelling Processes
'
$
10p
10p
coffe
e
ν
tea
collect
&
'
ξ
%
$
10p
coffe
e
10p
10p
tea
collect
&
'
10p
ο
10p
10p
coffe
e
10p
tea
collect
&
%
$
%
10p.10p.(coffee.collect.ν + tea.collect.ν )
10p.(coffee.collect.Î
10p
Exercise 11.14
½
+ tea.collect.ν )
(Solution on page 467)
ν ξ ο ! ν ξ ο 10p " !
10p coffee
Distinguishing Between Behaviours 301
10p coffee ξ ο Î 10p 10p coffee Î Î Î Î Î
10p coffee
tea
10p 10p tea Exercise 11.15
(Solution on page 468)
Î Î Î
! " # Exercise 11.16
$
(Solution on page 469)
% 0 & 0
% & % & 0 & 0
% ' ( ) # 302 Modelling Processes
11.5
Equality Between Processes
¯
¯
Exercise 11.17
(Solution on page 469)
! "! # $ % ½ & ' 0 % ¾ & ' % & ' ' %& % ' & ' ' % ' &
%& ( ) * $ Example 11.17
' 0 $ ¯
' 0 ¯
' 0 + $ ' 0 0 0 )! ! ! )
! Additional Exercises 303
¯ ¯ ¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
! "½ # $
"¾ # $
% % & Exercise 11.18
(Solution on page 469)
' ! ( ¾ ' 11.6
) Additional Exercises
* + **, -- . -- **/ *0 ( $ 1 2 & " 34 --5 3& --5# $ 304 Modelling Processes
! " # $ # ! " ! "$ $
!% &' " ( $
) * ) " " +
, & + - - $ $
$ " . / %
&+ & + 0 # $ $ 1$ 2 3 / $
44 ( 5 ($ 1 6 ($ 2 7, ( 3 54 ( $ 1 ( 8 /
%
$ 1$ 2 3 ( / $ $
$ 9 - : $ - ( $ ,$
7 4 $ * $ ( : /
%
7 - ) ! ) & + / ) (
! ! ! : $ $ $ $ 5$ ; 6
$ %
&+ / ) (
! ! ! : $ $ ,$ 5$ 9$ ;$ 6
4 $ %
5 )$ $ < ( ) <
Additional Exercises 305
! "# $% & ' ! (
" ) x mod y *
+
while x y do x := x-y
return x
,- . "% mod , - / # 0 1 2
0
3
2
2
,- . , - & 4 5 Clock% Clock% 2
1 Cl
1 Clock & 6666
6 . 5
! 7 66 8 ! 1
, - 1
666 ' ¯ ¯ 2
2
9*
306 Modelling Processes
"
! #
#
$ ! % ! &
" ' (
" ' (
" ' (
" ' (
& Additional Exercises 307
!"! #
$ $ $ " $ % & $ ' (
"
) * + , $ .# ) -
/ 0 0 ¾ / 0 / 0 / / / 0 / / 1 0 0 ½
2 * + , $ 1
1
0 / 0 / 0 0 )
$ $ ' Chapter 12
Distinguishing Between
Processes
# ! " $ ¯
% ¯
& #
'# ( %
12.1
The Bisimulation Game
%
) * + % % ' ) $ ¾ . ½' / , -
& & '
& ½& ' 0 F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_13, © Springer-Verlag London 2013
310 Distinguishing Between Processes
! " # $ ! " ! ! % !
every time it is her turn " ! ! & ! ! & ! #& ! '! The Bisimulation Game 311
Example 12.1
! ! " ! ! # $ $
Example 12.2
% !
&
" ' ( ) & * *
" * !
+ ( ' ) & ' &
& " + !
' ( & ( ) , ' 312 Distinguishing Between Processes
! Theorem 12.2
Exercise 12.2
$
" # ½ " #
(Solution on page 470)
"
# % ½" #
"&% ' (()#
Definition 12.2
-game equivalent " # -game equivalent
½ ½ " #
% !
! !
(! ¾
(
% 10p
½ ¿ ¾ ½ ¿ ¿
% % "coffee tea# ¾ ¿ ¿ % ½ * * (
Properties of Game Equivalence 313
ο coffee ξ tea tea ξ Exercise 12.3
(Solution on page 471)
" 12.2
0
0
0 0!
# $% %
Properties of Game Equivalence
& % '% (
% % '% Theorem 12.3
½
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
½
½
½
½
Proof: % (% )* '% % ( ) 314 Distinguishing Between Processes
½ ½ ¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
½
! " #$% & & Theorem 12.4
Proof:
½
" ½
'( ½
" ) * " ½
½
½
) " " ½
½
½
½
Bisimulation Relations 315
Exercise 12.4
(Solution on page 471)
½ Theorem 12.5
½ ¼ ½ ¾ ½
! " # " # " # # # " # ! # # $ " # " # ! # # " # " # # # % & " ¼ ½ ¾ ½ Cl Cl Cl ·½ Cl' Clock Clock
Clock ½ Clock " ( " ! #)
*+
Proof:
Exercise 12.5
(Solution on page 472)
# Cl Cl Cl Clock Clock Clock ½ Clock 12.3
·½
Cl'
Bisimulation Relations
, # ½ -#. " ! # " " ) ! # $ 316 Distinguishing Between Processes
¾ %
!"# Clock Clock $ !"#&#'
Definition 12.5
bisimulation relation
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
( ) Theorem 12.6
½ Proof: Bisimulation Relations 317
½ ! !" # $
# % " &
' ½
Example 12.6
" # ( # "
!$ )$ * # '
Ò
½ ½ ¾ ¾ ¾ Ó
+ , # ½ Exercise 12.6
(Solution on page 473)
- Exercise 12.7
, (Solution on page 473)
- " "
Æ ( ½ ½ " ½ ½ + $ " # $& . ! " $& . ! ½ # Ì
½ ' ¾ ! # !!% / # ! Clock Clock Clock ½ Clock / " 318 Distinguishing Between Processes
Definition 12.7
image-finite Theorem 12.7
½
Ì
¾ Ì
½
¾ Ì
½ ¾ Ì
¾ ½ Æ
Ì
! ¾ " ! ½ ¼ $ ½ # %&' ! ¼ ( ! Proof:
½ ( ¼ ! ) ¼ ¼ ¼ ( ¼ ¼ ¼
* ¼ ¼
¼
¼
( Exercise 12.8
(Solution on page 474)
! +
! $
$ !
! !
& -
'
! !) .! % $ $ , ! ! ! 0 0 / 0'
&(
Bisimulation Colourings 319
12.4
Bisimulation Colourings
Definition 12.8
bisimulation colouring every ! every ¼
¼
¯ ¯ bisimulation equivalent bisimilar ¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
" # $ Theorem 12.8
½ % & '() '(* %
½ Proof:
320 Distinguishing Between Processes
½ ! " ½ # $
$ # % ! &
Invariant: ' # ! $ # # partition refinement algorithm ( $ $ $ # ) *$ + $
'
%
&
, - - . / , # 0 , ( - . / ! 1 , ( 1 $
'
&
%
Bisimulation Colourings 321
! " " # ! $ %
$
'
&
%
#
# & " "
' # ' ( " " )
Exercise 12.9
(Solution on page 475)
* " # ' & " " " & & " & # & & " & " " "
" " +" & &" # # 322 Distinguishing Between Processes
" #
"
Exercise 12.10
! !
(Solution on page 475)
# $ %&% ' ( !
% ) & ) "
12.5
+ * ) ( The Bisimulation Game Revisited: To Infinity and
Beyond!
! ! ! ,
! -
½ ½
%&. The Bisimulation Game Revisited: To Infinity and Beyond! 323
Clock Clock ¾ Clock ½
Clock ½ ! " ¼ ½ ¾ ¿
#
$
%&'½¼¼ &'' ()
* + , - . / * 0& 01 0 ) $ " 2 3
45 % $
( 6 )
%7 4&4( $
%7 4&4( / %
( " ordinal numbers ½ 12.5.1
Ordinal Numbers
' & 1 0&
01
*
0
0 0&
0 01
% ( $ ) 0 1 2 *
324 Distinguishing Between Processes
successor
predecessor limit ! " ! # $ % $ $ % &
$ " ' (
( ) ! *
" + " , & !!
Æ # ! ! - transfinite induction
! ! . /,
0 $
" "
$
! "
+ - Example 12.10
1 ! " 2
( , (
,
# " ! 12.5.2
' ! # ( , " " Ordinal Bisimulation Games
& . $ " ! $ $ " '
"
The Bisimulation Game Revisited: To Infinity and Beyond! 325
½ ¼
! " # $
! $
¼
¼
½
¼
¼
% ! ' & ( ##
&# Theorem 12.10
Proof:
)
+ ¼
¼
+ ¼
*
%
¯
¼
+ *
%
* "
¼
·½
·½
##
326 Distinguishing Between Processes
¯
·½ ¯
¯
·½ ¼ ¼ ½ Definition 12.10
-game equivalent Example 12.11
!
"#
Clock
$%&
(
Clock
Cl Clock Clock
Clock Clock ·½
' Exercise 12.11
Clock Clock
·½ Clock Clock Clock
Clock
Cl Cl Cl Clock ·½ Clock
(Solution on page 477)
) # * ) · ··½ $%% * #
The Bisimulation Game Revisited: To Infinity and Beyond! 327
½ Theorem 12.11
¼
¯ ¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
Theorem 12.12
Theorem 12.13
Theorem 12.14
½
¾Ç
Proof: ½
# $ % ¼ – #
! – # ¼ ! ¼ ¼ ¼
¼
¼ ¼
! " ¼ ¼ ½ ¼
¼ ¼ ½ ¼
328 Distinguishing Between Processes
½ ¯ Ì ¾Ç ½ Æ Ì
¾Ç ½ ¼ ¼ ! " " # ¼ $ " % ¼ ¼ ¼ $ " & #
¼ ¼
' " ¼ ¼
¼ ¼ ¼ # 12.6
Additional Exercises
( " " $$ " ) * * * ( " " $$ " ) * * * * * * * * & ( " Additional Exercises 329
½
! !
!
!
# $ " " " " " " $ %%# &
! !
'0
330 Distinguishing Between Processes
¾
¿
½ $
% !
!
½ "## $ "#%$ & ' !
$ ! $
$
& ! trace set
trace equivalent $ $ $ ( $ deterministic $ $ $ $ ) $ ) $ ¼
¼
¼
* +
trace bisimulation relation
¼
¼
£
,
, ¼
¼
¼
¼
¼
-
Additional Exercises 331
¯
¼
¼
¼
!
" #
%
¼
¼
refusal set ¦
!
$
failure equivalent failures
" # %
"# &
%
" # ' ½ ¾
¾ % ¿ %
- )*
%
¿ ½ % ¾
(
$+,
·
Ë /
%
.
/
0
%
Ë
·
·
$ % ·
1 % $
% .
%
% %
% %
% $
$
%
%
$
%
%
$ Ë $ ·
2 %
%
%
%
$ $ .
/
(
332 Distinguishing Between Processes
¾ ¾ ¾ ¾ ¾ ! "# $ "#"" ! %#&
"% $ "#"# ! %#&
"' $ "#"% ! %#&
Chapter 13
Logical Properties of Processes
" # %
% %
'
% & ' % ( $
! ! & ! ! # ) % * F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_14, © Springer-Verlag London 2013
+
334 Logical Properties of Processes
Example 13.1
! "
# $%&$'()'(*+'++ "
, -. (
- . ) )(
- / . 0 0 1 ) $%&$'()'(*+'++
/ /
13.1
The Mays and Musts of Processes
2 0 3 4 / #
10p 10p coffee 10p 10p tea - . / 5 5
The Mays and Musts of Processes 335
! " # ! " # $
%coffee&
' & Æ coffee
( ( ) coffee
* + %coffee&
) "
" & + %coffee&
* true * %coffee&
coffeetrue
coffee true , - true true # . 10p 10p coffeetrue
/ 10p10p teatrue
) ( ( 336 Logical Properties of Processes
Exercise 13.1
10p 10p coffee 10p 10p tea (Solution on page 477)
coffeetrue
coffeefalse
coffeetrue
coffeefalse
Exercise 13.2
(Solution on page 477)
! ! " # ! ! Exercise 13.3
(Solution on page 478)
! " $ Cl %
% &
$ # $ Cl % '
% $ % $ $ ( # ! " ! Cl "! Cl ) ! !
13.2
A Modal Logic for Properties
*
! % !
% " ! A Modal Logic for Properties
HML ' &
valid &
true
&
false
! " (
#
(
* true
%
false
& %
satisfiable ( satisfies
&
# &
& )
! " # $
false
HML
true
%%&
337
&
&
&
&
# &
&
&
# &
& ! " &
&
! " + ,
# + , $ ) 0 HML
- ./.
## %
338 Logical Properties of Processes
false true
HML
! "
! # $ ¾
# %
! &'
! ( ( false $ ¾
# %
! # &' ! ( ( true $ # %
A Modal Logic for Properties
339
¾ ¾ ! " # HML " $ $ Example 13.3
% &
0
0
'
0
( ) " " &
true true
true true
* " ) + , +, - HML . ) - 340 Logical Properties of Processes
true
! "#true
$% % % &
' (
true &
) *
( HML (
true true
(
true true
Exercise 13.4
(Solution on page 478)
+ (
, - . true
1 . true
4 . "#false
6 . " #false
*
/ . true
2 . true
5 . "#false
7 . " #false
0 . "# true
-3 . "# true
-- . "#"#false
-1 . "#" #false
Negation Is Definable 341
Exercise 13.5
(Solution on page 478)
! ! " &
'
13.3
! # $ %! #$ ! # $ %! # $ # $ ! # $ # $ Negation Is Definable
' %( ! " ()
! ( ( * ( % &'
+ ! , % " ()
! ! - !
- . . / %( % -
0 1 0 1 ! - ! " ( 2
! " ( 342 Logical Properties of Processes
! " # $%
& ! Exercise 13.6
(Solution on page 478)
# ! ! " Example 13.6
' () true
* true false ! +
false
false # false () () false HML HML , Negation Is Definable 343
HML
pos negtrue false
negfalse true
pos pos pos pos pos $ %
$ %
neg
neg neg neg pos pos
pos #
neg pos pos pos
postrue true
! " posfalse false
pos
pos neg neg pos neg &
neg neg
neg neg
neg neg $ %
$ %
neg ' ' Theorem 13.6
pos neg Proof:
(
Exercise 13.7
(Solution on page 478)
) Exercise 13.8
HML
*+,
(Solution on page 482)
) negneg 344 Logical Properties of Processes
13.4
The Vending Machines Revisited
Î Î Î HML HML ! "10p#"10p# tea true
! $10p% tea ! $10p% ½
¾
¿
½
¾
¿
½
½
coffee.collect.
½
+ tea.collect.
½
tea & ' $10p% $tea% ( $coffee% ) ! 10p 10p "tea#false
(! * )
+ "10p# 10p "tea#false
! $10p% $10p% $tea% ! $10p% ¾
¾
¿
¿
¼
½
½
¾
¾
10p.coffee.collect.
½
+ 10p.tea.collect.
½
$10p% coffee.collect.
½
$tea% & ' $10p% ,
½
10p.(coffee.collect.
¿
10p
½
½
+ tea.collect.
½)
The Vending Machines Revisited 345
10p.tea.collect.Î
10p
¯ ο
10p ¿
ν
tea Î
¼
!
"
10p10pteafalse
10p10p teatrue
tea 10p
10p
#
10p.coffee.collect.
10p
$
10p &
% %
10p
tea 10p teatrue
¼
10p
)
+ 10p.tea.collect.
10p
(Solution on page 482)
) *" +++,
0 - 0
- 0 - 0
.% / + tea.collect.
10p
' (
10p.(coffee.collect.
10p.coffee.collect.
10p
Exercise 13.9
tea HML
' -
( 346 Logical Properties of Processes
13.5
Modal Properties and Bisimulation
!
" ! !
" # $ !
HML $ " ! % % Definition 13.9
modal depth
& ' HML
&true' ( )
&false' ( )
& ' ( & '
& '
& '
& '
&+, '
( & & ' & ''
( & & ' & ''
( * & '
( * & '
" !
HML - Modal Properties and Bisimulation 347
false
true false
!
!
true
" %
true
false true
true
false
false
# $ "
&
$ Theorem 13.9
Proof:
' #
&
true: " true false: " false
: ( ½ ¾ : ) ½ ½ ¾ ½ ( ½ ¾ ½
¾ : ) ½ ¾ ½ ¾ * ¾ + ¾ ½ ¾ ½
½ ¾ ½ ¾ ¾ * 348 Logical Properties of Processes
½ ¾ ½ ¾ ½ ¾ :
½ !
¼
¼
¼
¾ ½ ¼
¼
¼
¼
¼
"#:
$ "# ¼
¼
½ % "# $ !
¼
¼
¼
¼
¼
¼
¼
& ' ( ! ) HML ' Definition 13.10
HML HML *
HML -logically equivalent HML logically equivalent HML
Modal Properties and Bisimulation 349
Corollary 13.10
HML HML Proof:
HML ! ! " ! HML HML #
$ " ! ! "$ "
Theorem 13.10
% ! & ¼ ' ½ (
Proof:
¼
¼
¼
¼
¼
½
¾
$ " " ) ½ ¾ ) * ¼
¼
½ ¾ + ½ ¾ ½ ¾ 350 Logical Properties of Processes
Corollary 13.11
Proof:
Clock
Clock
Clock '
(
Clock
! "#$% &
13.6
Clock
Clock
Clock Clock Clock
Clock
Characteristic Formulæ
)
+ !
% !0%
+ ,
!
characteristic formula
% HML
*
0
-false
.
Exercise 13.11
(Solution on page 483)
/ !0%
" )
+
,
-false
,
0 -,-false
!0 0 0%
1 true
( 2( ( 1* .
Theorem 13.11
! % HML Characteristic Formulæ 351
true true ¼
States ½ ! Proof:
¼
¾
" #
¼
! ¼
¼
$ !
$ % ! $ % !
& ' & ( &
( ) * + ·½ , , " #
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
- . ·½
/ ·½
, . 0 ¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
352 Logical Properties of Processes
true
States
false
States
States
¼
¼
¼
¼
HML
¼
¼
! " # ! $ ¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
¾
% 13.7
¼
½ Global Semantics
$ " &! ' HML ! (
! HML & ! ! ) & & $ " ' " (
& States ! ! * ' & & Theorem 13.12
+! ! (
true: true States true
Proof:
Additional Exercises 353
false:
½ ¾ :
:
false
½ ¾
½ ¾ :
½ ¾
:
:
Exercise 13.12
false
½ ¾
½ ¾
½ ¾
½ ¾
¼
¼
¼
¼
¼
¼
¼
½ ¾
½ ¾
¼
(Solution on page 483)
¾
true
true
true
true
13.8
½
false
true
Additional Exercises
! HML " # Cl $% & ' ( ( ! HML Cl " Cl !
) false * ! % + *
354 Logical Properties of Processes
true true
true false
!
" 0 # " "
0
0
$ %
& ' ' true
false
0
true
true
true
true
true
true
true
( !
)% ! ! * ! ! ! Additional Exercises 355
¯ true true
true false
false false
#$%
! ! "" & '( & '
) * ! + , -./
true true true
true
true
true
true
true
false
true
0 1 ) + 2- -. ! 3
3
3
3
-.
4 5 + HML 6- 6- + + - ! 7
6- 6- + -. 1 6- 6- + - 2- + +
-.
"$ 8 HML - HML -. 9:* 2- 3 true
; HML 2- 3 ##$+ 3 + + -. HML ! 0
356 Logical Properties of Processes
HML true
HML
HML #$ % & $' ' '
HML # HML ( )false
HML
! "
* HML ! + % && ' ' ' HML Chapter 14
Concurrent Processes
14.1
synchronisation merge ! Synchronisation Merge
! ! " # $ !
Example 14.1
% "
#
" " & & " &
#
" " " '
" " & " " & (
" F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_15, © Springer-Verlag London 2013
358 Concurrent Processes
!! "
# $ % Synchronisation Merge 359
nisation sort Sort
synchro-
Example 14.2
Sort ! Sort " "
É
Ê
% Sort
&
$
Sort "
È É Ê
$
Sort " #
È
' 360 Concurrent Processes
Sort
Sort Sort synchronisation merge
" # !
!
$ %
" %
# %
¼
¼
¼
Sort Sort Sort
¼
¼
¼
¼
Sort ¼
& ' ( Exercise 14.2
(Solution on page 483)
( )
* ' )
14.2
+ ( + Counters
$
,
, -counter !
Counters 361
¯
¯ "
#
!
!
$
"
¼
"
¼¼
"
#
!
¼
#
¼¼
%
¼
!
¼
&
$
¼¼
Sort)* "
' ( %
!
362 Concurrent Processes
Exercise 14.3
(Solution on page 484)
14.3
¾
Railway Level Crossing
! " # $ Rail Railway Level Crossing 363
¯
¯
Road Controller Safety Properties ¯
Liveness Properties ¯
¯
! ! " Road
#
car.up.ccross.down.Road
SortRoad # up down
Road car $
up $
ccross $ % down Road car
Road
up
down
ccross
Rail
#
train.green.tcross.red.Rail
SortRail # green red
Road Rail 364 Concurrent Processes
Rail
train
green
tcross
red
train
Rail
green
red
tcross
Controller green.red.Controller up.down.Controller
Sort Controller up down green red
Controller
green
up
Controller
red
down
Crossing
" " Road Controller Rail
#
!
$ #
Mutual Exclusion 365
Exercise 14.4
(Solution on page 484)
¯ ¯ 14.4
Mutual Exclusion
! " # $% Mutual exclusion critical section & & " '
14.4.1
Dining Philosophers
" ()*+
, 366 Concurrent Processes
! "#
$ " %
" Ý & " " & " " & ' " ( " ( ! & "
Ý Mutual Exclusion 367
!
¯ ! ¯ ! ¯ ! ½
!
" # " # " # " # " # $ % & & ' & & & !
" " " " " !
Sort "
! ( ) Sort "
! ( ) & * ! % & & & $ & !
368 Concurrent Processes
½
Exercise 14.5
(Solution on page 484)
14.4.2
Peterson’s Algorithm
! " #$%#
& ' b1 ( ) b2 ( ) * k # + , - ( ) & b1 b2 k ( )
' while true do
' while true do
b1 := true;
b2 := true;
k := 2;
k := 1;
while (b2 and k=2) do
while (b1 and k=1) do
skip;
skip;
b1 := false
b2 := false
b1 k + . ( b2 ) ( k #) * b1 " b1 b2 k Mutual Exclusion 369
½
¾ b1 Sort
b1 !
" ! b1 ! !
# ! ! b1 " ! b1 ! # ! ! b1 " ! b1 ! $ ! "
! b2 ! Sort % " k & '( & ' ( & ' ) &
& ') & ' ) & ' ( &
Sort&
'( ') ' ( ' ) '(
&
' (
' )
' (
')
&
' )
370 Concurrent Processes
k k ½ ¾ !
" ! # b1 k $
%
&
# " $
while (b2 and k=2) do skip
# b2 k & ' b2 k & ! $
%
( & (
( & ) ! " b1 $
%
# $
Sort
%
& # $
% & %
( & ( ( & % Sort %
& # !$
A Message Delivery System 371
½
½ È
Ï
È
Exercise 14.6
È
Ê
Ï
Ê
½
È È
(Solution on page 485)
14.5
½
¾ È
È
A Message Delivery System
! " ! # $ ! % "
$ & ! ! ! ' (in) *! ' (snd) *! ' (ack) *" ! $
& ! ' (err) *" + + Sender , 372 Concurrent Processes
Sender
S
in snd S
ack Sender
SortSender
err snd S
snd ack err
in
sndS
Sender
err
ack
snd
S
snd rcv err Medium Medium
snd rcv Medium err Medium
SortMedium
snd rcv err
rcv
Medium
snd
rcvMedium
errMedium
err
! rcv "
out # ack "
Receiver Receiver
rcv out ack Receiver
SortReceiver
rcv ack
Alternating Bit Protocol 373
rcv
Receiver
out ack Receiver
ack
Sender
Medium
System
out
ack Receiver
Receiver
ack
in
Exercise 14.7
out
rcv
err
! "# $
(Solution on page 485)
%
14.6
snd
&'
Alternating Bit Protocol
protocols
( communication
374 Concurrent Processes
Sender
Medium
Receiver
ack
in
S
Medium
ack Receiver
snd S
Medium
Receiver
err
out
snd
S
S
Medium
out ack Receiver
rcv Medium err Medium Receiver
rcv
"
# " ! " !# " "
"$ ! " "
" ! " " ! # % "#
!
#
" " !" " & # # " ! " ! ! ' # ""( # !"( ! ! " ) " "
# " " ! " # ! " Alternating Bit Protocol 375
! ¯
#in$
& ' " % "
%
#s¼ $
#s½ $ " #ack $
#ack $
%
( ) * " #t$
,
,
in
in
,
% " %
+ Sort"
¼
¼
%
¼
,
s "ack
¼
s "ack ,
s s ,
- ack - ack
¼
- t
¼
- t
s
in
¼
ack
ack t
ack t
ack
¼
s
in
¼
%
%
¼
376 Concurrent Processes
¯
s¼
s½ r r out ! rack rack " ! # $
%
Sort
%
r outrack
%
r outrack % rack rack & r rack & r rack out
rack
r
r
r
r
rack
out
rack rack ! ! " # $
% %
s r
Sort
& s r &
%
rack ack
r r ack ack &
rack ack Additional Exercises 377
s¼
s½
r¼
r½
rack
rack½
ack
ack½
s s rack rack r r ack ack System Sender
Medium
Receiver
in
s
s
ack
ack
r
r
rack
rack
out
in out ! Exercise 14.8
(Solution on page 488)
" in out #
14.7
Additional Exercises
$ % & ' (# #
378 Concurrent Processes
¿
" ! # $ ! %&'
down
green
$
up
red
( (
# $ & # ) ) $ *
- - / 0 3
$
)
!
)
) !! !
%& !" # ) ! $ + , .
! 1 0 22 1 0 !.
4 2
Additional Exercises 379
½
¾
while true do
while true do
b1 := true;
b2 := true;
while b2 do
while b1 do
if k=2 then
if k=1 then
b2 := false
while k=2 do skip
while k=1 do skip
b2 := true
b2 := false
in
" " $
out
0
"
Sort
!
$
Sort %
k := 1;
b1 := false
# k := 2;
b1 := false
b1 := true
" $
$
0
"
&
' ( ! " )!
" )!
¼
" )!
*
¼
¼
¼
¼
-
!
"
"
¼
¼
Sort
"
¼
Sort "
+ ,
!
! Sort Sort
Chapter 15
Temporal Properties
HML ¾ HML
! %
) * "
$ #
& ! ' (
' + temporal properties ,
-
' . ¯ Liveness properties
¯ Safety properties
F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4_16, © Springer-Verlag London 2013
. 382 Temporal Properties
15.1
Three Standard Temporal Operators
15.1.1
Always:
!
"# $ %
& '
%
&'&'
* * + )
,
. %
true
+
- .
* ##
+ &'&'&'
- .
&'
+
)* & '
Û
* !" ( %
true
Three Standard Temporal Operators
383
Example 15.1
Clock Clock ! !" " HML# " $ %& &" ¾ # " ! # "
$ %& ' Clock Clock ! " " & & $ (
Clock
) true
!
Clock
) true
Example 15.2
* " " " & + ,- * .ccross/false
.tcross/false * "# " 0 ccross 0 tcross 15.1.2
Possibly:
0 #
# 1$
2# " " & & "#
) # " #
) Û * 12 $
& & ! " ' & " 3 4 5 " ! (
* "# ( 5 5
5 5 6 " & & "( !& 3 4 " 3 & % ) 384 Temporal Properties
! "false # #
$ ! "false
!" $ $ $ %
$ Exercise 15.2
(Solution on page 488)
& # $ $ true $ !"false
15.1.3
U
' # ( ) # & # % ( $ & $ ¼ ½ ¾ $ ¼ ½ ¾ ¿ $ $ Until:
½
¾
Recursive Properties
385
true !
" # $ % #% $ %
#% $ !! &# Exercise 15.3
(Solution on page 488)
' # ( " ) * +
,! # 15.2
Recursive Properties
' # # HML # - "% " ' % % # $
% % ' # HML% # # . % ( /01 #
2 # % % - "% % % % 3 3 ' # % 4 ' valuation function
386 Temporal Properties
V Variables
Variables
States
! !
" true
V false
V V V V V V %&%'
V V " V
#
V V
! States
V
V
V V
V V
States States " Theorem 15.3
( States
Exercise 15.4
$
V
V V
V
V
V
V
V true
V false
V
V V V V V (Solution on page 489)
%)&
V
¼
¼
V
V
¼
¼
Recursive Properties
15.2.1
387
Solving Recursive Equations
HML
V States
V
V V& ' "
!
V V$ %
V
"
V &
V
# !
' $ %
V $ %
V
Example 15.4
( !
)
States
States
!
!
V States
* !
V +
, " 388 Temporal Properties
V
V V
V V
V Exercise 15.5
(Solution on page 489)
!"#
V
$ % % 15.2.2
Fixed Point Solutions
& ' States States V ( % fixed point % ' States % ) * +( ,
( ( -!. !/# % 0 % 0 % % ( % % % Theorem 15.5
HML V V W V W W
) % 0 % 0 % true: trueV States trueW false: falseV falseW : V V W W Proof:
: V
V V
W
W
W
Recursive Properties
¾:
½
:
:
V
V
V
389
V V
W W
W
States States W
States States W
V
W
¼
¼
¼
¼
¼
¼
V
W
¼
¼
! ! " # # " # ! # #! ! # # $ % V &
'
( )* + !
& #! ,# #! HML modal mu-calculus # # # ! Exercise 15.6
(Solution on page 490)
- # # $ % V ! . )* +'
/ ! '
390 Temporal Properties
true
V
false
States
V
V
V V
V
V V
V
V
V
V
V
States States V Ì Ò States
ËÒ
States
V
V
¼
¼
¼
¼
V
V
Ó
Ó
15.3
The Modal Mu-Calculus
! HML " " ! # $ % %! & # '(
) true false *+ *+ , # * + $ %! ) & V # %! - $ % V " % # # $ V " $
HML ./ # $ $ & %! $ 0,
12& 34& 0, # V 5 HML & # ! The Modal Mu-Calculus 391
Theorem 15.6
V W V W V W Proof:
! " " # : V # # W
# : V " V " W W
# : V "
V "
W W
Definition 15.6
V #V true
#V false
#V #V #V #V $ %
#V
#V #V
#V #V #V #V V
#V #V #V States & States &
&
#V 392 Temporal Properties
V
V
HML Exercise 15.7
(Solution on page 490)
!
neg"true#
false
neg" #
$%neg" #
neg"false#
true
neg"$% #
neg" #
neg" #
neg" # neg"#
neg" #
neg" #
neg" #
neg" # neg"#
neg" #
neg" #
neg" #
& 15.4
V
neg" #
V
V" #
V" #
Least versus Greatest Fixed Points
' ( ( ( ( ( ) ( ( ( (
( ( * ( ( ( + , - ( ( . . ( / ( (
. Example 15.7
(( ( ( ( . (( ( ( * !
Least versus Greatest Fixed Points 393
Example 15.8
true !
true true true true true " true #
true true " true " ##
15.4.1
Approximating Fixed Points
$ %
& %
' ( )
' % ' ! ' % false true ' % % Definition 15.8
mu-approximant nu-approximant 394 Temporal Properties
½ ¼
false
¼
·½
true
Example 15.9
!¼
!½
!¾
!¿
! " false
false
false
false
# $
#¼
#½
#¾
#¿
true
true
true
true
% ! & " & ' $
( # & " " ""
& "
) ** +* , ( &- +* " * ( * true
Example 15.10
! " # $
Least versus Greatest Fixed Points 395
¼
½
¾
¿
¼
½
¾
¿
false
true true true false
true
true
true
true
true
false
true
false
true
true
true true true true
true
!"
" # ! #
" ! " # $ # " % # #& # # ## # #&
" false
' " ! ! # ! ! ! #(# true) ! # ! ! (# false ' ! ! ! # # " ! # # ' *# +, ! # ! # # ! " # # # # ! )
! " $ +-. $ ( ! & # # " " # ! States $ # # ! 396 Temporal Properties
Theorem 15.10
V
States V Proof:
! V
" V V V
# $V
V
falseV
V " ! Example 15.11
% & '
#$
( * V
)
) () +,
+-. )
" ) ) '
States
" ( States
States
States
V
States
V
'
States
V
'
States
)
"
/" ) ) V
) V
Expressing Standard Temporal Operators 397
Example 15.12
false
! " States ¼
¼
# $ $ %&' $ States
!States" States
$ ( $ $ ¼! " ½ ! " States ¾ ! " States ¿
! " States ¼
¼
¼
¼¼
! " 15.5
Expressing Standard Temporal Operators
$ ) * ! $ true " $ $ 398 Temporal Properties
'
(
Until:
false
safety
liveness
* (
+
* , +
&
U
%
'
&
&
Possibly:
%
)
&
15.5.3
" #$#
Always:
15.5.2
%
15.5.1
properties
!
properties
¯
-
Further Fixed Point Properties 399
true " Exercise 15.12
#
!
# $
true !
(Solution on page 491)
%! !
& '
(! !
& '
)! true !
& true '
15.6
Further Fixed Point Properties
* #
+ !
There is an
path.
, +
!
" # # $
!
400 Temporal Properties
There is no
path.
neg ! " #$ % & " #$ ' (
holds at every state along some
( holds somewhere along some
) ( & " path.
path.
( * ( & ( + ( , ( - . ! ' ( / ( ! Additional Exercises 401
holds at every state along every
path.
!
" # $ % & '
Exercise 15.13
(Solution on page 491)
( ' ) ! * almost always holds along some path.
+ , , - holds infinitely often along some path.
15.7
Additional Exercises
* ( weak until - . */- 0 true
false
402 Temporal Properties
'
,
.
/
1
-
!
" # 0 $ 0
% & % States(
V ) V % )V ( ( V ( * +
% & -( States ) V
) V +
+0
( entry ( entry
exit & ( 2 3
+ *
+
4 & ( 4 ( 4 ( 4 ( 4 ( 5 ) $ ( ) ( #
6 ) true 23
)
23
(
Additional Exercises 403
¾
true
¾ ½
Solutions to Exercises
Chapter 1
Exercise 1.1 (page 20)
' &' !" #$ " % & " " ! ( ! Exercise 1.2 (page 20)
) & &"
& * ! * * " ! * +" ! & ! ! &"
" * ) " ! , *-
& !& ) * & ! ) & " /
* " ! &
. ( $ " *
*
+
& ! *( *
! * (
+ * ! *
) & & ) & ! & & ) !
) . " & *
*
F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4, © Springer-Verlag London 2013
406 Temporal Properties
! " # $ %
$ % & & Exercise 1.3 (page 21)
' ( ) ( ( # ! " * ( + , # # - # . ( /
# 0 ( Exercise 1.4 (page 23)
' $( ) $+ * ) 1 )
%
%
.
Exercise 1.5 (page 24)
' ( "
) ( * ( ! Exercise 1.6 (page 24)
' + (
3& 4
2 Additional Exercises 407
! " # Exercise 1.7 (page 25)
$ #
% " & % % % Exercise 1.8 (page 26)
JoelHappy
AmandaHappy
AmandaHappy JoelHappy
$ AmandaHappy
JoelHappy
Exercise 1.9 (page 26)
! ' " ( !
(# ! Exercise 1.10 (page 29)
$ )
" #
)
" #
) " #
" #
Exercise 1.12 (page 31)
$ *
" # " #
408 Temporal Properties
É È
È
É
É
È É È ÉÈ
! "
È
È É Ê È É È Ê È
É
È
Ê
É
È
Ê
# $ $ Exercise 1.14 (page 33)
' ( ) $ * $ Love
Police
Sup
% & ,- . $ /
,- . ,- . )/
Long
,- . /
Poet
,- . /
Prison
,- . /
Cousin
,- . )0 /
/
+ Additional Exercises 409
Love !
" Police Sup
# Long Poet
$ Prison
% Cousin Love
& Poet Police
' Sup Cousin
( Prison Long
) * * & ' * + , & -Poet. -Police.! Poet Police ( / 0 - Prison. -Long.! Prison Long
1 * -Love.!
Prison - $.
Long - ( Prison Long.
Poet - # Long Poet.
Police - & Poet Police.
Sup - " Police Sup.
Cousin - ' Sup Cousin.
Love - % Cousin Love.
- 0 0 0 *0 *.
410 Temporal Properties
Exercise 1.15 (page 34)
KingMoved
LeftRookMoved
RightToCastleLeft
KingMoved
RightRookMoved
RightToCastleRight
RightToCastleLeft
RightToCastleRight
PieceBetweenLeft
PieceBetweenRight
KingAttack
KingAttack
LeftSquareAttack
RightSquareAttack
KingMoveLeftAttack
KingMoveRightAttack
MayCastleLeft
MayCastleRight
Exercise 1.16 (page 35)
! ! " ! ! ! " # FonJ
JonF
JonO
OonJ FonJ
OonF JonF
FonO JonO
OonJ OonF
FonO
$ ! % # FonJ OonJ
JonF OonF
JonO FonO
! ! Additional Exercises 411
JonF
FonJ
OonJ
JonF
FonO FonJ
OonF OonJ
JonO FonO
OonF
JonF JonO JonO
FonJ FonO
OonJ OonF
OonJ FonJ FonO JonO JonF ! " #Oskar$ % & #Joel$ &
#Felix$ ' & Exercise 1.19 (page 40)
! ( ( ! )
* " ! ( ! ! ) ! ) ) Exercise 1.20 (page 40)
+
) ," irrespective of
the premise of the conditional statement Exercise 1.21 (page 42)
-, You understand implication
You pass the exam
'
F
F
T
T
F
T
F
T
&
T
T
F
T
$
%
412 Temporal Properties
Í È Exercise 1.22 (page 44)
! Ò " # $
% & ' ( )* Exercise 1.23 (page 44)
'
È É
F
F
T
T
T
F
F
T
F
T
F
T
&
(È
F
F
T
T
F
T
T
F
T
F
T
F
É*
F
T
F
T
$
%
'
È É
F
F
T
T
F
T
F
T
&
(È
F
F
T
T
F
F
F
T
É*
F
T
F
T
(
T
F
F
T
T
T
F
F
È
F
F
T
T
T
F
F
F
T
F
T
F
É*
F
T
F
T
$
%
Additional Exercises 413
'
É Ê Ë
È
F
F
F
F
F
F
F
F
F
F
T
T
F
T
F
T
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
F
T
T
T
T
F
F
T
T
F
T
F
T
F
F
F
F
F
F
F
F
T
T
T
T
T
T
T
T
F
F
F
F
F
F
T
T
F
T
F
T
T
T
T
T
F
F
F
F
F
F
F
F
T
T
T
T
T
T
T
T
F
F
T
T
F
T
F
T
T
T
T
T
T
T
T
T
T
T
T
T
&
É Ê Ë T
T
T
T
T
T
T
T
T
T
T
T
T
T
F
T
T
T
F
F
F
F
T
T
T
T
F
T
F
T
F
T
T
T
F
F
F
F
T
T
T
T
F
T
F
T
F
T
T
T
F
F
F
F
T
T
T
T
F
T
F
T
F
T
T
T
F
F
F
F
T
T
T
T
F
T
F
T
F
T
$
%
Exercise 1.24 (page 44)
'
Ô Õ
Ô Õ
F
F
T
T
F
F
T
T
F
T
F
T
&
F
T
T
F
T
F
T
F
$
F
T
F
T
%
Exercise 1.25 (page 46)
Ô Ô Õ '
Ô Õ
Ô Ô
F
F
T
T
F
F
T
T
F
T
F
T
&
Ô Õ Ô Õ '
F
T
T
T
Ô
Õ
F
F
T
T
F F
F F
T F
T T
F
T
F
T
&
$
Õ
F
T
F
F
F
T
F
T
%
Ô Õ
F
T
F
T
T F
T F
F T
F T
F
F
F
F
Ô Õ
T
F
F
F
F
F
T
T
F
T
T
T
F
T
F
T
$
%
414 Temporal Properties
F
T
F
T
T
F
'
F
F
T
T
F
T
F
T
T F
F T
T
T
F
F
T
T
&
T F
F T
$
T
T
F
T
F
T
F
T
F
F
T
T
F
F
T
T
F
T
F
T
%
'
F
F
T
T
F
T
F
T
F
F
T
T
T
T
T
T
&
T
F
T
T
F
F
T
T
$
%
Exercise 1.26 (page 47)
'
Pressure Height Land
F
F
F
F
F
T
F
T
F
F
T
T
T
F
F
T
F
T
T
T
F
T
T
T
&
$
T
T
F
T
F
T
F
T
T
T
T
T
T
T
F
T
T
T
F
T
F
T
F
T
%
! " # # Additional Exercises 415
Exercise 1.27 (page 50)
false false
416 Temporal Properties
Chapter 2
Exercise 2.1 (page 59)
! " #
$ % & ' ( ) * " + * Exercise 2.2 (page 60)
# , -
. Exercise 2.3 (page 60)
! # Exercise 2.4 (page 60)
/
/ Exercise 2.5 (page 62)
! Exercise 2.7 (page 65)
0 '
1 ! ! !+ + '
! 2' ! 3 + ! 4! 2 Exercise 2.15 (page 69)
5 /
6 7 8 /
2+
7 8 /
# 7 8 /
7 8 /
, - 6 6 # , - Additional Exercises 417
Exercise 2.16 (page 69)
! " ## % " & &
% " $
$
&
$
$
% " % " Exercise 2.17 (page 71)
& ( )% & ))% & * % & +" & ,% -
. /
& ' * # 0))!% " " ))- 1
418 Temporal Properties
¯ ¯ ¯ ¯ ¯ ¯ Exercise 2.18 (page 71)
Ò
Ó
Exercise 2.19 (page 71)
Exercise 2.20 (page 73)
Ì
¬Ò
Ë
¬Ò
! "
! Exercise 2.23 (page 75)
# # Exercise 2.24 (page 76)
$ %
Love Police Sup Long &
! Poet NoPrison Cousin &
' Police
Sup
%
Additional Exercises 419
Long
Poet
NoPrison
Cousin
Love
Poet
Police
Sup
Cousin
NoPrison
Long
NoPrison
!
!
!
!
!
!
Long
Poet
Police
Sup
Cousin
Love
NoPrison
Long Long
Poet Poet
Police " Police
Sup Sup
Cousin
Cousin Love ! # # # # $% & % & % & $ '% '
Exercise 2.25 (page 77)
( $ $ # & $ $ & & $ $ & $ # $ ! &$ ) $ $ * # + #$
Í
, $ $ # $ # & % & & $
# $ 420 Temporal Properties
Exercise 2.26 (page 77)
Í
! " ! # $! $% &%' ! # ' ( !) $! $% %' $% * ! $ ! Exercise 2.27 (page 80)
Exercise 2.28 (page 80)
( ) # ( ) ( )
# ( )
# ( ) # Additional Exercises 421
Exercise 2.29 (page 81)
¯
Exercise 2.30 (page 83)
Exercise 2.31 (page 83)
! "# $ %
% $ & '
& $ $ % % $& $ $ $ (
$$ % $ $$ % $
$ % )$ % & & '
$ *$ F
$ % % $ '
Chapter 3
Exercise 3.3 (page 89)
$ $%$ & $ % $ $ & +$ * $ )$ , $& %
- - - $ % & ) - . %
/ $ $ $ & $
'
422 Temporal Properties
Exercise 3.9 (page 92)
! "# $ % & ' "(
) % ! ' %
! *
'+
¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
Exercise 3.10 (page 93)
ÜÝ Ü Ý Ü Ý Ü Ý ¼
¼
¼
¼
¼
ÜÜ ÜÝ Ü Ý ÝÝ
¼
¼
¼
¼
ÜÝ Ü Ý
¼
¼
)
ÜÝ ÜÞ
ÜÝ ÜÜ ÜÝ
Ü Ý Ü Þ ¼
¼
Ü Ü Ý Ü Ü Þ ÜÜ ÜÞ
ÜÞ
¼
¼
¼
¼
' )! ' % ", " Ü Ý ¼
$ - Ü Ý . Ü Ý Þ
Ü Ü Ý Ü ÜÜ Ý Ý Ü ¼
Ü ¼
¼
Ý Ý Ý Ý ÜÝ Ü Ý ¼
¼
¼
% Ý ÜÝ Ü Ý Ý / - Ý Ý ' ÜÝ Ü Ý Ü Ü Ü
¼
¼
¼
¼
¼
¼
Additional Exercises 423
Exercise 3.11 (page 94)
Ü ¼
¼
¼
¼
¼
¼
¼
¼
¼
Exercise 3.14 (page 99)
¼
! "
#
Exercise 3.15 (page 99)
# $ $ " # " &
" ¼
¼
' ' '
' '
'
'
'
' '
'
'
%
$ " '
'
'
' '
'
'
' '
'
'
'
' '
'
' '
' '
'
'
'
'
'
'
424 Temporal Properties
Exercise 3.16 (page 99)
! ¼
¼
¼
¼
¼
Exercise 3.17 (page 102)
"# "" $%
Chapter 4
Exercise 4.2 (page 111)
% & & ' ( " ) " ( ' " & " * & ( & ¿ & $ & $ ¾ & $ * " " * % (
) $ % ' " + * , Exercise 4.5 (page 115)
% " * Exercise 4.7 (page 117)
% " ¼
Additional Exercises 425
Ü Exercise 4.8 (page 117)
! "
# Exercise 4.9 (page 120)
% $ % & ½
½
½
¾
¾
¾
½
¾
Exercise 4.10 (page 121)
$ ' (
) *
& ' (
*
) '
( 426 Temporal Properties
Ü Ü
Ü
Ü Ü Ü Ü Ü Ü Ü Ü Ü
Ü
Ü Ü Ü Ü Ü Ü Ü Ü Ü Exercise 4.12 (page 125)
Ü
! ! "
#
% $ % -
(
$% % & $ " $ $ %
$ )$ +
" $ "
. "
*
+
$
'
% $ , $ $ $ % % . %% " $ Exercise 4.13 (page 127)
% % $ % "
! ! $ !
%%
Additional Exercises 427
Chapter 5
Exercise 5.2 (page 134)
Fact 15.14
Proof:
Exercise 5.3 (page 136)
Proof:
! "#$ ! " #$ ! %"#$&%" #$& ! ' # " # " # $
! "%" # # & # $
! " #$ ! " # # Fact:
Exercise 5.5 (page 138)
( (
') '#) ! * ( ') (
* +(* +)( *#+#(#*#+#)#( ! ') ( * +(* +)( (
Exercise 5.9 (page 141)
Fact:
428 Temporal Properties
Proof:
Exercise 5.10 (page 142)
Fact:
Proof:
! " # " $ % Exercise 5.13 (page 145)
Fact:
& # ! ' Proof:
(') ' ! ' ( )
# ! Additional Exercises 429
Exercise 5.14 (page 146)
Fact:
Proof:
Exercise 5.15 (page 147)
Fact:
! Proof:
" &
# $%
! Exercise 5.16 (page 147)
Fact:
Proof:
' & ' ¾ $ ( ) * +
- ¾ $
¾
' ( , ' (
¾
' 0 1 ' )
¾
' 2 3 ' ,
¾
' ) + ' +
¾
' * ' *
4 ' ' /
,
$ ' .
430 Temporal Properties
Exercise 5.17 (page 147)
Ü
Exercise 5.18 (page 149)
Fact: Proof: ! "
# $
% % ! # & $ Exercise 5.19 (page 151)
Fact: ' # # ()$
$
Proof: * ' % # ()$
)
+
) ( )(, )
) ( )(, )+
) ( )(, ( )
+
)
)(, ( )
, )(, )
)
) #,$
, #)(,$ )
,
- . / ' # ()$ 0 ¾
(
'
% )
+
) ( , Additional Exercises 431
Exercise 5.20 (page 152)
Proof: Fact:
– ! – ! ! " – ! – ! " Exercise 5.22 (page 153)
" Proof: # " " " $ % " & ' ( Fact:
Chapter 6
Exercise 6.2 (page 158)
rangescore
score
½
) * *+ ) ), -* -, ,, + .. /
-. 432 Temporal Properties
Exercise 6.3 (page 158)
Exercise 6.4 (page 160)
graph Exercise 6.5 (page 161)
score ! ! score" score#$ % ! score& score'
( Ê Ê ) ¾ ! ! * ! Ê ( ) ¾
Exercise 6.6 (page 161)
score ! ! +
( Ê Ê ) Ê ! ! Ê ( Æ Æ ) ¾ ! Æ ¾ ¾
+
¾ ! Exercise 6.7 (page 161)
½ ! ! ! , ! !
)
Additional Exercises 433
Exercise 6.8 (page 163)
Exercise 6.9 (page 164)
Æ
Æ
Exercise 6.10 (page 165)
Æ
Exercise 6.11 (page 165)
! " # $ % # & '( ½ ) ) * ) + ½ ) , ½ ) id ! -( % # & ½ ) ) + ½ ) , ½ ) id Æ
Exercise 6.12 (page 166)
Æ Æ ) Æ ) ) Æ ) Æ Æ Exercise 6.14 (page 170)
½
)
,
Æ
434 Temporal Properties
Exercise 6.15 (page 170)
Æ ½ Exercise 6.16 (page 172)
!" # $
' % & '
Exercise 6.17 (page 173)
( " ) $ %& %&
) $ %& %&
* %& Exercise 6.18 (page 174)
+ ' " % & % & $ % & % & % ' & % & ' ' "" $ ! " $
! , ' ' " $ !
Exercise 6.20 (page 176)
)
% & -' -' % &
' % & % & ¾
% & ' ¾ % & . ¿ % & ' / ¿ % & . # % & ' ' ' % & . ' Additional Exercises 435
L G Chapter 7
Exercise 7.1 (page 180)
Exercise 7.3 (page 183)
! " # $!
! %& $!
! ' & ( ) % $!
* +! ( , - . / )$!
! " 0 1 2 )$!
3 * - ! % 4 5 ) -$!
3 * - ! - 6$!
3 * - ! 2 ' & 7 ($!
! #) #) 1* $!
3 * - ! ( 4& $!
3 * - ! 1 8 9$!
%0 " ! % )* " * $!
%0 " ! 9$!
: ; ! 7$!
: ; ! % 0 #) " $!
: ; ! % 5 < # 7 &*$!
: ; ! " 1 " $!
" *! 3 $!
" *! =& &0 > $!
" *! 6> $ Exercise 7.5 (page 184)
* ! ! %"! :;! " > ! * +!
3 * - ! %0 " ! : ; " *! 4?
)! > > * 4 ! $!
! $! ! 3-$! ! %"$!
436 Temporal Properties
!
$
" #!
!
Exercise 7.6 (page 185)
$
%&'
%&'
( (
(
Additional Exercises 437
Exercise 7.7 (page 187)
!
"
½
¾
¾
½
¿
¿
½
¾
¿
Exercise 7.8 (page 188)
½
Exercise 7.9 (page 189)
Æ # $ % &
' # % # ' # % # % 438 Temporal Properties
¯
Æ ! " # " # ! Exercise 7.10 (page 190)
"
" $%
Exercise 7.11 (page 191)
" &' ( !) # # #
" &' * + " &' &' * + * + Exercise 7.12 (page 191)
" , ' -" "- . , ' -(! (!- - (!
" , ' -(! (!- * + * + Exercise 7.13 (page 192)
" , ' /0- -(! /0(!
" * + * + # * + Additional Exercises 439
Exercise 7.14 (page 192)
¯
¯
¯
¯
¯
¯
Exercise 7.18 (page 194)
! Exercise 7.19 (page 194)
" ½ " " " " " ¾ # $ % " & % ' " ' $ ' " Exercise 7.21 (page 195)
( ) ) ) 440 Temporal Properties
Exercise 7.23 (page 196)
Exercise 7.24 (page 196)
'
(
"
%
!$
' !' ( !( " ! % !$ !
#
'
!
!#
! " # # ! !" ' ! !# $
&
$
&
!!
!%
$ % !& &
$ & !! !% Chapter 8
Exercise 8.1 (page 203)
" : ) * ( * !* + !* ! +
!* $ + !* " "' : , "' (* * "' - !* - $' +
- !' + ' +
(' + (' + ' + . - /* 0 * ( ! $ " ! + * - +
"'* "' Additional Exercises 441
Exercise 8.2 (page 204)
smallest
Exercise 8.3 (page 204)
Exercise 8.4 (page 205)
!
Exercise 8.5 (page 207)
!
" # $ % & ' (
Exercise 8.6 (page 208)
.
)*+ , true false
/
½ ! 0
- ½ 0 ! ½ 0 !
! Exercise 8.7 (page 212)
)*+ , 1
442 Temporal Properties
½ ¾
Exercise 8.8 (page 213)
! "#
! ""
! " &
! " %
! " *
! " '
+ #
#
#
#
#
#
$!" # #
#!% # %
%!' # (
( ! ) # #'
#' ! #$ # "*
"* ! #" # &'
Exercise 8.9 (page 213)
, #!#!#!#!#!#
%(
" %*
# " & % * '
"$
- .
! ##
$!# #
#
!"
# ! #" &" # *
& ! # ## # )&&
! &#
" &
'
#
##
#
"*
! %
' ! % #" " $)&
"* ! # #&/ " ")&
! *#
#" *
'$
#&/ ! # %( " %*
! '#
'$ ' "$
Exercise 8.10 (page 214)
0 1 1 # # " 2 # 0 &
" % & Additional Exercises 443
¯
½ ½ ½
¾
Exercise 8.11 (page 215)
Exercise 8.12 (page 215)
!
$ #
" %
!& '"
&
! '"
&
!'"
&'
!
"
&'
(
Exercise 8.13 (page 215)
¾
# ¾
! " ¾
# ¾ Exercise 8.14 (page 216)
true
½
false
½
Exercise 8.15 (page 216)
) * , $ + - 444 Temporal Properties
¯
¯
¯
¯
¯
¯
¯
¯
¯
Exercise 8.16 (page 218)
Exercise 8.17 (page 220)
!" !" ! !" #!" !" !" !! ! !" ! ! $! %
!" ! ! !" !" ! &
!" ! !" " !" ! '! !" ! ( !
&
) (! ! * + !" ( ,( % (
Chapter 9
Exercise 9.1 (page 226)
! ( !"! !" ( ( ! ! + ! !! ! ( !"! % ! !
- !
+ ( !(! (! !"!
½
!
! !+ !" !" +
+ %+ & .
Additional Exercises 445
½ ¿ ¾ ! " # $ % & ' ' ( ) $ * ( )( )( ) ' ( ) ( )( )( )
+ , , Exercise 9.2 (page 228)
# + + . + . . . / .
.
/
.
/
. /
. . /
Exercise 9.3 (page 228)
0 1 , /
2 34
44 22 2 3 3 3
/
4 4 4 /
34 4 / 3434
4 4 4
446 Temporal Properties
! Exercise 9.4 (page 231)
" ¾ # $¾ # %¾ #
Proof:
* #( # ¾ & '#('$
)
+ # $ ¾ # %¾ #
# ¾ & & '#('$'(#(
)
Induction Step: + #( ¾ # $ ¾ # %¾ #
# ¾ & ' #('$
)
#%(
¾ # $¾ # %¾ # # ¾ # ' #(¾ & ' #(' #$('$
)
& & #
¾ # $¾ # %¾ #
# ¾ # '#(¾
#( # '#(¾ & '#('$
)
& '#(
) '$#( # )'#(
¾
& '#(
$
#
,
#
)(
)
'
#(
& ) '#$('$#%(
#%(
& '#('#$('$
)
$ " # % # # # '$ ( & ¾ Base Case:
¾
Proof:
* + # % # # # '$'(( & & ¾
Induction Step: + # % # # # '$( & ¾
Base Case:
Additional Exercises 447
¾ ¾
¾
¾
!
" Proof: # Base Case: $ " Induction Step: $
!! ! !!!
"
" " Exercise 9.5 (page 232)
! ¼ ½ Proof: # Base Case:
·½ ¾ ! ¼ ½ 448 Temporal Properties
Induction Step:
¼
½
·½ ¼ ½
·½ ·¾ ¼ ½ ¾
·½
·½ ·½
¾ ½
¾ ·¾
¾ ·½
·¾ Exercise 9.6 (page 232)
¾ ¿ ·½
Proof:
Base Case:
¾ ¿ Induction Step:
¾ ¿ ½
¼ ¾ ¿ ·½
·¾
·½ ! " ·½ ·½
Additional Exercises 449
½
·½
·½ ·½
·¾
·¾
Exercise 9.7 (page 233)
¾ Proof: Base Case: ¾
Induction Step: ! ¾ ¾ " ! ! " # ¾ ¾ ! $ % ! &
'
" #
& &¾ & & Exercise 9.8 (page 234)
¾ # (
Proof: Base Case: Induction Step: ( (
! !
# (
# (
( ( (¾ #
¾
# ! ! ! # ! ¾ " ! # ! 450 Temporal Properties
¾ ¾ Exercise 9.9 (page 235)
Proof:
! " Exercise 9.10 (page 236)
# Proof:
$ Base Case '
Induction Step: %& (
(
"
'
½
Exercise 9.11 (page 236)
Fact:
Proof:
¾
¼ ¾
½ ¾
¾ ¾
½ ¾
·½ ¼
(
Base Case ('
¾
¼ ¾
¾ ¼
¾
¾
(¾ (
¼ ½
Additional Exercises 451
Induction Step
¾
¼ ¾
½ ¾
¾ ·½ ·½
·½ ¾
¾
·½ ¾
·½ ·½ ·¾
Exercise 9.12 (page 238)
Fact: ·½ Proof:
¾
Induction Step ¾
# $
Base Case ¾
¾
¾
¼ ½ ¼
!" % %
¾ ¾
Æ ¾
·½ ¾
# # & ·½ ·¾ ¾ ' ¾
¾ ¾
¾ ¾
¾
¾
Exercise 9.13 (page 238)
" # Fact:
¾ ¾
·½ ! !
( # ¾
! % ½ ¾ ! ¾ ¾ %
# Proof:
! ¾
¾
%
¾
¾ ¾ ¾ ' ¾
¾ ¾ ¾
·½ ! % ! " %
% 452 Temporal Properties
Ü
½
·½
·¾
·½ ·¾
Exercise 9.14 (page 239)
Fact: ¾·½
·¾
Base Case ½¾ ¼ ¾
Induction Step Proof:
¾·½
·¾
·½ ·½ ¾
½
·½
¾
½
¼
·½
½
·½
¾
½ ·½
Exercise 9.15 (page 239)
! ! Exercise 9.17 (page 243)
" # ! ¼
¼
¼¼
¼¼
Additional Exercises 453
¾ Exercise 9.20 (page 246)
Fact:
Proof:
½ ¾ ½ ½ ¾ Base Case
¾ ½
½ ¾ ¾ ½ ¾ Induction Step
¾ ¾ ¾ ¾ Chapter 10
Exercise 10.1 (page 257)
)
!
!
"
#
$
%
&
!
'
(
)
+ * ,
)
* "
*
)
)
" . - "
"
- - , - "
" !
* 454 Temporal Properties
! " #$ "
Exercise 10.2 (page 258)
% &
% ' ' ' ' ( )
' ' ! ' Exercise 10.3 (page 258)
* ' +
¯ , - ( - . - ( ( - ¯ / - &
+ ( , - . - ¯ " - 0 - / - ( / - Additional Exercises 455
¯
¯ !
¯ " # ¯ $ " ¯ $ %
& '! ' %
¼
¼
¼
¼
¼
& %
& ! Æ '
¯ '
%%! ' ! !
¯ '
! ' ! ¯
¼
( ' ( ! 456 Temporal Properties
¯ !
¼
¼
¼
Exercise 10.4 (page 259)
" #
¯ $ !
¯ %
$!
¯ & ¯ ' ( % !
¯ ) ¯ (
$!
¯ ¯
'!
¯ '!
!
!
!
Exercise 10.5 (page 262)
" * ! + , - . * !
/ . !
/ 0 !
Exercise 10.6 (page 262)
" - !
Additional Exercises 457
Exercise 10.7 (page 264)
" # ½
¾
& ½
""## '"#
"# "# $ "!# ! ( % Lemma 1.
½ ¾
! !
not
may
"# ( $ "# "# ""##
Lemma 2. ! "# "# '
"# ( must is
( "# "# )!* +
½
"½ # ¾ , ) "¾ # ' " # $
Proof of Lemma 1.
,
"¿# $ ,
½
' ¿ ¾
458 Temporal Properties
½ ¾ ½ ¾ ¾
½ ¾
½
½
½
½ ·½
½
Proof of Lemma 2.
½ ¾ ½ ¾ ! ½ ½ ½ ½
½
¾
" ½ ½¾ ¾
½ ¾ ¿ ½ ¾ ¾ ¿ ½ ¾ ¾¿ ½ # ½ ½ ¾ ½ ¾ ½ ¾ $ % ½ ½ $ $ $ % $ & ½ ½ ·½ ½
·½
½
Additional Exercises 459
Exercise 10.12 (page 270)
Chapter 11
Exercise 11.3 (page 286)
! " " # $ "%
# $ " # & $ '% # $
( '% )% * # " " " "%$ * # " % $ +
', * '-. # $ 460 Temporal Properties
! " ! ! "# $" % &! '(
%
& '( % '( % '( % &! ' )
!# "! ! "
# ! & ! Additional Exercises 461
Exercise 11.4 (page 287)
!
" ! #$ "%
#% & $ ! ! ' !
( )
$&
$&
$&
$&
$&
$&
" *!
#
*!
! !
!
(! + # # +
! #
" + (! + "
" !
!
, $ -% )
! !
" ! . #
! .
" . ' #
. !
' !
Exercise 11.5 (page 287)
% %
)
)
# $ ' ) . % . %$ % /
) . % . %$ % 0$ / )
) 1 ) 1 & ) 1 % 0 # / 1 2 1 / 462 Temporal Properties
&
# $#% "
" " ! '
"
( ) * "
+ + ( ) Exercise 11.6 (page 288)
, #
. /01
. 2/
. ,20
. 34
. 2/
. ,20
5 . ,/
. 34
. ,/
. 1
. 4
.1
-
Additional Exercises 463
x := x mod y y := y mod x
Ü "
#
!
#
!
"
!"
"
#
!
#
!
#
x := x mod y
!"
"
!"
y := y mod x
x := x mod y
y := y mod x
x := x mod y
Exercise 11.7 (page 289)
Exercise 11.8 (page 290)
Cl
Cl¼
$ Cl Cl¼ %
tick
tick
Cl
Cl Cl
Cl¼ Exercise 11.9 (page 291)
& $ tick% 464 Temporal Properties
¾
½ ¾ ¾ ¿ ! ½ " ¾ " ¿ " !
" " " " " " " " " " #! " "
" $
&& ' ! " $
" ( $
%
& &
( ( " %
" & ' & ' && &
' &
" ½
Additional Exercises 465
¼
¾
¼
¼
¿
466 Temporal Properties
Exercise 11.10 (page 291)
!
" ! #$ % & ' ( ' ) ' ) * ( & ( ! + & #$ % ( ' ( ! ( , -. / 0( -. ( 1
( # 2 ( Additional Exercises 467
Exercise 11.11 (page 296)
!
"
# # $ % # &
' (
Exercise 11.12 (page 297)
Cl
%
tick Cl
#
tick Cl Exercise 11.13 (page 298)
)
%
# # # # # + - % *
% )*
(
10p.coffee.collect. + 10p.tea.collect.
coffee.collect.
tea.collect.
collect.
,*
+
. )
Exercise 11.14 (page 300)
- +
468 Temporal Properties
¼
Î
10p.coffee.collect.Î
10p.tea.collect.Î
coffee.collect.Î
tea.collect.Î
collect.Î
Exercise 11.15 (page 301)
10p 10p tea Additional Exercises 469
0
Exercise 11.16 (page 301)
!! ! !! ! " !! ! !! Exercise 11.17 (page 302)
# $ %! reflexive:
&!!
! '
'
' ! (# ! ) '
! ! symmetric:
'
transitive:
! ! '
' ! (#
*
*
' +
' +
Exercise 11.18 (page 303)
! ' ¼ ! $ ! % ' ½
'
½
470 Temporal Properties
¾ ¿ ¼
½ ¾
¾ ¿
Chapter 12
Exercise 12.2 (page 312)
! "
! Fact:
# ! ¼ $
! ! %!! !! &
Proof:
¼
¯
¼
¯
¼
¼
¼
¼
¼
¼
¼
!
' !
¼
¼
¼
¼
¼
( !! ! ·½ ) )
! ! !
( ! ·½ ! ·½ !! ( ¼
¯
¼
! ' ! ! ! ·½ ' ¼
¼
¼
¼
¼
¼
¼
Additional Exercises 471
¯
¼
¼
½ ¼
¼
¼
¼
¼
Exercise 12.3 (page 313)
¾
¿ #
#
#
0$ 0
0
0
$
0
0
0 0 $ 0
0$0
0
0 $ 0
0
0 $ 0
! 0
0
"
0 0 $ 0
½
¼
Exercise 12.4 (page 315)
Fact:
#
Proof:
#
#
%& '(!' ·½
¼ '(! ·½ !'! "
) 472 Temporal Properties
·½
·½
½
¼
¼
¼
·½
! " # ·½ # !
$
¼
¼
¼
¼
¼
¼
¼
¯ $
¼
¼
¼
¼
¼
¼
¼
¼
¼
! ·½ ! " # ·½ # !
$
¼
¼
¼
¼
¼
¼
$ ¼
¼
¼
¼
¼
¼
¼
¼
¼
¼
# # " ·½ Exercise 12.5 (page 315)
Cl
Fact: %
Cl Cl
·½ Cl
Proof: & ' # ! Base Case: Cl¼
¼ Cl # Induction Step: (" Cl
Cl ·½ ·½ Cl
Cl !
' " # " !
Cl ! Cl ) " # Cl¼ ! Cl ! # # Cl
Cl ! Fact: %
Clock
Clock Clock ½ Clock
Additional Exercises 473
Clock Clock Clock Cl Clock Cl Clock Cl Cl Cl !"! Clock Clock # Cl Cl
Proof:
½
Exercise 12.6 (page 317)
$ !% &
' ' &
' &
' &
' ' &
' ' ½
½
½
Exercise 12.7 (page 317)
( Æ ¼
¼
¼
474 Temporal Properties
¼
¼
¼
¼
¼
Æ
¼
¼
¼
¼
¼
¼
Æ
¼
¼
¼
¼
¼
Æ
¼
¼
¼
Exercise 12.8 (page 318)
transitive:
! ½ symmetric:
#
"
reflexive:
$ ! ½ ! % ! &' ½ ( ')* +', simulation relation # ¼
¼
¼
¼
¼
¼
¼
½
–
¼
$ ¼
¼
¼
'), +', ¼
½
'), .
#
- Æ
/0 ')1
2
Æ
Additional Exercises 475
Æ ¼
¼
¼
¼
¼
¼
¼
¼
Æ
¼
¼
¼
0 ¾ 0 0
0 ¾ 0 0
Exercise 12.9 (page 321)
"#" !
!
$ ! %
Exercise 12.10 (page 322)
& "#"
$
'
&
%
!
)
!
!
( %
% ' (
476 Temporal Properties
$
'
&
%
$
'
&
%
$
'
&
%
Additional Exercises 477
Exercise 12.11 (page 326)
Clock
Clock
¾ ¼
Chapter 13
Exercise 13.1 (page 336)
coffeetrue true
coffee
coffeefalse false
coffee
coffee coffee false ! " #$
! " false
% &coffee'true true
coffee
( coffee ( true !
! " true
) &coffee'false false
coffee
* coffee false "
! coffeetrue
Exercise 13.2 (page 336)
true
+ + + 478 Temporal Properties
Exercise 13.3 (page 336)
tick ticktrue
Cl
Cl
tick
tick
$
Exercise 13.4 (page 340)
!
" # $
%
&
'
(
% Exercise 13.5 (page 341)
true
true
%
&
true
true
* true
) + - . $ Proof:
, ,
,
0
/ ,
0
/
0
/
/
,
,
, 0
Exercise 13.7 (page 343)
Theorem 13.6:
1 Exercise 13.6 (page 342)
Fact:
,
$ true
HML2
true
Additional Exercises 479
pos Proof: neg pos neg pos neg true
postrue
true ! postrue"
negtrue
false ! true ! negtrue"
true false"
false
posfalse
false ! posfalse"
negfalse
true ! false ! negfalse"
true false"
pos
neg ! neg pos
pos"
! "
! "
! neg"
! "
! "
480 Temporal Properties
½
¾
½
pos
½
pos
¾
pos ½ ½
½
¾
pos
¾
¾
pos
½
¾
neg
½
¾
pos
neg ½ neg ¾
neg ½ neg ¾ ½ ¾
½
¾
½ ¾
½
pos
¾
pos ¾
pos ½ pos ¾ ½ ¾
½ ¾
neg
½
½
¾
pos
pos
½
neg ½ neg ¾
neg ½
neg ¾ ½
¾
½ ¾ ½ ¾
pos ¾ ¾
¾
½
½
neg
neg
½
¾
¾
Additional Exercises 481
pos pos
pos neg
neg neg
neg pos
pos pos
pos neg
neg neg
neg 482 Temporal Properties
Exercise 13.8 (page 343)
Fact:
Proof:
true:
negnegtrue
false:
negnegfalse
negneg negfalse
true
negtrue
false
negneg ½ ¾ : negneg ¾ ¾ negneg ½ ¾ negneg ½ neg ¾ negneg ½
negneg ¾ ½
¾
½
½
¾ : negneg ½ negneg ¾ ¾ negneg ½ ¾ negneg ½ neg ¾ negneg ½ negneg ¾ ½ ¾
½
½
:
:
negneg negneg neg neg negneg negneg negneg negneg negneg Exercise 13.9 (page 345)
!" ###$ % "
HML
&' &' &'
&' (
false false
Additional Exercises 483
¯
true true
! neg neg Exercise 13.11 (page 350)
" # true false false
# 0
$ % & '
$ & !
$ % & (
) $ 0 * 0 true false true true false Exercise 13.12 (page 353)
"
)
+
,
-
.
true ½
true ½ ¾
true true false true Chapter 14
Exercise 14.2 (page 360)
/ 0 Sort $ ! Sort
0 0 Sort $
0 Sort Sort 0 0
484 Temporal Properties
Exercise 14.3 (page 362)
¾ ¾
¼
¾ ¼
¾
¼¼
Exercise 14.4 (page 365)
! " ¯
¯
" #
$ #
Exercise 14.5 (page 368)
" " " % " % " " " & ' " "
( " $ " ) * + " + Additional Exercises 485
Exercise 14.6 (page 371)
¯
b1 b2 k ¯ b2 k ! ½
½
¾
Exercise 14.7 (page 373)
! " # ! $ % ! &
Sender ' insndS
S ' ackSender ( errsndS
SortSender ' snd ack err
&
in
Sender
snd S
err
ack
snd
S
! $"
)rcv* )out* $"
)rack* "
)rerr* 486 Temporal Properties
Receiver
rcv out rack Receiver
SortReceiver
rerr rack Receiver
rcv rack rerr
rcv
Receiver
rack
snd rcv rack M
M
ack Medium
SortMedium
rcvrackM
ack
errMedium
rcv
rerr
rack
rackM
"ack#
err
"rerr# rerr rack M
Medium
"rack# err Medium
snd
M
% snd rcv err
Medium
! "rcv# $ & out
rackReceiver
outrackReceiver
rerr
Additional Exercises 487
in
Sender
Medium
Receiver
snd S
Medium
Receiver
err
ack
snd
S
S
M
Receiver
rcv rack M err Medium Receiver
rerr
rack
rcv
S
rack M
rack Receiver
S
rack M
out rack Receiver
out
! System
# in
"
Sender
Medium
!# snd
ack
err
$ ! Receiver
rcv
rack
rerr
out
#
488 Temporal Properties
Exercise 14.8 (page 377)
¯
Ë Å Ê Ë¼ Šʼ in Ë Å Ê ¼
in Sender ˽ Medium Medium
Sender ack Sender ˽
Å ack Sender × Ø Medium
Receiver ack rack
Receiver rack Receiver ʽ ˽
Šʽ
out
Chapter 15
Exercise 15.2 (page 384)
true
true
"#false
! È
È È
"#È ! Exercise 15.3 (page 385)
$ È È É È È % & ' È É ( ' É
true true ( $ È
true È Additional Exercises 489
Exercise 15.4 (page 386)
Fact:
V
true:
false:
:
V
V
:
true
V
false
V :
V
:
V
V
V V
V
V
V
V
V
V
V
States
V
V
V Exercise 15.5 (page 388)
V
V V V V V V V V V
V V V V V :
falseV
trueV
V
:
V States
Proof:
490 Temporal Properties
Exercise 15.6 (page 389)
V V States ! " # ! $ % & V States ' ( ( ( )% # V % & Exercise 15.7 (page 392)
' " * %% * + " , % HML & - . % -!-
:
V neg V V V :
V neg V neg States V neg States V neg States V V :
V Additional Exercises 491
V
neg
States States States V V neg V
V
V
neg
neg
Exercise 15.12 (page 399)
! " ! # ! $
% $ & ! ! !$ # ! % ! ' % ! ( ( ! ! Exercise 15.13 (page 401)
almost always holds along some path.
) ! ! ! * + 492 Temporal Properties
holds infinitely often along some path.
! " #
Index
F
É
Ê
Æ ¬Ò id Æ
T
0
½ V F. Moller, G. Struth, Modelling Computing Systems,
Undergraduate Topics in Computer Science,
DOI 10.1007/978-1-84800-322-4, © Springer-Verlag London 2013
494 INDEX
! "#
%
2
2
8-
8
"
8
&
#
3-
4
80
- &
-
#
7
& &#
8: 5#
8:! 5#
8 #
#
(
&#
8! 9 (
- &#
2#1.# "
)
8 #
1& (
#
/
7
8 5
& &#
5
0 & &#
2
# 0
# 6#$
2 (
( & ./ (
((
-
& ,
2#
10# 2 (
# & '
(#
# ( & )*+)
2 (
$%
# (
2."
& # #(
2 4#
# INDEX 495
2 # !$( -# +, # "" $ $ $ %
!# " .# ! " # % % # ! 3" # #
$ $ -
% # % & # ( - - ." ! ) &# & 7 #" 7 !# +, - ! ( " -5
6 ( ! '#* .
! '# !((*
- " ! ! '#
% !
-* 4 ! /0 +" 1# 7 84 # 7 & 7 496 INDEX
6& 92
6
/9 &
62
HML
:
'
,
-
+
,$
2
-
,
& & '
'
0 1 '
3 $
.2 '
+
-
&
%*
52 & %* + ,
,
%*
%* $'
! &
'$
3 -
-
1 6
'
',
-
! -
'
-
6 ,
-
% '$
. 4
+ ,
% ,
&
+
'
&& &+
2 & '
.2
./ / / .2
*
/* '
. ',
'
+ ./ / $-
-
+ + '
'
2
!9"
''
& &/% ,
)
.
3 2 # & &
& .0"
',
,
6 . ) %* + &
,
$
(
,
% 6
$
% &
'
& !"#
07 8
+ +*
-
! 9 "
2 -
'
INDEX 497
30 ,'<
30 3 "
$
#
% $ $
-
/
)
* ' mod
%,
3 - .
)
"66
,
/
=
/
)
,
)
1
/
7 1 -
)/
)
/
%
/
1#1.
( (, ( 3 (:(& ; &,
, /
, (, 5
+ 1 5 1 , <
nil
/
5 1 /
1 - 1
9 ' ;
1#1.
1 > ,<
3 /
)
& ( %% %% ' /
%
% % 8 )
#- %% )
3 $
)
)
1 ' /
,'
)
/
- #- -
5
2 3 0, -
)
( 4 % -
1
"
,
/
,
' //
.-
- , % #0#.
(+ +, ) ;- )
%
)
3 & ' $ ' # '( !
3 ( ,
%
)
+, ?
)
)
/
498 INDEX
0
+
(
$+
5
$+ & nil
!" # # $
#
$$ #
0 ' 12
,' (
,3
' . 4 5 $
$ $ $
$
*
#
5 +
*
$ ( ' (
- ' & #
# #
# #
#
#
5 +
$ # &
6' ' (' *
0 + & *
'
'
*
-
#
*
$
#
,3
'
, . / (
*
5& (
$ *
+
, +
#
,('
&
( #)
,-$
, *
# # ' $ %&' $
# ' $ $ % & *
INDEX 499
+ .
.
. ' . 3 !" ' # 4 $ % &
" 5 '( ) *
( . ( + + + '( ,
-" #( '( ,
. $ HML
6
.
( .
. # . 78
( ' /
. . * . '* $ 0( 0 Sort1
. #( "9
( 2 # . * . - HML
#( 500 INDEX
!
!
!
" # $
$
%& ' "
$
"
!$
! !
"
()) )' '' $
'' !
$
* # "
+ , ) , - .# !$
/ $
0 $
, 1 2 , 3 , 1 , 4 !$
# ' # # 536 # 7& 8 "
9 !$
7 & , $
Download