SlideShare a Scribd company logo
Traffic Light Controller
  Examples in SMV



     Himanshu Jain
 Bug catching (Fall 2007)
2

           Plan for today
Modeling Traffic Light Controller in SMV

Properties to Check

Four different SMV models for traffic
 light controller
3
Scenario   N




                       W




               S
4
             N
No turning




                       W




                 S
5
Binary    N
traffic
 lights


                      W




              S
6
   Safety         N
  Property



                              W

This should not
    happen

                      S
7
   Safety         N
  Property



                              W

This should not
    happen

                      S
8
Liveness        N
Property



                            W

When will the
 stupid light
  become
green again
                    S
9
Liveness     N
Property



                                W

                     Traffic in each
Thank God!
                     direction must
                       be served
                 S
10




Let’s see how to model
     all this in SMV
11
  SMV                 N
variables                     N-go=0
 Three Boolean
variables track the
  status of lights


                                       W


     S-go=0                   W-go=1


                          S
12
SMV variables          N
  Three Boolean                   S-sense =1
  variables sense
 the traffic in each
      direction


  W-sense =0                                    W

                               These variables are
                               called N, Sy, W in the
    N-sense =1                  code I will show you

                           S
13

  Properties we would like to check
Mutual exclusion
   SPEC AG !(W-Go & (N-Go | S-Go))


Liveness in North direction
  SPEC AG(N-sense & !N-Go -> AF N-Go)


Similar liveness properties for south and west
14

  Properties we would like to check
 No strict sequencing
   We don’t want the traffic lights to give turns to each other
    (if there is no need for it)
   For example, if there is no traffic on west lane, we do not
    want W-go becoming 1 periodically

 We can specify such properties atleast partially
   AG(W-Go -> A[W-Go U (!W-Go & A[!W-Go U (N-Go | S-Go)])])
   See code other such properties
   We want these properties to FAIL
15
  SMV              N
 modules                   West module
                           will control
North module
 will control



                                          W

                           Main module will
   South module            -Initialize variables
    will control           -Start north, south,
                       S     west modules
What if north light           16
is always green       N
and there is always
traffic in north
direction




                                   W




                          S
17

         Fairness Constraints
 What if north light is always green and there is
  always traffic in north direction

 We will avoid such scenarios by means of fairness
  constraints

 FAIRNESS running & !(N-Go & N-sense)

 On an infinite execution, there are infinite number of
  states where either north light is not green or there is
  no traffic in north direction

 Similar, fairness constraints for south and west
  directions
18




Now we look at some concrete
     implementations
19

         Some more variables
 To ensure mutual exclusion
   We will have two Boolean variables
   NS-Lock: denotes locking of north/south lane
   EW-Lock: denotes locking of west lane


 To remember that there is traffic on a lane
   Boolean variables: N-Req, S-Req, W-Req
   If N-sense becomes 1, then N-Req is set to true
   Similarly, for others….
20
MODULE main
                          Traffic1.smv
VAR
    N : boolean;   --senses traffic going along north
    Sy : boolean;   --senses traffic going along south
    W : boolean;    --senses traffic going westward
    N-Req : boolean; --rememebers that there is traffic along north that needs to go
    S-Req : boolean; --rememebers that there is traffic along south that needs to go
    W-Req : boolean; --rememebers that there is traffic along west that needs to go
    N-Go : boolean; --north direction green light on
    S-Go : boolean; --south direction green light on
    W-Go : boolean; --west direction green light on
    NS-Lock : boolean; --north/south lane locked
    EW-Lock : boolean; --east/west lane locked

    north : process north1(NS-Lock, EW-Lock, N-Req, N-Go,N,S-Go);
    south : process south1(NS-Lock,EW-Lock,S-Req,S-Go,Sy,N-Go);
    west : process west1(NS-Lock,EW-Lock,W-Req,W-Go,W);

ASSIGN
    init(NS-Lock) := 0; init(Sy) := 0;
    init(W) := 0;
    init(W-Req) := 0; …………………..OTHER INITIALIZATIONS
MODULE north(NS-Lock, EW-Lock, N-Req, N-Go,N,S-Go)                       21
VAR
    state : {idle, entering , critical , exiting};
                                                        next(N-Req) :=
ASSIGN
                                                                  case
    init(state) := idle;
                                                                       !N-Req & N : 1;
    next(state) :=
                                                                       state = exiting : 0;
          case
                                                                       1 : N-Req;
                state = idle : case
                                                                  esac;
                            N-Req = 1 : entering;
                            1 : state;
                                                             next(N-Go) :=
                           esac;
                                                                  case
                state = entering & !EW-Lock : critical;
                                                                       state = critical : 1;
                state = critical & !N : exiting;
                                                                       state = exiting : 0;
                state = exiting : idle;
                                                                       1 : N-Go;
                1 : state;
                                                                  esac;
          esac;
                                                        -- non-deterministically chose N
     next(NS-Lock) :=
                                                             next(N) := {0,1};
          case
               state = entering & !EW-Lock : 1 ;
                                                        FAIRNESS
               state = exiting & !S-Go : 0;
                                                            running & !(N-Go & N)
               1 : NS-Lock;
          esac;
