Skip to content

Commit

Permalink
Added explainable DELX examples
Browse files Browse the repository at this point in the history
- Corrected original DELX examples.
- Version 0.9.1.
  • Loading branch information
ovidiomanteiga committed Jun 9, 2024
1 parent 043f04f commit df46ea2
Show file tree
Hide file tree
Showing 21 changed files with 404 additions and 50 deletions.
2 changes: 1 addition & 1 deletion deolingo/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

__version__ = "0.9.0"
__version__ = "0.9.1"
4 changes: 3 additions & 1 deletion deolingo/examples/delx/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
The examples in this folder are taken from the paper "Deontic Equilibrium Logic with eXplicit negation", see https://www.dc.fi.udc.es/~cabalar/DELX.pdf

The examples in this folder are taken from the paper "Deontic Equilibrium Logic with eXplicit negation".
See https://www.dc.fi.udc.es/~cabalar/DELX.pdf
17 changes: 12 additions & 5 deletions deolingo/examples/delx/example1.1.lp
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
% C1 (Explicit versus Negative permission)

% C1 (Explicit versus Negative permission) (1st example: Π ∪ (15))

% (i) There must be no fence (f).
&obligatory{-f}.
&forbidden{f}.

% (ii) If there is a fence, it must be a white (w) fence.
&obligatory{w} :- f.
&obligatory{w} :- f, &forbidden{f}.

% (iii) If the cottage is by the sea (s), there must be a fence.
&obligatory{f} :- s.

% A white fence is a fence.
f :- w.

% If it is obligatory a white fence, then it is obligatory a fence.
&obligatory{f} :- &obligatory{w}.

% (iv) If it is permitted (explicit), I build a fence around my cottage
f :- &permitted{f}.
% (iv) If it is permitted (implicit), I build a fence around my cottage
%f :- not &forbidden{f}.
17 changes: 12 additions & 5 deletions deolingo/examples/delx/example1.2.lp
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
% C1 (Explicit versus Negative permission)

% C1 (Explicit versus Negative permission) (2nd example: Π ∪ (16))

% (i) There must be no fence (f).
&obligatory{-f}.
&forbidden{f}.

% (ii) If there is a fence, it must be a white (w) fence.
&obligatory{w} :- f.
&obligatory{w} :- f, &forbidden{f}.

% (iii) If the cottage is by the sea (s), there must be a fence.
&obligatory{f} :- s.

% A white fence is a fence.
f :- w.

% If it is obligatory a white fence, then it is obligatory a fence.
&obligatory{f} :- &obligatory{w}.
% (iv) If it is permitted (explicit), I build a fence around my cottage
%f :- &permitted{f}.

% (iv) If it is permitted (implicit), I build a fence around my cottage
f :- not &forbidden{f}.
13 changes: 11 additions & 2 deletions deolingo/examples/delx/example2.lp
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@

% C2 (Contrary-to-Duty (CTD) and Compliance)

% (i) There must be no fence (f).
&obligatory{-f}.
&forbidden{f}.

% (ii) If there is a fence, it must be a white (w) fence.
&obligatory{w} :- f.
&obligatory{w} :- f, &forbidden{f}.

% (iii) If the cottage is by the sea (s), there must be a fence.
&obligatory{f} :- s.

% A white fence is a fence.
f :- w.

% If it is obligatory a white fence, then it is obligatory a fence.
&obligatory{f} :- &obligatory{w}.

% (v) If you put a fence when forbidden, you should pay a fine.
&obligatory{pay} :- &forbidden{f}, f.
16 changes: 13 additions & 3 deletions deolingo/examples/delx/example3.lp
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@

% C3 (CTD and Dilemmas)

% (i) There must be no fence (f).
&obligatory{-f}.
&forbidden{f}.

% (ii) If there is a fence, it must be a white (w) fence.
&obligatory{w} :- f.
&obligatory{w} :- f, &forbidden{f}.

% (iii) If the cottage is by the sea (s), there must be a fence.
&obligatory{f} :- s.

% A white fence is a fence.
f :- w.

% If it is obligatory a white fence, then it is obligatory a fence.
&obligatory{f} :- &obligatory{w}.

% (v) If you put a fence when forbidden, you should pay a fine.
&obligatory{pay} :- &forbidden{f}, f.

% There is a fence.
f.
f.
16 changes: 13 additions & 3 deletions deolingo/examples/delx/example4.lp
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
% C4 (CTD and Defeasible Obligations)

% C4 (CTD and Defeasible Obligations) ((18) ∪ (3) ∪ {s,f})

