Skip to content

Commit

Permalink
cleaned up and added bunch of examples
Browse files Browse the repository at this point in the history
  • Loading branch information
wanko committed Oct 31, 2023
1 parent e1524c9 commit a42695e
Show file tree
Hide file tree
Showing 21 changed files with 123 additions and 251 deletions.
20 changes: 10 additions & 10 deletions examples/car.lp
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#const n = 8.
time(0..n). step(I,I+1) :- time(I), I < n.

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

&fsum {s(I)} =: s(I') :- not &fsum{ s(I') } != s(I), step(I,I').
&sus {s(I)} =: s(I') :- not &sus{ s(I') } != s(I), step(I,I').

&fsum {p(I)+s(I)} =: p(I') :- step(I,I').
&sus {p(I)+s(I)} =: p(I') :- step(I,I').

&fsum {400000} =: rdpos.
&fsum {90000} =: rdlimit. % <<< ADDED <<<
&sus {400000} =: rdpos.
&sus {90000} =: rdlimit. % <<< ADDED <<<

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

&fsum {0} =: p(0).
&fsum {80000} =: s(0).
&sus {0} =: p(0).
&sus {80000} =: s(0).

acc(11350,4).
slow(2301,6).
10 changes: 10 additions & 0 deletions examples/config_assignment.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
price(standardframe,15).

selected(standardframe).
{ selected(saddlebag) }.

&sus{price(P)} = V :- selected(P), price(P,V).
&sus{price(P) : selected(P)} =: price(total).

#show selected/1.
&show{price/1}.
11 changes: 11 additions & 0 deletions examples/config_default.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
price(standardframe,15).

selected(standardframe).
{ selected(saddlebag) }.

&sus{price(P)} = V :- selected(P), price(P,V).
&sus{price(P)} = 1 :- selected(P), not price(P,_).
&sus{price(P) : selected(P)} =: price(total).

#show selected/1.
&show{price/1}.
16 changes: 16 additions & 0 deletions examples/config_default_df.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
price(standardframe,15).

default_price(20).

selected(standardframe).
{ selected(saddlebag) }.

&sus{price(P)} = V :- selected(P), price(P,V).
&sus{price(P) : selected(P)} =: calculated_price(total).

&sus{price(total)} = calculated_price(total) :- &df{calculated_price(total)}.
&sus{price(total)} = D :- not &df{calculated_price(total)},
default_price(D).

#show selected/1.
&show{price/1}.
13 changes: 13 additions & 0 deletions examples/config_default_in.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
price(standardframe,15).
default_range(1,2).

selected(standardframe).
{ selected(saddlebag) }.

&sus{price(P)} = V :- selected(P), price(P,V).
&in{L..U} =: price(P) :- selected(P), not price(P,_),
default_range(L,U).
&sus{price(P) : selected(P)} =: price(total).

#show selected/1.
&show{price/1}.
10 changes: 10 additions & 0 deletions examples/config_optional.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
price(standardframe,15).
price(saddlebag,5).

selected(standardframe).
{ selected(saddlebag) }.

&sus{price(P)} = V :- selected(P), price(P,V).

#show selected/1.
&show{price/1}.
16 changes: 16 additions & 0 deletions examples/config_pricelimit_choice.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
part(sportsframe). price(sportsframe,15). type(sportsframe,frame).
part(standardframe). price(standardframe,14). type(standardframe,frame).
part(fancysaddle). price(fancysaddle,6). type(fancysaddle,saddle).
part(standardsaddle). price(standardsaddle,5). type(standardsaddle,saddle).

&sum{price(P)} = V :- price(P,V).

pricelimit(20).

&sum{price(P) :: selected(P) : part(P)} <= X :- pricelimit(X).
:- selected(P), selected(P'), P<P',
type(P,T), type(P',T).
:- type(_,T), { selected(P) : type(P,T) }0.

#show selected/1.
&show{}.
13 changes: 13 additions & 0 deletions examples/config_pricelimit_sum.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
price(standardframe,15).

pricelimit(14).

selected(standardframe).
{ selected(saddlebag) }.

&sus{price(P)} = V :- selected(P), price(P,V).
:- &sum { price(P) : selected(P) } >= L,
pricelimit(L).

#show selected/1.
&show{price/1}.
13 changes: 13 additions & 0 deletions examples/config_pricelimit_sus.lp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
price(standardframe,15).

pricelimit(14).

selected(standardframe).
{ selected(saddlebag) }.

&sus{price(P)} = V :- selected(P), price(P,V).
:- &sus { price(P) : selected(P) } >= L,
pricelimit(L).

#show selected/1.
&show{price/1}.
24 changes: 0 additions & 24 deletions examples/fsD.lp

This file was deleted.

25 changes: 0 additions & 25 deletions examples/fsE.lp

This file was deleted.

4 changes: 0 additions & 4 deletions examples/fsI.lp

This file was deleted.

26 changes: 0 additions & 26 deletions examples/fsO.lp

This file was deleted.

8 changes: 0 additions & 8 deletions examples/golomb.lp

This file was deleted.

12 changes: 0 additions & 12 deletions examples/money.lp

This file was deleted.

24 changes: 0 additions & 24 deletions examples/move.lp

This file was deleted.

9 changes: 0 additions & 9 deletions examples/queens.lp

This file was deleted.

2 changes: 0 additions & 2 deletions examples/simple.lp

This file was deleted.

18 changes: 9 additions & 9 deletions examples/taxes.lp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ deduction(mary, 10000, 10001).

1 { lives(P,R) : region(R) } 1 :- person(P).

&fsum{ 0 } =: deduction(P) :- person(P), not deduction(P,_,_).
&fin{ L..H } =: deduction(P) :- deduction(P,L,H).
&fsum{ T } =: rate(P) :- lives(P,R), income(P,I),
&sus{ 0 } =: deduction(P) :- person(P), not deduction(P,_,_).
&in{ L..H } =: deduction(P) :- deduction(P,L,H).
&sus{ T } =: rate(P) :- lives(P,R), income(P,I),
T = #max{ T' : rate(R,L,T'), I>=L}.

&fsum{ I*rate(P)-100*deduction(P) } =: 100*tax(P) :- income(P,I).
&fsum{ tax(P) : lives(P,R) } =: total(R) :- region(R).
&fmin{ tax(P) : person(P) } =: min.
&fmax{ tax(P) : person(P) } =: max.
min_taxes(P) :- &fmin{ tax(P') : person(P') } = tax(P), person(P).
max_taxes(P) :- &fmax{ tax(P') : person(P') } = tax(P), person(P).
&sus{ I*rate(P)-100*deduction(P) } =: 100*tax(P) :- income(P,I).
&sus{ tax(P) : lives(P,R) } =: total(R) :- region(R).
&min{ tax(P) : person(P) } =: min.
&max{ tax(P) : person(P) } =: max.
min_taxes(P) :- &min{ tax(P') : person(P') } = tax(P), person(P).
max_taxes(P) :- &max{ tax(P') : person(P') } = tax(P), person(P).

#show lives/2.
#show min_taxes/1.
Expand Down
Loading

0 comments on commit a42695e

Please sign in to comment.