22

Module south is similar


Module west1 is a little different


Everything seems ok!

Let us run a model checker
23

 Mutual exclusion fails (Counterexample)
1. All variables zero
2. N-sense=1 (North module executed)
3. S-sense=1 (South module executed)
4. S-Req=1
5. south.state=entering
6. S-sense=0, NS-Lock=1, south.state=critical      One module is
7. S-sense=1,S-go=1,south.state=exiting              executing
8. N-Req=1
9. north.state=entering
                                                    at each step
10. north.state=critical
11. S-Req=0, S-Go=0, NS-Lock=0, south.state=idle
12. W=1
13. W-Req=1
14. west.state=entering
15. EW-lock=1, west.state=critical
16. W-Go=1
17. N-Go=1
24

 Mutual exclusion fails (Counterexample)
1. All variables zero
2. N-sense=1 (North module executed)
3. S-sense=1 (South module executed)
4. S-Req=1
5. south.state=entering
6. S-sense=0, NS-Lock=1, south.state=critical       One module is
7. S-sense=1,S-go=1,south.state=exiting                executing
8. N-Req=1
9. north.state=entering
                                                      at each step
10. north.state=critical
11. S-Req=0, S-Go=0, NS-Lock=0, south.state=idle
12. W=1
13. W-Req=1                               Even though
14. west.state=entering                   north.state is critical
15. EW-lock=1, west.state=critical        the NS-lock is
16. W-Go=1
17. N-Go=1                                released
25

 Mutual exclusion fails (Counterexample)
1. All variables zero
2. N-sense=1 (North module executed)
3. S-sense=1 (South module executed)
4. S-Req=1
5. south.state=entering
6. S-sense=0, NS-Lock=1, south.state=critical       One module is
7. S-sense=1,S-go=1,south.state=exiting                executing
8. N-Req=1
9. north.state=entering
                                                      at each step
10. north.state=critical
11. S-Req=0, S-Go=0, NS-Lock=0, south.state=idle
12. W=1
13. W-Req=1
14. west.state=entering                 One problem is the
15. EW-lock=1, west.state=critical
16. W-Go=1                              one-step difference
17. N-Go=1                              Between North.state=critical
                                    and N-Go=1
MODULE north(NS-Lock, EW-Lock, N-Req, N-Go,N,S-Go)                    26
VAR
    state : {idle, entering , critical , exiting};
                                                     next(N-Req) :=
ASSIGN
                                                               case
    init(state) := idle;
                                                                    !N-Req & N : 1;
    next(state) :=
                                                                    state = exiting : 0;
          case
                                                                    1 : N-Req;
                state = idle : case
                                                               esac;
                            N-Req = 1 : entering;
                            1 : state;
                                                          next(N-Go) :=
                           esac;
                                                               case
                state = entering & !EW-Lock : critical;
                                                                    state = critical : 1;
                state = critical & !N : exiting;
                                                                    state = exiting : 0;
                state = exiting : idle;
                                                                    1 : N-Go;
                1 : state;
                                                               esac;
          esac;
                                                      -- non-deterministically chose N
     next(NS-Lock) :=
                                                           next(N) := {0,1};
          case
               state = entering & !EW-Lock : 1 ;
                                                      FAIRNESS
               state = exiting & !S-Go : 0;
                                                          running & !(N-Go & N)
               1 : NS-Lock;
          esac;
27

This problem is fixed in traffic2.smv
 next(state) :=
           case
              state = idle : case
                          N-Req = 1 : entering;
                          1 : state;
                         esac;
              state = entering & !EW-Lock : critical;
              state = critical & !N : exiting;
              state = exiting : idle;
              1 : state;
          esac;

 next(N-Go) :=
         case
              state = entering & !EW-Lock : 1;          --change here
              state = exiting : 0;
              1 : N-Go;
          esac;
28

 Model checking traffic2.smv
Mutual exclusion property is satisfied

Liveness property for North direction fails
   AG ((N & !N-Go) -> AF N-Go) is false
29
     Counterexample for liveness
      property contains a loop


    North.state=entering
        S-sense=1,
        W-sense=1                             S-Go=1




   EW-lock=1                            NS-lock=1
west.state = critical               south.state = critical

                           W-Go=1
30
     Counterexample for liveness
      property contains a loop
                            North module given a chance to
                           execute here. But it is of no use 
    North.state=entering
        S-sense=1,
        W-sense=1                                   S-Go=1




   EW-lock=1                                  NS-lock=1
west.state = critical                     south.state = critical

                           W-Go=1
31


Ensuring liveness requires more work
This is in traffic3.smv

Introduce a Boolean variable called turn
   Give turn to others (if I have just exited the
    critical section)
   turn = {nst, ewt}
32
MODULE north1(NS-Lock, EW-Lock, N-Req, N-Go,N,S-Go,S-Req,E-Req,turn)
VAR
    state : {idle, entering , critical , exiting};

ASSIGN
    init(state) := idle;
    next(state) :=
          case
                state = idle & N-Req = 1 : entering;
                state = entering & !EW-Lock & (!E-Req | turn=nst): critical;
                state = critical & !N : exiting;
                state = exiting : idle;
                1 : state;
          esac;

