I want to write a function (apologies for probably not using the correct term here) wubble which is true for specific constants and true for those constants if wrapped into another constant, but only one layer deep! Examples:
% are supposed to be TRUE:
?- wubble(foo).
?- wubble(bar).
?- wubble(wrapper(foo)).
?- wubble(wrapper(bar)).
% are suppoed to be FALSE:
?- wubble(not_in_knowledge_base).
?- wubble(wrapper(wrapper(foo))).
The naive (at least in my brain) implementation looks like this:
wubble(foo).
wubble(bar).
wubble(wrapper(wrapper(_))) :- !, fail.
wubble(wrapper(X)) :- wubble(X).
And this works with the queries above. However, I can't enumerate all valid X for wubble with this implementation:
?- wubble(X).
X = foo
X = bar
So this is missing X = wrapper(foo) and X = wrapper(bar). Is it possible to fix my implementation somehow?