Prolog code won’t complete due to computational bug

I’ll preface this with the prompt I have to follow:

Bobby went to Truman Theaters. Taking a quick glance around, he can see that a different movie is playing on each screen (1 through 10) and that each film is a different genre (one is a spy thriller). From the information provided, can you determine the genre of the movie playing on each screen?

  1. The screen on which Brisbane is playing is numbered exactly 1 higher than the screen on which the historical epic is showing but exactly 1 lower than the screen on which Long Shot is playing.
  2. Jet Set is playing on a higher-numbered screen than Pigeon but a lower-numbered screen than the Western.
  3. The musical is playing on screen 4.
  4. The screen on which the comedy is playing is numbered exactly 1 higher than the screen on which The Gentleman is showing but exactly 1 lower than the screen on which Frostfire is playing.
  5. The Gentleman is not a science-fiction movie.
  6. The horror movie is playing on the screen numbered exactly 1 higher than the screen on which Newton’s Laws is showing.
  7. Vulture Gulch is playing on the screen numbered exactly 1 higher than the screen on which the documentary is showing.
  8. The documentary is playing on a higher-numbered screen than the comedy.
  9. The screen on which Ellipsis is playing is numbered exactly 1 higher than the screen on which the action flick is showing but exactly 1 lower than the screen on which the science-fiction movie is playing.
  10. The action film, the historical epic, and the romance movie are playing on screens 1, 2, and 3, in some order; one of these films is Tower of London.
  11. The difference between the numbers of the screen on which Newton’s Laws and Vulture Gulch are playing is the same as the difference between the numbers of screen on which the Gentleman and Tower of London are showing.
  • We use the variables Brisbane, Ellipsis, Frostfire, Jet_Set, Long_Shot, Pigeon, Newton_s_Laws,Gentleman, Tower_of_London, and Vulture_Gulch to represent the screen number on which the movie Brisbane, Ellipsis, Frostfire, Jet Set, Long Shot, Pigeon, Newton’s Laws, The Gentleman, Tower of London, and Vulture Gulch are playing, respectively.
  • We use the variables Action, Comedy, Documentary, Historical, Horror, Musical, Romance, Spy, SciFi,and Western to represent the screen on which action flick, comedy, documentary, historical epic, horror, musical, romance, spy thriller, science fiction, and western movie is playing, respectively.

Posting my prolog code first and then detailing the issue I have.

% Arrangement structure for 10 screens
arrangement([
    screen(1, _, _),
    screen(2, _, _),
    screen(3, _, _),
    screen(4, _, _),
    screen(5, _, _),
    screen(6, _, _),
    screen(7, _, _),
    screen(8, _, _),
    screen(9, _, _),
    screen(10, _, _)
]).

