Don't Drive Drunk¶
Note
View the source code for this example here.
The don't drive drunk example encoding is a simple ASP encoding with variables. It models a scenario where there are two people, Gabriel and Clare. If any of the two people are drunk and also drives they get sentenced and have to go to prison.
Usage¶
Explanation:
asplain examples/dont_drive_drunk/encoding.lp 1 --log info --query "sentence(gabriel,innocent)"
Pruned graph¶
asplain examples/dont_drive_drunk/encoding.lp 1 --log info --query "sentence(gabriel,innocent)" --open --prune CHANGES
Using the interactive explanation interface:¶
clinguin client-server --domain-files examples/dont_drive_drunk/encoding.lp --ui-files src/asplain/encodings/ui.lp --custom-classes src/asplain/ui --backend ASPlainBackend --cost-encoding src/asplain/encodings/costs/program-difference.lp
Encodings¶
Base Encoding:
% @label("{} is a person",(P,)) :: person(P)
% @label("{} is driving",(P,)) :: drive(P)
% @label("{} is drinking alcohol",(P,)) :: alcohol(P)
% @label("{} is resisting the authorities",(P,)) :: resist(P)
% @label("{} is punished",(P,)) :: punish(P)
% @label("{} is sentenced to prison",(P,)) :: sentence(P, prison)
% @label("{} is innocent",(P,)) :: sentence(P, innocent)
% @label("{} is punished since they drove drunk",(P,))
punish(P) :- drive(P), alcohol(P), person(P).
% @label("{} is punished since they resisted the authorities ",(P,))
punish(P) :- resist(P), person(P).
% @label("{} is prison since they were not punished",(P,))
sentence(P, prison) :- punish(P).
% @label("{} is innocent since they were not punished",(P,))
sentence(P, innocent) :- person(P), not punish(P).
% ----- Instance
person(gabriel).
person(clare).
% @removable
drive(gabriel).
% @removable
alcohol(gabriel).
% @removable
drive(clare).
#program asplain.
% @label("{} is resisting the authorities",(P,))
% @addable
resist(P):-person(P).