next(turn) :=
           case
              state=exiting & turn=nst & !S-Req : ewt;
              1 : turn;
          esac;




                       Similar code in south and west modules
33

        Model check again
Mutual exclusion holds

What about liveness properties
  In north direction?
  In south direction?
  In west direction?
34

       Model check again
Mutual exclusion holds

What about liveness properties
  In north direction? HOLDS
  In south direction? HOLDS
  In west direction? FAILS 
35

            Traffic4.smv 
 Two more variables to distinguish between
  north and south completion
   ndone and sdone


 When north module exits critical section
  ndone is set to 1
   Similarly for south module and sdone

 When west module exits both sdone and
  ndone are set to 0
36
MODULE north1(NS-Lock, EW-Lock, N-Req, N-Go,N,S-Go,S-Req,E-
Req,turn,ndone,sdone)
VAR
     state : {idle, entering , critical , exiting};
ASSIGN
next(state) :=
           case
                 state = idle & N-Req = 1 : entering;
                 state = entering & !EW-Lock & (!E-Req | turn=nst): critical;
                 state = critical & !N : exiting;
                 state = exiting : idle;
                 1 : state;
           esac;
 next(turn) :=
           case
                 state=exiting & turn=nst & (!S-Req | (sdone & E-Req)): ewt;
                 1 : turn;
           esac;
next(ndone) :=
           case
                 state=exiting : 1;
                 1 : ndone;
           esac;
37

                Hurray!
Mutual exclusion holds

Liveness for all three directions holds

Strict sequencing does not hold
  That is what we want
38

                    Think about
 How to allow north, south, east, west traffic

 How to model turns

 Instead of writing code for four modules have a
  generic module
    Instantitate it with four times. Once for each direction

 Ensure properties without changing fairness
  constraints
    We will make the SMV code and slides available
39




QUESTIONS

More Related Content

What's hot

Flip-Flop (Clocked Bistable)
Flip-Flop (Clocked Bistable)Flip-Flop (Clocked Bistable)
Flip-Flop (Clocked Bistable)
Aravir Rose
 
Digital e chap 4
Digital e   chap 4Digital e   chap 4
Digital e chap 4
Mohammad Bappy
 
latches
 latches latches
latches
Unsa Shakir
 
Latches and flip flop
Latches and flip flopLatches and flip flop
Latches and flip flop
Shuaib Hotak
 
Sequential logics
Sequential logicsSequential logics
Sequential logics
faiqikhan
 
All flipflop
All flipflopAll flipflop
All flipflop
DHEERAJ CHOKSE
 
D Flip Flop
D Flip Flop D Flip Flop
D Flip Flop
Pradhan Rishi Sharma
 
D flip Flop
D flip FlopD flip Flop
D flip Flop
Talha Mudassar
 
Flip Flops DLD
Flip Flops DLDFlip Flops DLD
Flip Flops DLD
Assad Shehbaz
 
Latches and flip flops
Latches and flip flopsLatches and flip flops
Latches and flip flops
mubashir farooq
 
MASTER SLAVE JK FLIP FLOP & T FLIP FLOP
MASTER SLAVE JK FLIP FLOP & T FLIP FLOPMASTER SLAVE JK FLIP FLOP & T FLIP FLOP
MASTER SLAVE JK FLIP FLOP & T FLIP FLOP
Smit Shah
 
Trts d flip flop1
Trts d flip flop1Trts d flip flop1
Trts d flip flop1
abdullah254el
 
J - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPSJ - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPS
Krishma Parekh
 
Ee2 chapter12 flip_flop
Ee2 chapter12 flip_flopEe2 chapter12 flip_flop
Ee2 chapter12 flip_flop
CK Yang
 
Flip flops
Flip flopsFlip flops
State table and characteristic equation for sequential circuit
State table and characteristic equation for sequential circuitState table and characteristic equation for sequential circuit
State table and characteristic equation for sequential circuit
Preet_patel
 
What are Flip Flops and Its types.
What are Flip Flops and Its types.What are Flip Flops and Its types.
What are Flip Flops and Its types.
Satya P. Joshi
 
Lect20 Engin112
Lect20 Engin112Lect20 Engin112
Lect20 Engin112
John Williams
 
Chapter 4 flip flop for students
Chapter 4 flip flop for studentsChapter 4 flip flop for students
Chapter 4 flip flop for students
CT Sabariah Salihin
 
1.2 table
1.2 table1.2 table

What's hot (20)

Flip-Flop (Clocked Bistable)
Flip-Flop (Clocked Bistable)Flip-Flop (Clocked Bistable)
Flip-Flop (Clocked Bistable)
 
Digital e chap 4
Digital e   chap 4Digital e   chap 4
Digital e chap 4
 
latches
 latches latches
latches
 
Latches and flip flop
Latches and flip flopLatches and flip flop
Latches and flip flop
 
Sequential logics
Sequential logicsSequential logics
Sequential logics
 
All flipflop
All flipflopAll flipflop
All flipflop
 
D Flip Flop
D Flip Flop D Flip Flop
D Flip Flop
 
D flip Flop
D flip FlopD flip Flop
D flip Flop
 
