James Bond¶
Note
View the source code for this example here.
The James Bond example encoding is a simple ASP encoding without any variables. It is a causal encoding that models a scenario where James Bond is on vacation and is offered a poisoned martini. If he is carful, he will notice the poison and avoid drinking it. Or since he is a seasoned spy, he might have taken a profilactic antidote that prevents him from being poisoned even if he drinks the martini.
Usage¶
Explanation¶
asplain examples/james-bond/encoding.lp --nexplanations 0 --query "p" 0
Explanation with fixed model:
asplain examples/james-bond/encoding.lp --nexplanations 0 --query "p" 0 --model examples/james-bond/model.lp
Using a cost function for selecting preferred explanations:¶
- Penalizing program changes
asplain examples/james-bond/encoding.lp --nexplanations 0 --query "p" 0 --model examples/james-bond/model.lp --cost-encoding src/asplain/encodings/costs/program-difference.lp
- Penalizing also model difference
asplain examples/james-bond/encoding.lp --nexplanations 0 --query "p" 0 --model examples/james-bond/model.lp --cost-encoding src/asplain/encodings/costs/program-difference.lp --cost-encoding src/asplain/encodings/costs/model-difference.lp
Getting a natural language explanation:¶
asplain examples/james-bond/encoding.lp --nexplanations 0 --query "p" 0 --model examples/james-bond/model.lp --cost-encoding src/asplain/encodings/costs/program-difference.lp --cost-encoding src/asplain/encodings/costs/model-difference.lp --llm GPT_4O
Using the interactive explanation interface:¶
clinguin client-server --domain-files examples/james-bond/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("Bond takes the antidote") :: a
% @label("Bond is poisoned") :: p
% @label("Bond is careful") :: c
% @label("Bond has contact with toxin") :: t
% @label("Bond might drink martini")
{d}.
% @label("Can't be poisoned he was careful")
:- p, c.
% @label("Bond is poisoned due to contact with toxin")
p :- t.
% @label("Bond is poisoned if drinks and didnt take the antidote")
p :- d, not a.
% @removable
a.
% @removable
c.
% Addable rules can optionally be added in a program called asplain
% This way, they will not be considered in the clingo or clinguin calls,
% but only when running asplain
#program asplain.
% @addable
t.
Model:
a.
c.