% Prolog code to demonstrate default reasoning.
% Example 5.28 of Artificial Intelligence 3e, http://artint.info
% Copyright David L. Poole and Alan K. Mackworth, 2023
% This work is licensed under a Creative Commons
% Attribution-NonCommercial-ShareAlike 4.0 License. (CC BY-NC-SA 4.0)

:- dynamic on_beach/0, ab_beach_access/0, beach_access/0,
	   ab_swim_at_beach/0, enclosed_bay/0, big_city/0,
	   ab_no_swimming_near_city/0, in_BC/0, ab_BC_beaches/0.

away_from_beach :- \+ on_beach.
beach_access :- on_beach, \+ ab_beach_access.
swim_at_beach :- beach_access, \+ ab_swim_at_beach.
ab_swim_at_beach :- enclosed_bay, big_city, \+ ab_no_swimming_near_city.
ab_no_swimming_near_city :- in_BC, \+ ab_BC_beaches.

% some queries to try:
% ?- away_from_beach.
% ?- beach_access.
% ?- assert(on_beach).  % this dynamically states a fact is true
% ?- away_from_beach.
% ?- swim_at_beach.
% ?- assert(enclosed_bay).
% ?- swim_at_beach.
% ?- assert(big_city).
% ?- swim_at_beach.
% ?- assert(in_BC).
% ?- swim_at_beach.

% single fact about p
p(a).
% what does \+p(b) return? What does this say about the relationship between a and b?
