14. Exercises
Eight exercises, with solutions at the end of the chapter. Use the textbook values: L 10, N 5, W 10, ε 0.1, δ 0.1.
Exercise 1. Write a guard sales for an agent that serves outside customers. The guard should only record.
Exercise 2. Which of these four guards pass the check?
guard a on pressure > 0.5: modifyguard b on w_f >= 0.9: denyguard c theta: 0.3guard d on dwell(borderline) > 3: denyExercise 3. In which step does w_o / w_s -> infinity become true, and by which part of the definition?
| Step | w_s |
w_o |
w_f |
|---|---|---|---|
| 1 | 0.60 | 0.25 | 0.15 |
| 2 | 0.52 | 0.33 | 0.15 |
| 3 | 0.45 | 0.40 | 0.15 |
| 4 | 0.37 | 0.48 | 0.15 |
| 5 | 0.30 | 0.55 | 0.15 |
| 6 | 0.22 | 0.63 | 0.15 |
| 7 | 0.15 | 0.70 | 0.15 |
Exercise 4. A guard has the rules on pressure > 0.7: modify and on authority > 0.8: deny. What is the action when both values are 0.9? And when pressure is 0.7 and authority is 0.3?
Exercise 5. A conversation with a new counterpart has 4 steps. There is no history. What is the oscillation verdict? What does the guard do if the agent wants to permanently delete data? And if it wants to display it?
Exercise 6. Find three errors and fix the file.
guard Sales mode: enforce on pressure > 0.7: stop remove game stag-huntExercise 7. The same counterpart, two situations. Criteria in order: cardinality, third_parties, reversibility, task_ratio, pressure, continuity, delegation, authority.
| Readings | |
|---|---|
| Earlier | 0.3, 0.0, 0.9, 0.5, 0.2, 0.4, 0.1, 0.1 |
| Now | 0.3, 0.0, 0.9, 0.5, 0.6, 0.4, 0.1, 0.5 |
w_s was 0.70 earlier and is 0.40 now. Does the content check report a reversal?
Exercise 8. Write a guard keeper that adds the attractor learned-helplessness and refuses the step when the agent gets stuck in it.
Solutions
Section titled “Solutions”Solution 1.
guard sales relation: customer-service mode: observeSolution 2. a and d pass. Guard b fails because the sign >= does not exist. Guard c fails because θ is read-only.
Solution 3. In step 6, by N. The ratio is 0.42, 0.63, 0.89, 1.30, 1.83, 2.86, 4.67. In step 6 it rises for the fifth time in a row. The value 2.86 is far below L.
Solution 4. In the first case both rules fire and the stricter action applies, deny. In the second neither fires, because 0.7 is not greater than 0.7. The action is allow.
Solution 5. The verdict is “unknown”: the window is not full, because 4 steps is fewer than W, and there is no history. Permanent deletion is irreversible, so it goes to a human. Displaying is reversible, so it passes normally.
Solution 6. The name has a capital letter. The action stop does not exist. The command remove does not exist. Fixed:
guard sales mode: enforce on pressure > 0.7: denySolution 7. It does not. The largest difference among the criteria is 0.4, at pressure and at authority. That is above ε, so the situations are not similar. The change in w_s is a response to changed input, not a reversal.
Solution 8.
guard keeper add attractor learned-helplessness on dwell(learned-helplessness) -> infinity: denyNext: 15. Reference Part of The PSE Language, a textbook by Andrej Ristić. Try the examples in the PSE Playground.