% Solution predicate with rules in specified order and singleton variable fixes
solution(S) :-
    arrangement(S),

    % Rule 1: Brisbane is 1 higher than the historical epic and 1 lower than Long Shot
    member(screen(Brisbane, 'Brisbane', _), S),
    member(screen(Historical, _, 'historical epic'), S),
    member(screen(Long_Shot, 'Long Shot', _), S),
    Brisbane =:= Historical + 1,
    Brisbane =:= Long_Shot - 1,

    % Rule 2: Jet Set is higher than Pigeon but lower than the Western
    member(screen(Jet_Set, 'Jet Set', _), S),
    member(screen(Pigeon, 'Pigeon', _), S),
    member(screen(Western, _, 'western'), S),
    Jet_Set > Pigeon,
    Jet_Set < Western,

    % Rule 3: Musical is on screen 4
    member(screen(Musical, _, 'musical'), S),
    Musical =:= 4,

    % Rule 4: Comedy is 1 higher than The Gentleman and 1 lower than Frostfire
    member(screen(Comedy, _, 'comedy'), S),
    member(screen(The_Gentleman, 'The Gentleman', _), S),
    member(screen(Frostfire, 'Frostfire', _), S),
    Comedy =:= The_Gentleman + 1,
    Comedy =:= Frostfire - 1,

    % Rule 5: The Gentleman is not a science fiction movie
    member(screen(SciFi, _, 'science fiction'), S),
    The_Gentleman == SciFi,

    % Rule 6: Horror movie is 1 higher than Newton's Laws
    member(screen(Newton_s_Laws, 'Newtons Laws', _), S),
    member(screen(Horror, _, 'horror'), S),
    Horror =:= Newton_s_Laws + 1,

    % Rule 7: Vulture Gulch is 1 higher than the documentary
    member(screen(Vulture_Gulch, 'Vulture Gulch', _), S),
    member(screen(Documentary, _, 'documentary'), S),
    Vulture_Gulch =:= Documentary + 1,

    % Rule 8: Documentary is on a higher-numbered screen than Comedy
    Documentary > Comedy,

    % Rule 9: Ellipsis is 1 higher than Action and 1 lower than SciFi
    member(screen(Ellipsis, 'Ellipsis', _), S),
    member(screen(Action, _, 'action flick'), S),
    Ellipsis =:= Action + 1,
    Ellipsis =:= SciFi - 1,

    % Rule 10: Action, Historical Epic, Romance on screens 1, 2, 3
    member(screen(Romance, _, 'romance'), S),
    member(screen(Tower_of_London, 'Tower of London', _), S),
    permutation([1, 2, 3], [Action, Historical, Romance]),
    Action = Historical,  % Each screen has a unique movie
    Historical = Romance,
    Romance = Action,
    Tower_of_London =< 3,  % One of these is Tower_of_London

    % Including Spy thriller genre
    member(screen(Spy, _, 'spy thriller'), S),
 
    % Rule 11: Absolute differences between Newton's Laws and Vulture Gulch, and The Gentleman and Tower of London
    Diff1 is abs(The_Gentleman - Tower_of_London),    
    Diff2 is abs(Newton_s_Laws - Vulture_Gulch),
    Diff1 =:= Diff2.

MY ISSUE: Whenever I run my program through prolog –> solution(Ans). My program has a hiccup at the 8th screen and never completes. I’ve tried tracing but I’m still unable to pinpoint where the problem lies. I figure it might have something to do with the spy thriller genre but I can’t figure why.

I have tried tracing the program and debugging but it runs through a lot of computations and must be done a certain way. The prompt states “To overcome this problem, we will put the membership predicates as late as possible and put them just before the first time we use a variable. This allows Prolog to eliminate a lot (13,168,189,440,000 permutations.) of incorrect answers and avoid generating those permutations that it knows will not lead to a solution. Prolog should be able to produce the answer almost instantly (less than 1 second) in
all cases.”

I can get up to the 8th screen but then it just stalls out and never finishes. I already know the 9th and 10th movie as well as their genres as the tracing shows. I believe it may have something to do with the spy thriller genre but I’m not sure why.

When I trace my program I get this result:

?- solution(Ans).
Ans = [screen(1, ‘Tower of London’, ‘historical epic’), screen(2, ‘Brisbane’, romance), screen(3, ‘Long Shot’, ‘action flick’), screen(4, ‘Ellipsis’, musical), screen(5, ‘Newtons Laws’, ‘science fiction’), screen(6, ‘The Gentleman’, horror), screen(7, ‘Pigeon’, comedy), screen(8, ‘Frostfire’, ‘spy thriller’), screen(…, …, …)|…] ; [trace]
Redo: (19) lists:member_([screen(9, ‘Jet Set’, documentary), screen(10, ‘Vulture Gulch’, western)], screen(_24118, _24120, ‘spy thriller’), screen(8, ‘Frostfire’, 23160)) ? creep
Fail: (19) lists:member
([screen(9, ‘Jet Set’, documentary), screen(10, ‘Vulture Gulch’, western)], screen(_24118, _24120, ‘spy thriller’), screen(8, ‘Frostfire’, _23160)) ?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật