« Return to Thread: Forall in SWI Prolog

Re: Forall in SWI Prolog

by Richard O'Keefe :: Rate this Message:

Reply to Author | View in Thread


On Jul 5, 2009, at 4:48 AM, Fatih TURKMEN wrote:

>
> Dear All,
>
> I am running into a problem with forall predicate of SWI-Prolog. I  
> have the following predicate that tries to match all  
> subjectMatch(....) with rSub(...). This makes sure all different  
> combinations of subjectMatch(...) facts with different RID and  
> RValue values are matched. However, forall returns True when the  
> Condition section of forall predicate is not matched.

forall(Generator, Test) is true
   if and only if
     there is no provable instance of Generator
       for which Test does not have a provable instance

It is an approximation to ∀ x g(x) ⟶ t(x)

By its semantics, it *MUST* be true when Generator has
no provable instances.  This isn't in any sense a "default"
value; there is nothing optional or unmotivated about it,
the logical formula (forall x) G(x) -> T(x) just *is* true
when G(x) is always false.

> That means if there is no fact matching the condition of forall  
> (that is subjectMatch(P,R,N,RID,RValue)) forall returns True as a  
> default value.
>
> subjectS(P,R,N)  :-  forall(subjectMatch(P,R,N,RID,RValue),
>              rSub(RID,RValue)).

The layout here is confusing, to put it mildly.
>
>
> Is there a way to get around this? I mean if the condition of forall  
> is not matched at all, how can I get a false?

The very first thing is to be very clear about what you MEAN.

What would a predicate that otherwise behaved like forall/2
but failed when the Generator had no solutions *MEAN*?
What do you in fact want subjectS to *MEAN*?

It would be extremely easy to make a predicate that
*behaved* the way you apparently want; I am having real
trouble understanding what it is supposed to mean or
why it would be thought useful.

CouldYouPerhapsStartByTellingUsWhatThePredicates
subjectS/3, subjectMatch/5, and rSub/2 *mean*?

I'mStressingTheWord *Mean* becauseThatIsWhatPrologProgramming
isSupposedToBeAbout: meaning comes first, behaviour comes second.

AndIfYouDon'tLikeTextWrittenInThisStyle,
whyDoYouWriteYourPredicateNamesThatWay?


_______________________________________________
SWI-Prolog mailing list
SWI-Prolog@...
https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

 « Return to Thread: Forall in SWI Prolog