Prolog keeps value when backtracking -


Hello I have a problem with a homework question. My problem worried about the Proole Backcracking feature, as explained by swipl

As I have understood the purpose of back tracking, when it is asked, the answer is to generate. If no possible solution is left out then it will return false. . In this way we want to lock or commit, a certain execution path we can use to deduct

My problem is: the right out of the program will provide three (ADA, FADA) , Calle)) then the program fails to ask for more solutions.

When different tests are done, the result of the input will be correct

What do I expect to achieve: ask for another solution But it will try the other X and will not be committed for the first time. If the code or database provides clarity then I would be happy to post it.

  [trace] 4? - Spider (X). Call: (6) Spider (_G4246)? Creep Calls: (7) Construction of individuals (_G4317)? Creep call: (8) bagf (_G4310, person (_G4310), _G 4321)? Creep% ^ Call: (14) person (_G4310)? Leave creep: (14) person (ADA)? Redo creep: (14) person (_G4310)? Leave creep: (14) person (beds)? Redo creep: (14) person (_G4310)? Exit creep: (14) person (calle)? Leave creep: (8) bagf (_G4310, user: person (_G4310), [eda, bed, coil])? Creep% ^ Exit: (7) Construction of individuals ([ada, bed, coil])? Creep Call: (7) List: Remove ([ADA, Bed, Caledonia], _G 4246, _G 4353)? Leave creep: (7) List: Remove ([ADA, Bed, Caledonia], _G 4246, [])? Creep Calls: (7) Conspirator (_G4246, [], [], [], _G 4355, _G 4356)? Leave creep: (7) Conspirator (_G4246, [], [], [], [], [])? Creep call: (7) [] == []? Leave creep: (7) [] == []? Leave creep: (6) Spider (_G4246)? Creep is true; Again: (7) Conspiracy (_G4246, [], [], [], _G 4355, _G 4356)? Creep unsuccessful: (7) Conspiracy (_G4246, [], [], [], _G 4355, _G 4356)? Creep Failed: (6) Spider (_G4246)? Crawling False  

Edit

 % DB person (ADA) person (Fida). Person (calle) (ADA, Fida). (ADA, Calle). (Beda, Calle).  

CODE

  generated persons (individuals): - Bagf (x, person (x), person). Spider (X): - When individuals are created (individuals), remove (person, x, person's view), conspirator (x, [], persons nospeeder, [], _, listeration),% == [] plotters (_, [], [], ConsList, ConsList, []). Conspiracy list (potential suspects, unsuccessful editor list, [prospective telecommunications | list 1], conspirator list in, conspirator listart, listwriting): - The conspirator list is already a conspirator friend known (potentially compelling, potential spinner), and not (friend_with_list (probable User, conspirator list in)), Friendfriend (potential congressman, plotters friend), subtracting (List1, ConspiratorsFriends, ListCut) Subtract (FailedConspiratorList, Co NspiratorsFriends, NewFailedConspiratorList), PossibleSpider, NewFailedConspiratorList, ListCut, [PossibleConspirator | ConspiratorListIn], ConspiratorListOut, ListReturn). Conspirator (potential speed, unsuccessful consultants, [NoteCopyCaptator, List 1], conspirator listart, listariton): - No increase in the list of consensuals (friend (potential spider, notepointCCPeter)), conspirator (potential spider, [nottepeciccitizer] ] Unsuccessful consultants), list 1, conspirator, conspiracy, listReturn). % Friend (X, Y) examines both methods: - (knows (x, y); knows (y, x))% how is it or is it going to work right? Friendlist (X, Friendlist): - Baffe (Y, Friend (X, Y), Friendlist). Friend_with_list (_, []): -% A friend is hard to find in a blank world. % Return is correct if input A is listed in any B C buddy_list_list (X, [or | _]): - Friend (X, Y). % X does not know the head of the list, let's try again! Friend_with_list (X, [_ | Tail]): - friend_with_list (x, tail)  

explanation

The spider is to find out. Spider is in touch with the conspirators, of which no other conspirator can be contacted. If the spider succeeds, then it will be true: the plotters and their friends, all are joint. That is, no person should be out of the net.


Comments