Advertisement
Guest User

Untitled

a guest
Nov 9th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/I 1.27 KB | None | 0 0
  1. % file: security.pl
  2. % Title: CPSC 322 Assignment 3 Question 4
  3. % Authors: Chris Liu (35551118) & Adriano Sela Aviles (31063150)
  4.  
  5. % a (door) sensor is triggered if:
  6. % a door is open, the door has a sensor, and power is on (live).
  7. triggered(S) <- door_open(DOOR) & hasSensor(DOOR, S) & live(S).
  8.  
  9. % a (laser) sensor is triggered if:
  10. % a laser is interrupted, the laser has a sensor, and the power is on (live).
  11. triggered(S) <- laser_interrupted(LASER) & hasSensor(LASER, S) & live(S).
  12.  
  13. % a (window) sensor is triggered if:
  14. % a window is broken is broken, the window has a sensor, and the power is on (live).
  15. triggered(S) <- window_broken(WINDOW) & hasSensor(WINDOW, S) & live(S).
  16.  
  17. % an alarm is triggered if:
  18. % a sensor is triggered and the alarm is a system
  19. alarm_triggered(ALARM) <- triggered(S) & system(ALARM).
  20.  
  21. % the power is on ( live(S) is true ) if:
  22. % S is live and connected (there is a current)
  23. live(S) <- connected_to(S,S1) & live(S1).
  24.  
  25. % connected_to(x, y) is true if x is connected to y s.t. current flows from y to x.
  26. connected_to(ds1,power).
  27. connected_to(ls1,ds1) <- circuit_ok(c1).
  28. connected_to(ws1,ls1) <- circuit_ok(c2).
  29.  
  30. % initial sensor/alarms setup - do not modify
  31. hasSensor(door1,ds1).
  32. hasSensor(laser1,ls1).
  33. hasSensor(window1, ws1).
  34. system(alarm1).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement