Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prolog looping due to interdependency

Status
Not open for further replies.

keowang

Technical User
Dec 30, 2012
1
0
0
US
Have to write some prolog rules to represent the geometrical properties about isosceles triangle.

First rule is to say
Code:
angleEqual(angle(A,B,C),angle(A,C,B)):- 
    triangle(A,B,C), 
    lineEqual(line(A,B),line(A,C)).

Second rule says
Code:
lineEqual(line(A,B),line(A,C)):- 
    triangle(A,B,C), 
    angleEqual(angle(A,B,C),angle(A,C,B)).

But the two rules together will cause a interdependency and prolog is looping forever if given facts such as
Code:
triangle(a,b,c).
lineEqual(line(a,b),line(a,c)).


and query about
Code:
?- angleEqual(A,B).


Any idea? Thanks very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top