ronslow

Train Signal snippet

Jan 15th, 2014
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. module test
  2.  
  3. data LineSegment = StringLineSegment String
  4. data LineStatus = AllClear LineSegment | LimitedClearance LineSegment | Obstruction LineSegment
  5.  
  6. total
  7. isClear : LineStatus -> Bool
  8. isClear (AllClear _) = True
  9. isClear (LimitedClearance _) = False
  10. isClear (Obstruction _) = False
  11.  
  12. total
  13. isLimitedClearance : LineStatus -> Bool
  14. isLimitedClearance (AllClear _) = False
  15. isLimitedClearance (LimitedClearance _) = True
  16. isLimitedClearance (Obstruction _) = False
  17.  
  18. using (LineStatus ls)
  19. data LightStatus : Bool -> Bool -> Bool -> Type where
  20. GreenOn : (isClear ls = True) -> LightStatus False False True
  21. OrangeOn : (isLimitedClearance ls = True) -> LightStatus False True False
  22. RedOn : LightStatus True False False
  23.  
  24. --prove that the green light cannot come on with an obstruction
  25.  
  26.  
  27. -- prove that no light can come on with any other light
Advertisement
Add Comment
Please, Sign In to add comment