Reading Prolog Code
HTML-код
- Опубликовано: 7 фев 2025
- Prolog code can be read in different ways: declaratively, selectively, procedurally and informally. Selective reading is also called program slicing and is useful for generating explanations. Failure slicing is a special case of program slicing and lets us show reasons for nontermination of Prolog programs. More information: www.metalevel....
This was very helpful! Thank you :)
At 17:00 the query list_length(Ls, 3) terminates. Why is this?
It seems to be related to the addition of the constraint L #> 0 but I can't see why as L=3 is provided as input and L is always >0 so shouldn't effect termination.
list_length is evaluated recursively. So, for each iteration, the new L in the body is the L0 of the outer evaluation, that is L-1
Program slicing is debugging infinite loops with early returns