(base) 538$ swipl Welcome to SWI-Prolog (threaded, 64 bits, version 9.2.8) SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software. Please run ?- license. for legal details. For online help and background, visit https://www.swi-prolog.org For built-in help, use ?- help(Topic). or ?- apropos(Word). ?- [anbn2]. true. ?- a(Tree, [a,a,a,b,b,b], []). Tree = a(a, b(a(a, b(a(a, b(b)), b)), b)) ; false. ?- a(Tree, [a,a,b,b], []). Tree = a(a, b(a(a, b(b)), b)) ; false. ?- a(Tree, [a,a,b,b,b], []). false. ?- [lrrg]. true. ?- s(Sheep,[]). Sheep = [b, a, a, !] ; Sheep = [b, a, a, a, !] ; Sheep = [b, a, a, a, a, !] ; Sheep = [b, a, a, a, a, a, !] ; Sheep = [b, a, a, a, a, a, a, !] ; Sheep = [b, a, a, a, a, a, a, a, !] ; Sheep = [b, a, a, a, a, a, a, a, a|...] ; Sheep = [b, a, a, a, a, a, a, a, a|...] ; Sheep = [b, a, a, a, a, a, a, a, a|...] ; Sheep = [b, a, a, a, a, a, a, a, a|...] ; Sheep = [b, a, a, a, a, a, a, a, a|...] . ?- [lrrg2]. Warning: /Users/sandiway/Desktop/538/lrrg2.prolog:1: Warning: Redefined static procedure s/2 Warning: Previously defined at /Users/sandiway/Desktop/538/lrrg.prolog:1 Warning: /Users/sandiway/Desktop/538/lrrg2.prolog:2: Warning: Redefined static procedure a/2 Warning: Previously defined at /Users/sandiway/Desktop/538/lrrg.prolog:2 Warning: /Users/sandiway/Desktop/538/lrrg2.prolog:4: Warning: Redefined static procedure ba/2 Warning: Previously defined at /Users/sandiway/Desktop/538/lrrg.prolog:4 Warning: /Users/sandiway/Desktop/538/lrrg2.prolog:5: Warning: Redefined static procedure b/2 Warning: Previously defined at /Users/sandiway/Desktop/538/lrrg.prolog:5 true. ?- [lrrg2]. true. ?- s(Sheep,[]). ERROR: Stack limit (1.0Gb) exceeded ERROR: Stack sizes: local: 1.0Gb, global: 48.8Mb, trail: 0Kb ERROR: Stack depth: 6,390,835, last-call: 0%, Choice points: 6,390,826 ERROR: Probable infinite recursion (cycle): ERROR: [6,390,835] user:a(_12787434, _12787436) ERROR: [6,390,834] user:a(_12787454, _12787456) Exception: (6,386,195) a(_5396, _12778088) ? creep Exception: (6,386,194) a(_5396, _12778086) ? abort % Execution Aborted ?-