Flip Flops DLD
Flip Flops DLDFlip Flops DLD
Flip Flops DLD
 
Latches and flip flops
Latches and flip flopsLatches and flip flops
Latches and flip flops
 
MASTER SLAVE JK FLIP FLOP & T FLIP FLOP
MASTER SLAVE JK FLIP FLOP & T FLIP FLOPMASTER SLAVE JK FLIP FLOP & T FLIP FLOP
MASTER SLAVE JK FLIP FLOP & T FLIP FLOP
 
Trts d flip flop1
Trts d flip flop1Trts d flip flop1
Trts d flip flop1
 
J - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPSJ - K & MASTERSLAVE FLIPFLOPS
J - K & MASTERSLAVE FLIPFLOPS
 
Ee2 chapter12 flip_flop
Ee2 chapter12 flip_flopEe2 chapter12 flip_flop
Ee2 chapter12 flip_flop
 
Flip flops
Flip flopsFlip flops
Flip flops
 
State table and characteristic equation for sequential circuit
State table and characteristic equation for sequential circuitState table and characteristic equation for sequential circuit
State table and characteristic equation for sequential circuit
 
What are Flip Flops and Its types.
What are Flip Flops and Its types.What are Flip Flops and Its types.
What are Flip Flops and Its types.
 
Lect20 Engin112
Lect20 Engin112Lect20 Engin112
Lect20 Engin112
 
Chapter 4 flip flop for students
Chapter 4 flip flop for studentsChapter 4 flip flop for students
Chapter 4 flip flop for students
 
1.2 table
1.2 table1.2 table
1.2 table
 

Viewers also liked

Electrical Consultants & Engineers, Amravati , Solar & Energy Saving LED Lights
Electrical Consultants & Engineers, Amravati , Solar & Energy Saving LED LightsElectrical Consultants & Engineers, Amravati , Solar & Energy Saving LED Lights
Electrical Consultants & Engineers, Amravati , Solar & Energy Saving LED Lights
IndiaMART InterMESH Limited
 
its project
its projectits project
its project
p71089
 
Traffic Light Controller System using Optical Flow Estimation
Traffic Light Controller System using Optical Flow EstimationTraffic Light Controller System using Optical Flow Estimation
Traffic Light Controller System using Optical Flow Estimation
Editor IJCATR
 
Design of Smart Traffic Light Controller Using Embedded System
Design of Smart Traffic Light Controller Using Embedded SystemDesign of Smart Traffic Light Controller Using Embedded System
Design of Smart Traffic Light Controller Using Embedded System
IOSR Journals
 
Intelligent Traffic Controller
Intelligent Traffic ControllerIntelligent Traffic Controller
Intelligent Traffic Controller
Ranjan Dhar
 
Doc a.7-tlc report
Doc a.7-tlc reportDoc a.7-tlc report
Doc a.7-tlc report
9951081577
 
Traffic light Controller Design
Traffic light Controller DesignTraffic light Controller Design
Traffic light Controller Design
Ivan Tim Oloya
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
Eng Ahmed Salad Osman
 
Chapter 2 traffic studies
Chapter 2 traffic studiesChapter 2 traffic studies
Chapter 2 traffic studies
Ankit Patel
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
chandreshghodasara
 
Ppt (1)
Ppt (1)Ppt (1)
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
nimmi_abes
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
Srikanth Kaleru
 
Bangalore Traffic Police B-Trac
Bangalore Traffic Police B-TracBangalore Traffic Police B-Trac
Bangalore Traffic Police B-Trac
bangaloretrpolice
 
PART -1 TRAFFIC LIGHT CONTROL USING 8085
PART -1 TRAFFIC LIGHT CONTROL USING 8085PART -1 TRAFFIC LIGHT CONTROL USING 8085
PART -1 TRAFFIC LIGHT CONTROL USING 8085
Subash Sambath Kumar
 
Intelligent Transportation System
Intelligent Transportation SystemIntelligent Transportation System
Intelligent Transportation System
D.Y.Patil College Of Engineering, Akurdi.
 
Smart street light detector
Smart street light detectorSmart street light detector
Smart street light detector
siddharth bhatt
 
Speed Detection Of Moving Vehicles (Using Traffic Enforcement Camera)
Speed Detection Of Moving Vehicles (Using Traffic Enforcement Camera) Speed Detection Of Moving Vehicles (Using Traffic Enforcement Camera)
Speed Detection Of Moving Vehicles (Using Traffic Enforcement Camera)
Emmanuel Oshogwe Akpeokhai
 
EkoLum : Smart Street Lighting Software
EkoLum : Smart Street Lighting SoftwareEkoLum : Smart Street Lighting Software
EkoLum : Smart Street Lighting Software
Josep Pocalles
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
Shubham Sharma
 

Viewers also liked (20)

Electrical Consultants & Engineers, Amravati , Solar & Energy Saving LED Lights
Electrical Consultants & Engineers, Amravati , Solar & Energy Saving LED LightsElectrical Consultants & Engineers, Amravati , Solar & Energy Saving LED Lights
Electrical Consultants & Engineers, Amravati , Solar & Energy Saving LED Lights
 
its project
its projectits project
its project
 
