Empty tree in problem 3.2

Disclaimer: Dieser Thread wurde aus dem alten Forum importiert. Daher werden eventuell nicht alle Formatierungen richtig angezeigt. Der ursprüngliche Thread beginnt im zweiten Post dieses Threads.

Empty tree in problem 3.2
Unfortunately I don’t quite understand how the empty tree with no nodes should be represented in the definition of trees in problem 3.2, for reference:

subtrees([]).
istree(tree(Value,Children)) :− string(Value),subtrees(Children).
subtrees([(Cost,T)|Rest]) :− number(Cost),istree(T), subtrees(Rest).

Can anyone help?


You can make a tree with just the root node “A” and no children like this:

tree("A",[])

I hope this helps.

You can check out more examples in the notebook:
https://swish.swi-prolog.org/example/lists.pl
Since Swish is being particularly unreliable this year, I’ll also post the code from the notebook to
https://kwarc.info/teaching/AI/resources/