lc2casp
A translator for logic programs with constraint atoms to CASP.

Overview

lc2casp is a translator for logic programs with constraint atoms to CASP.

Example

#include "lc.lp".

#const n = 8.
time(0..n).
step(I,I+1) :- time(I), I < n.

&assign { s(I') := s(I)+D } :- step(I,I'), acc(D,I').
&assign { s(I') := s(I)-D } :- step(I,I'), slow(D,I').

% Inertia for the speed
&assign { s(I') := s(I) } :- step(I,I'), not &sum{ s(I') } != s(I).

def_s(I) :- time(I), &sum{s(I); -s(I)}=0.

% The position keeps moving with the speed, if there is a speed
&assign { p(I') := p(I)+s(I) } :- step(I,I'), def_s(I).

&assign{ rdpos := 400000 }.
%&assign { rdlimit := 90000 }.
%&assign { rdpos := 300000..400000 }.

fine(I') :- step(I,I'), &sum{ p(I) } < rdpos, &sum{ p(I') } >= rdpos, &sum{ s(I') } > rdlimit.

% initial position 0 and initial speed 50 Km/h
&assign { p(0) := 0 }.
&assign { s(0) := 80000 }.
% We accelerate 11.35 Km/h 
acc(11350,4).
% We slow down 2.301 Km/h
slow(2301,6).

#show fine/1.

$ gringo vehicle.lp | lc2casp | clingcon 0
clingcon version 3.2.0
Reading from stdin
Solving...
Answer: 1
s(0)=80000 s(1)=80000 s(2)=80000  s(3)=80000  s(4)=91350  s(5)=91350  s(6)=89049  s(7)=89049  s(8)=89049 
p(0)=0     p(1)=80000 p(2)=160000 p(3)=240000 p(4)=320000 p(5)=411350 p(6)=502700 p(7)=591749 p(8)=680798 
rdpos=400000
SATISFIABLE

Models       : 1
Calls        : 1
Time         : 0.024s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
CPU Time     : 0.010s

Download

SourceForge.net Logo Valid XHTML 1.0 Strict