triska / the-power-of-prolog

Introduction to modern Prolog
https://www.metalevel.at/prolog
1.21k stars 75 forks source link

Integer Arithmetic - "left as an exercise" that is too difficult #41

Open prologbyexample opened 1 year ago

prologbyexample commented 1 year ago

The section on integer arithmetic and constraint programming at https://www.metalevel.at/prolog/clpz explains that the list_length/2 predicate does not terminate when asked to find a list that has a specified length.

?- list_length(Ls, 3), false.
nontermination

"It takes only a single additional goal to make this query terminate. This is left as an exercise."

I have struggled to find what this single additional goal is. I have tried days of reading popular texts on prolog, googling and even asking on stackexchange.

I would love an answer or a link to an answer.