Traffic Light Controller System using Optical Flow Estimation
Traffic Light Controller System using Optical Flow EstimationTraffic Light Controller System using Optical Flow Estimation
Traffic Light Controller System using Optical Flow Estimation
 
Design of Smart Traffic Light Controller Using Embedded System
Design of Smart Traffic Light Controller Using Embedded SystemDesign of Smart Traffic Light Controller Using Embedded System
Design of Smart Traffic Light Controller Using Embedded System
 
Intelligent Traffic Controller
Intelligent Traffic ControllerIntelligent Traffic Controller
Intelligent Traffic Controller
 
Doc a.7-tlc report
Doc a.7-tlc reportDoc a.7-tlc report
Doc a.7-tlc report
 
Traffic light Controller Design
Traffic light Controller DesignTraffic light Controller Design
Traffic light Controller Design
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
 
Chapter 2 traffic studies
Chapter 2 traffic studiesChapter 2 traffic studies
Chapter 2 traffic studies
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
 
Ppt (1)
Ppt (1)Ppt (1)
Ppt (1)
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
 
Bangalore Traffic Police B-Trac
Bangalore Traffic Police B-TracBangalore Traffic Police B-Trac
Bangalore Traffic Police B-Trac
 
PART -1 TRAFFIC LIGHT CONTROL USING 8085
PART -1 TRAFFIC LIGHT CONTROL USING 8085PART -1 TRAFFIC LIGHT CONTROL USING 8085
PART -1 TRAFFIC LIGHT CONTROL USING 8085
 
Intelligent Transportation System
Intelligent Transportation SystemIntelligent Transportation System
Intelligent Transportation System
 
Smart street light detector
Smart street light detectorSmart street light detector
Smart street light detector
 
Speed Detection Of Moving Vehicles (Using Traffic Enforcement Camera)
Speed Detection Of Moving Vehicles (Using Traffic Enforcement Camera) Speed Detection Of Moving Vehicles (Using Traffic Enforcement Camera)
Speed Detection Of Moving Vehicles (Using Traffic Enforcement Camera)
 
EkoLum : Smart Street Lighting Software
EkoLum : Smart Street Lighting SoftwareEkoLum : Smart Street Lighting Software
EkoLum : Smart Street Lighting Software
 
Traffic light controller
Traffic light controllerTraffic light controller
Traffic light controller
 

More from Kuldeep Chand

Marginalised groups of rural population beszedes
Marginalised groups of rural population beszedesMarginalised groups of rural population beszedes
Marginalised groups of rural population beszedes
Kuldeep Chand
 
Rural marketing-ppt-2
Rural marketing-ppt-2Rural marketing-ppt-2
Rural marketing-ppt-2
Kuldeep Chand
 
Social network for ed
Social network for edSocial network for ed
Social network for ed
Kuldeep Chand
 
Sharma social networks (1)
Sharma social networks (1)Sharma social networks (1)
Sharma social networks (1)
Kuldeep Chand
 
Social network (1)
Social network (1)Social network (1)
Social network (1)
Kuldeep Chand
 
Social network
Social networkSocial network
Social network
Kuldeep Chand
 
Diwali
DiwaliDiwali

More from Kuldeep Chand (7)

Marginalised groups of rural population beszedes
Marginalised groups of rural population beszedesMarginalised groups of rural population beszedes
Marginalised groups of rural population beszedes
 
Rural marketing-ppt-2
Rural marketing-ppt-2Rural marketing-ppt-2
Rural marketing-ppt-2
 
Social network for ed
Social network for edSocial network for ed
Social network for ed
 
Sharma social networks (1)
Sharma social networks (1)Sharma social networks (1)
Sharma social networks (1)
 
Social network (1)
Social network (1)Social network (1)
Social network (1)
 
Social network
Social networkSocial network
Social network
 
Diwali
DiwaliDiwali
Diwali
 

Recently uploaded

BeMetals Investor Presentation_June 1, 2024.pdf
BeMetals Investor Presentation_June 1, 2024.pdfBeMetals Investor Presentation_June 1, 2024.pdf
BeMetals Investor Presentation_June 1, 2024.pdf
DerekIwanaka1
 
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challengesEvent Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Holger Mueller
 
Digital Transformation Frameworks: Driving Digital Excellence
Digital Transformation Frameworks: Driving Digital ExcellenceDigital Transformation Frameworks: Driving Digital Excellence
Digital Transformation Frameworks: Driving Digital Excellence
Operational Excellence Consulting
 
Business storytelling: key ingredients to a story
Business storytelling: key ingredients to a storyBusiness storytelling: key ingredients to a story
Business storytelling: key ingredients to a story
Alexandra Fulford
 
Building Your Employer Brand with Social Media
Building Your Employer Brand with Social MediaBuilding Your Employer Brand with Social Media
Building Your Employer Brand with Social Media
LuanWise
 
Understanding User Needs and Satisfying Them
Understanding User Needs and Satisfying ThemUnderstanding User Needs and Satisfying Them
Understanding User Needs and Satisfying Them
Aggregage
 
