Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #domain fraction(A,B).
- fraction(1,1).
- fraction(1,2).
- fraction(1,3).
- fraction(1,4).
- fraction(1,5).
- fraction(1,6).
- fraction(1,7).
- fraction(1,8).
- fraction(1,9).
- fraction(1,12).
- fraction(1,24).
- fraction(1,27).
- fraction(1,36).
- fraction(A,B) :- tag(P,source), target_value(P,A,B).
- divide(f(A,B),S,f(A/S,B)) :- A #mod S == 0.
- divide(f(A,B),S,f(A,B*S)) :- A #mod S != 0.
- value(P,A,B) :- tag(P,source), target_value(P,A,B).
- value(P2,Ap,Bp) :-
- tag(P2,divider),
- edge(P1,P2),
- value(P1,A,B),
- divider_outs(P2,S),
- divide(f(A,B),S,f(Ap,Bp)).
- value(P2,A,B) :-
- tag(P2,target),
- edge(P1,P2),
- value(P1,A,B).
- :- tag(P,target), target_value(P,A,B), not value(P,A,B).
- #show value/3.
Add Comment
Please, Sign In to add comment