Toggle navigation
?
users online
Logout
Open hangout
Open chat for current file
/* Same facts as the non-recursive version. */ executive(alice). director(bob). human_resources(danny). read_compensation(danny). manager(alice, bob). manager(bob, charlie). manager(charlie, danny). manager(charlie, ellen). /* Helper fucntions need to change to accommodate recursive logic. */ is_in_manager_chain(Manager, Managee) :- manager(Manager, Managee). is_in_manager_chain(Manager, Managee) :- manager(Manager, Intermediate), is_in_manager_chain(Intermediate, Managee). is_in_manager_chain_or_hr(Manager, Managee) :- is_in_manager_chain(Manager, Managee). is_in_manager_chain_or_hr(Hr, _) :- human_resources(Hr), read_compensation(Hr). /* Same remaining rules as the non-recursive version. */ violates_executive_privilege(Violator, Violatee) :- executive(Violatee), not(executive(Violator)). violates_director_privilege(Violator, Violatee) :- director(Violatee), not(director(Violator)). authorized(Principal, Action, Entity) :- Action == read_compensation, Principal == Entity. authorized(Principal, Action, Entity) :- Action == read_compensation, is_in_manager_chain_or_hr(Principal, Entity), not(violates_executive_privilege(Principal, Entity)), not(violates_director_privilege(Principal, Entity)).