Income Tax exemption for Start up : Section 80 IAC
Income Tax  exemption for Start up : Section 80 IACIncome Tax  exemption for Start up : Section 80 IAC
Income Tax exemption for Start up : Section 80 IAC
CA Dr. Prithvi Ranjan Parhi
 
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
Lacey Max
 
Top mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptxTop mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptx
JeremyPeirce1
 
Mastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnapMastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnap
Norma Mushkat Gaffin
 
Industrial Tech SW: Category Renewal and Creation
Industrial Tech SW:  Category Renewal and CreationIndustrial Tech SW:  Category Renewal and Creation
Industrial Tech SW: Category Renewal and Creation
Christian Dahlen
 
Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024
Kirill Klimov
 
The Heart of Leadership_ How Emotional Intelligence Drives Business Success B...
The Heart of Leadership_ How Emotional Intelligence Drives Business Success B...The Heart of Leadership_ How Emotional Intelligence Drives Business Success B...
The Heart of Leadership_ How Emotional Intelligence Drives Business Success B...
Stephen Cashman
 
3 Simple Steps To Buy Verified Payoneer Account In 2024
3 Simple Steps To Buy Verified Payoneer Account In 20243 Simple Steps To Buy Verified Payoneer Account In 2024
3 Simple Steps To Buy Verified Payoneer Account In 2024
SEOSMMEARTH
 
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Kalyan Satta Matka Guessing Matka Result Main Bazar chart
 
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
AnnySerafinaLove
 
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdfThe 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
thesiliconleaders
 
How to Implement a Real Estate CRM Software
How to Implement a Real Estate CRM SoftwareHow to Implement a Real Estate CRM Software
How to Implement a Real Estate CRM Software
SalesTown
 
Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024
FelixPerez547899
 
Lundin Gold Corporate Presentation - June 2024
Lundin Gold Corporate Presentation - June 2024Lundin Gold Corporate Presentation - June 2024
Lundin Gold Corporate Presentation - June 2024
Adnet Communications
 

Recently uploaded (20)

BeMetals Investor Presentation_June 1, 2024.pdf
BeMetals Investor Presentation_June 1, 2024.pdfBeMetals Investor Presentation_June 1, 2024.pdf
BeMetals Investor Presentation_June 1, 2024.pdf
 
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challengesEvent Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
 
Digital Transformation Frameworks: Driving Digital Excellence
Digital Transformation Frameworks: Driving Digital ExcellenceDigital Transformation Frameworks: Driving Digital Excellence
Digital Transformation Frameworks: Driving Digital Excellence
 
Business storytelling: key ingredients to a story
Business storytelling: key ingredients to a storyBusiness storytelling: key ingredients to a story
Business storytelling: key ingredients to a story
 
Building Your Employer Brand with Social Media
Building Your Employer Brand with Social MediaBuilding Your Employer Brand with Social Media
Building Your Employer Brand with Social Media
 
Understanding User Needs and Satisfying Them
Understanding User Needs and Satisfying ThemUnderstanding User Needs and Satisfying Them
Understanding User Needs and Satisfying Them
 
Income Tax exemption for Start up : Section 80 IAC
Income Tax  exemption for Start up : Section 80 IACIncome Tax  exemption for Start up : Section 80 IAC
Income Tax exemption for Start up : Section 80 IAC
 
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
 
Top mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptxTop mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptx
 
Mastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnapMastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnap
 
Industrial Tech SW: Category Renewal and Creation
Industrial Tech SW:  Category Renewal and CreationIndustrial Tech SW:  Category Renewal and Creation
Industrial Tech SW: Category Renewal and Creation
 
Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024
 
The Heart of Leadership_ How Emotional Intelligence Drives Business Success B...
The Heart of Leadership_ How Emotional Intelligence Drives Business Success B...The Heart of Leadership_ How Emotional Intelligence Drives Business Success B...
The Heart of Leadership_ How Emotional Intelligence Drives Business Success B...
 
3 Simple Steps To Buy Verified Payoneer Account In 2024
3 Simple Steps To Buy Verified Payoneer Account In 20243 Simple Steps To Buy Verified Payoneer Account In 2024
3 Simple Steps To Buy Verified Payoneer Account In 2024
 
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
❼❷⓿❺❻❷❽❷❼❽ Dpboss Matka Result Satta Matka Guessing Satta Fix jodi Kalyan Fin...
 
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
Anny Serafina Love - Letter of Recommendation by Kellen Harkins, MS.
 
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdfThe 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
 
How to Implement a Real Estate CRM Software
How to Implement a Real Estate CRM SoftwareHow to Implement a Real Estate CRM Software
How to Implement a Real Estate CRM Software
 
Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024
 
Lundin Gold Corporate Presentation - June 2024
Lundin Gold Corporate Presentation - June 2024Lundin Gold Corporate Presentation - June 2024
Lundin Gold Corporate Presentation - June 2024
 