% (i) There must be no fence, unless a permission is granted
&forbidden{f} :- not &permitted{f}.

% (ii) If there is a fence, it must be a white (w) fence.
&obligatory{w} :- f, &forbidden{f}.

% (vi) If the cottage is by the sea (s), there may be a fence.
&permitted{f} :- s.

% A white fence is a fence.
f :- w.

% If it is obligatory a white fence, then it is obligatory a fence.
&obligatory{f} :- &obligatory{w}.

% The cottage is by the sea.
%s.
s.

% There is a fence.
%f.
f.
22 changes: 17 additions & 5 deletions deolingo/examples/delx/example5.1.lp
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
% C5 (Constitutive Norms)

% C5 (Constitutive Norms) (1st example: Π ∪ (19) ∪ {f})

% (i) There must be no fence (f).
&obligatory{-f}.
&forbidden{f}.

% (ii) If there is a fence, it must be a white (w) fence.
&obligatory{w} :- f.
&obligatory{w} :- f, &forbidden{f}.

% (iii) If the cottage is by the sea (s), there must be a fence.
&obligatory{f} :- s.

% A white fence is a fence.
f :- w.

% If it is obligatory a white fence, then it is obligatory a fence.
&obligatory{f} :- &obligatory{w}.

% No white fence if not fence.
-w :- -f.
% Not forbidden a white fence if not forbidden a fence.

% Forbidden a white fence if forbidden a fence.
&forbidden{w} :- &forbidden{f}.

% There is a fence.
f.

% The fence is white.
%w.
w.
23 changes: 17 additions & 6 deletions deolingo/examples/delx/example5.2.lp
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
% C5 (Constitutive Norms) (2nd example)

% C5 (Constitutive Norms) (2nd example: (2) ∪ (20) ∪ {f})

% (i) There must be no fence (f).
&obligatory{-f}.
&forbidden{f}.

% (ii) If there is a fence, it must be a white (w) fence.
&obligatory{w} :- f.
&obligatory{w} :- f, &forbidden{f}.

% (iii) If the cottage is by the sea (s), there must be a fence.
&obligatory{f} :- s.

% If white fence, then fence.
f :- w.

% No white fence if not fence.
-w :- -f.
% Obligatory fence if non violated white fence.

% Obligatory fence if non violated obligation of white fence.
&obligatory{f} :- &obligatory{w}, not -w.
% Forbidden white if non violated fence.

% Forbidden white fence if non violated prohibition of fence.
&forbidden{w} :- &forbidden{f}, not f.

% There is a fence.
f.
f.
19 changes: 15 additions & 4 deletions deolingo/examples/delx/example6.1.lp
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
% C6 (Defeasible Deontic Detachment) (1st example)

% C6 (Defeasible Deontic Detachment) (1st example: Π ∪ (21) ∪ {f ∨ ¬f})

% (i) There must be no fence (f).
&obligatory{-f}.
&forbidden{f}.

% (ii) If there is a fence, it must be a white (w) fence.
&obligatory{w} :- f.
&obligatory{w} :- f, &forbidden{f}.

% (iii) If the cottage is by the sea (s), there must be a fence.
&obligatory{f} :- s.

% A white fence is a fence.
f :- w.

% If it is obligatory a white fence, then it is obligatory a fence.
&obligatory{f} :- &obligatory{w}.

% (vii) If we put a fence, we must put a street mailbox (m).
&obligatory{m} :- f.

% (viii) If we do not put a fence, we must not put a street mailbox.
&forbidden{m} :- -f.

% Fence or not fence.
f;-f.
f; -f.
19 changes: 15 additions & 4 deletions deolingo/examples/delx/example6.2.alt.lp
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
% C6 (Defeasible Deontic Detachment) (2nd example)

% C6 (Defeasible Deontic Detachment) (2nd example with conditional notation: Π ∪ (22) ∪ {f ∨¬f})

% (i) There must be no fence (f).
&obligatory{-f}.
&forbidden{f}.

% (ii) If there is a fence, it must be a white (w) fence.
&obligatory{w} :- f.
&obligatory{w} :- f, &forbidden{f}.

% (iii) If the cottage is by the sea (s), there must be a fence.
&obligatory{f} :- s.

% A white fence is a fence.
f :- w.

% If it is obligatory a white fence, then it is obligatory a fence.
&obligatory{f} :- &obligatory{w}.

% (vii) If we put a fence, we must put a street mailbox (m).
&obligatory{m | f}.

% (viii) If we do not put a fence, we must not put a street mailbox.
&obligatory{-m | -f}.