Traffic

  • 1. Traffic Light Controller Examples in SMV Himanshu Jain Bug catching (Fall 2007)
  • 2. 2 Plan for today Modeling Traffic Light Controller in SMV Properties to Check Four different SMV models for traffic light controller
  • 3. 3 Scenario N W S
  • 4. 4 N No turning   W S
  • 5. 5 Binary N traffic lights W S
  • 6. 6 Safety N Property W This should not happen S
  • 7. 7 Safety N Property W This should not happen S
  • 8. 8 Liveness N Property W When will the stupid light become green again S
  • 9. 9 Liveness N Property W Traffic in each Thank God! direction must be served S
  • 10. 10 Let’s see how to model all this in SMV
  • 11. 11 SMV N variables N-go=0 Three Boolean variables track the status of lights W S-go=0 W-go=1 S
  • 12. 12 SMV variables N Three Boolean S-sense =1 variables sense the traffic in each direction W-sense =0 W These variables are called N, Sy, W in the N-sense =1 code I will show you S
  • 13. 13 Properties we would like to check Mutual exclusion  SPEC AG !(W-Go & (N-Go | S-Go)) Liveness in North direction SPEC AG(N-sense & !N-Go -> AF N-Go) Similar liveness properties for south and west
  • 14. 14 Properties we would like to check  No strict sequencing  We don’t want the traffic lights to give turns to each other (if there is no need for it)  For example, if there is no traffic on west lane, we do not want W-go becoming 1 periodically  We can specify such properties atleast partially  AG(W-Go -> A[W-Go U (!W-Go & A[!W-Go U (N-Go | S-Go)])])  See code other such properties  We want these properties to FAIL
  • 15. 15 SMV N modules West module will control North module will control W Main module will South module -Initialize variables will control -Start north, south, S west modules
  • 16. What if north light 16 is always green N and there is always traffic in north direction W S
  • 17. 17 Fairness Constraints  What if north light is always green and there is always traffic in north direction  We will avoid such scenarios by means of fairness constraints  FAIRNESS running & !(N-Go & N-sense)  On an infinite execution, there are infinite number of states where either north light is not green or there is no traffic in north direction  Similar, fairness constraints for south and west directions
  • 18. 18 Now we look at some concrete implementations
  • 19. 19 Some more variables  To ensure mutual exclusion  We will have two Boolean variables  NS-Lock: denotes locking of north/south lane  EW-Lock: denotes locking of west lane  To remember that there is traffic on a lane  Boolean variables: N-Req, S-Req, W-Req  If N-sense becomes 1, then N-Req is set to true  Similarly, for others….
  • 20. 20 MODULE main Traffic1.smv VAR N : boolean; --senses traffic going along north Sy : boolean; --senses traffic going along south W : boolean; --senses traffic going westward N-Req : boolean; --rememebers that there is traffic along north that needs to go S-Req : boolean; --rememebers that there is traffic along south that needs to go W-Req : boolean; --rememebers that there is traffic along west that needs to go N-Go : boolean; --north direction green light on S-Go : boolean; --south direction green light on W-Go : boolean; --west direction green light on NS-Lock : boolean; --north/south lane locked EW-Lock : boolean; --east/west lane locked north : process north1(NS-Lock, EW-Lock, N-Req, N-Go,N,S-Go); south : process south1(NS-Lock,EW-Lock,S-Req,S-Go,Sy,N-Go); west : process west1(NS-Lock,EW-Lock,W-Req,W-Go,W); ASSIGN init(NS-Lock) := 0; init(Sy) := 0; init(W) := 0; init(W-Req) := 0; …………………..OTHER INITIALIZATIONS
  • 21. MODULE north(NS-Lock, EW-Lock, N-Req, N-Go,N,S-Go) 21 VAR state : {idle, entering , critical , exiting}; next(N-Req) := ASSIGN case init(state) := idle; !N-Req & N : 1; next(state) := state = exiting : 0; case 1 : N-Req; state = idle : case esac; N-Req = 1 : entering; 1 : state; next(N-Go) := esac; case state = entering & !EW-Lock : critical; state = critical : 1; state = critical & !N : exiting; state = exiting : 0; state = exiting : idle; 1 : N-Go; 1 : state; esac; esac; -- non-deterministically chose N next(NS-Lock) := next(N) := {0,1}; case state = entering & !EW-Lock : 1 ; FAIRNESS state = exiting & !S-Go : 0; running & !(N-Go & N) 1 : NS-Lock; esac;
  • 22. 22 Module south is similar Module west1 is a little different Everything seems ok! Let us run a model checker
  • 23. 23 Mutual exclusion fails (Counterexample) 1. All variables zero 2. N-sense=1 (North module executed) 3. S-sense=1 (South module executed) 4. S-Req=1 5. south.state=entering 6. S-sense=0, NS-Lock=1, south.state=critical One module is 7. S-sense=1,S-go=1,south.state=exiting executing 8. N-Req=1 9. north.state=entering at each step 10. north.state=critical 11. S-Req=0, S-Go=0, NS-Lock=0, south.state=idle 12. W=1 13. W-Req=1 14. west.state=entering 15. EW-lock=1, west.state=critical 16. W-Go=1 17. N-Go=1
  • 24. 24 Mutual exclusion fails (Counterexample) 1. All variables zero 2. N-sense=1 (North module executed) 3. S-sense=1 (South module executed) 4. S-Req=1 5. south.state=entering 6. S-sense=0, NS-Lock=1, south.state=critical One module is 7. S-sense=1,S-go=1,south.state=exiting executing 8. N-Req=1 9. north.state=entering at each step 10. north.state=critical 11. S-Req=0, S-Go=0, NS-Lock=0, south.state=idle 12. W=1 13. W-Req=1 Even though 14. west.state=entering north.state is critical 15. EW-lock=1, west.state=critical the NS-lock is 16. W-Go=1 17. N-Go=1 released
  • 25. 25 Mutual exclusion fails (Counterexample) 1. All variables zero 2. N-sense=1 (North module executed) 3. S-sense=1 (South module executed) 4. S-Req=1 5. south.state=entering 6. S-sense=0, NS-Lock=1, south.state=critical One module is 7. S-sense=1,S-go=1,south.state=exiting executing 8. N-Req=1 9. north.state=entering at each step 10. north.state=critical 11. S-Req=0, S-Go=0, NS-Lock=0, south.state=idle 12. W=1 13. W-Req=1 14. west.state=entering One problem is the 15. EW-lock=1, west.state=critical 16. W-Go=1 one-step difference 17. N-Go=1 Between North.state=critical and N-Go=1
  • 26. MODULE north(NS-Lock, EW-Lock, N-Req, N-Go,N,S-Go) 26 VAR state : {idle, entering , critical , exiting}; next(N-Req) := ASSIGN case init(state) := idle; !N-Req & N : 1; next(state) := state = exiting : 0; case 1 : N-Req; state = idle : case esac; N-Req = 1 : entering; 1 : state; next(N-Go) := esac; case state = entering & !EW-Lock : critical; state = critical : 1; state = critical & !N : exiting; state = exiting : 0; state = exiting : idle; 1 : N-Go; 1 : state; esac; esac; -- non-deterministically chose N next(NS-Lock) := next(N) := {0,1}; case state = entering & !EW-Lock : 1 ; FAIRNESS state = exiting & !S-Go : 0; running & !(N-Go & N) 1 : NS-Lock; esac;
  • 27. 27 This problem is fixed in traffic2.smv next(state) := case state = idle : case N-Req = 1 : entering; 1 : state; esac; state = entering & !EW-Lock : critical; state = critical & !N : exiting; state = exiting : idle; 1 : state; esac; next(N-Go) := case state = entering & !EW-Lock : 1; --change here state = exiting : 0; 1 : N-Go; esac;
  • 28. 28 Model checking traffic2.smv Mutual exclusion property is satisfied Liveness property for North direction fails  AG ((N & !N-Go) -> AF N-Go) is false
  • 29. 29 Counterexample for liveness property contains a loop North.state=entering S-sense=1, W-sense=1 S-Go=1 EW-lock=1 NS-lock=1 west.state = critical south.state = critical W-Go=1
  • 30. 30 Counterexample for liveness property contains a loop North module given a chance to execute here. But it is of no use  North.state=entering S-sense=1, W-sense=1 S-Go=1 EW-lock=1 NS-lock=1 west.state = critical south.state = critical W-Go=1
  • 31. 31 Ensuring liveness requires more work This is in traffic3.smv Introduce a Boolean variable called turn Give turn to others (if I have just exited the critical section) turn = {nst, ewt}
  • 32. 32 MODULE north1(NS-Lock, EW-Lock, N-Req, N-Go,N,S-Go,S-Req,E-Req,turn) VAR state : {idle, entering , critical , exiting}; ASSIGN init(state) := idle; next(state) := case state = idle & N-Req = 1 : entering; state = entering & !EW-Lock & (!E-Req | turn=nst): critical; state = critical & !N : exiting; state = exiting : idle; 1 : state; esac; next(turn) := case state=exiting & turn=nst & !S-Req : ewt; 1 : turn; esac; Similar code in south and west modules
  • 33. 33 Model check again Mutual exclusion holds What about liveness properties In north direction? In south direction? In west direction?
  • 34. 34 Model check again Mutual exclusion holds What about liveness properties In north direction? HOLDS In south direction? HOLDS In west direction? FAILS 
  • 35. 35 Traffic4.smv   Two more variables to distinguish between north and south completion  ndone and sdone  When north module exits critical section ndone is set to 1  Similarly for south module and sdone  When west module exits both sdone and ndone are set to 0
  • 36. 36 MODULE north1(NS-Lock, EW-Lock, N-Req, N-Go,N,S-Go,S-Req,E- Req,turn,ndone,sdone) VAR state : {idle, entering , critical , exiting}; ASSIGN next(state) := case state = idle & N-Req = 1 : entering; state = entering & !EW-Lock & (!E-Req | turn=nst): critical; state = critical & !N : exiting; state = exiting : idle; 1 : state; esac; next(turn) := case state=exiting & turn=nst & (!S-Req | (sdone & E-Req)): ewt; 1 : turn; esac; next(ndone) := case state=exiting : 1; 1 : ndone; esac;
  • 37. 37 Hurray! Mutual exclusion holds Liveness for all three directions holds Strict sequencing does not hold That is what we want
  • 38. 38 Think about  How to allow north, south, east, west traffic  How to model turns  Instead of writing code for four modules have a generic module  Instantitate it with four times. Once for each direction  Ensure properties without changing fairness constraints We will make the SMV code and slides available