% Fence or not fence.
f;-f.
f; -f.
19 changes: 15 additions & 4 deletions deolingo/examples/delx/example6.2.lp
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
% C6 (Defeasible Deontic Detachment) (2nd example)

% C6 (Defeasible Deontic Detachment) (2nd example: Π ∪ (22) ∪ {f ∨¬f})

% (i) There must be no fence (f).
&obligatory{-f}.
&forbidden{f}.

% (ii) If there is a fence, it must be a white (w) fence.
&obligatory{w} :- f.
&obligatory{w} :- f, &forbidden{f}.

% (iii) If the cottage is by the sea (s), there must be a fence.
&obligatory{f} :- s.

% A white fence is a fence.
f :- w.

% If it is obligatory a white fence, then it is obligatory a fence.
&obligatory{f} :- &obligatory{w}.

% (vii) If we put a fence, we must put a street mailbox (m).
&obligatory{m} :- f.
&obligatory{m} :- &obligatory{f}, not -f.

% (viii) If we do not put a fence, we must not put a street mailbox.
&forbidden{m} :- -f.
&forbidden{m} :- &forbidden{f}, not f.

% Fence or not fence.
f;-f.
f; -f.
27 changes: 27 additions & 0 deletions deolingo/examples/delxx/example1.1.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

% C1 (Explicit versus Negative permission) (1st example: Π ∪ (15))

%!trace_rule {"There must be no fence"}
&forbidden{fence}.

%!trace_rule {"It must be a white fence, if the prohibition of a fence is violated"}
&obligatory{white_fence} :- &violated_prohibition{fence}.

%!trace_rule {"There must be a fence, if the cottage is by the sea"}
&obligatory{fence} :- sea.

%!trace_rule {"A white fence is a fence"}
fence :- white_fence.

%!trace_rule {"It is obligatory a fence, if it is obligatory a white fence"}
&obligatory{fence} :- &obligatory{white_fence}.

%!trace_rule {"I build a fence around my cottage, if it is explicitly permitted"}
fence :- &permitted{fence}.

%!show_trace &obligatory{X}.
%!show_trace &forbidden{X}.

%!trace {"There is a fence"} fence.
%!trace {"The cottage is by the sea"} sea.
%!trace {"There is a white fence"} white.
27 changes: 27 additions & 0 deletions deolingo/examples/delxx/example1.2.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

% C1 (Explicit versus Negative permission) (2nd example: Π ∪ (16))

%!trace_rule {"There must be no fence"}
&forbidden{fence}.

%!trace_rule {"It must be a white fence, if the prohibition of a fence is violated"}
&obligatory{white_fence} :- &violated_prohibition{fence}.

%!trace_rule {"There must be a fence, if the cottage is by the sea"}
&obligatory{fence} :- sea.

%!trace_rule {"A white fence is a fence"}
fence :- white_fence.

%!trace_rule {"It is obligatory a fence, if it is obligatory a white fence"}
&obligatory{fence} :- &obligatory{white_fence}.

%!trace_rule {"I build a fence around my cottage, if it is implicitly permitted"}
fence :- &permitted_implicitly{fence}.

%!show_trace &obligatory{X}.
%!show_trace &forbidden{X}.

%!trace {"There is a fence"} fence.
%!trace {"The cottage is by the sea"} sea.
%!trace {"There is a white fence"} white.
28 changes: 28 additions & 0 deletions deolingo/examples/delxx/example2.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

% C2 (Contrary-to-Duty (CTD) and Compliance)

%!trace_rule {"There must be no fence"}
&forbidden{fence}.

%!trace_rule {"It must be a white fence, if the prohibition of a fence is violated"}
&obligatory{white_fence} :- &violated_prohibition{fence}.

%!trace_rule {"There must be a fence, if the cottage is by the sea"}
&obligatory{fence} :- sea.

%!trace_rule {"A white fence is a fence"}
fence :- white_fence.

%!trace_rule {"It is obligatory a fence, if it is obligatory a white fence"}
&obligatory{fence} :- &obligatory{white_fence}.

%!trace_rule {"You should pay a fine, if you put a fence when forbidden"}
&obligatory{pay} :- &violated_prohibition{fence}.

%!show_trace &forbidden{X}.
%!show_trace &obligatory{X}.

%!trace {"There is a fence"} fence.
%!trace {"The cottage is by the sea"} sea.
%!trace {"There is a white fence"} white.
%!trace {"You should pay a fine"} &obligatory{pay}.
Loading

0 comments on commit df46ea2

Please sign in to comment.