In "fact F4_All_wanted_books_are_had_by_someone", I am trying to make all wanted books are on loan to some patron. Which is if a patron wants a book, it must be on load (otherwise it could be loaned to the patron that wants it). In "fact F7_Cannot_want_what_you_have", is a patron cannot want a book he or she already has. But when I tried to execute the code. it shows that there is no instance found, however, it supposed have instance found.
Before I add "fact F4" the instance still can found, but after I added F4, the instance cannot be found any more. Is there are anything wrong in "fact F4"? and how can I fix it. thanks for your help.
/**
* The books in a library.
*/
some sig Book{}
/**
* Patrons of the library, in general, have some books (on loan)
* and want some other books.
*/
some sig Patron {
has : set Book,
wants : set Book
}
/**
* The library has some books on reserve, some on the shelves,
* and some on hold because patrons want them (are waiting for
* them).
*
* Note: The books on loan are exactly those all the Patrons as
* a group "have".
*/
one sig Library {
onReserve : set Book,
onShelves : set Book
}
/**
* All wanted books are on loan to some patron (that is,
* some patron has the wanted book). Note that a patron
* *MAY* have a book out that nobody else wants.
*/
fact F4_All_wanted_books_are_had_by_someone {
all b : Patron | b.wants in b.has
}
/**
* Two different patrons cannot have the same book.
*/
fact F5_No_loan_conflicts {
all disj b1, b2 : Patron | no (b1.has & b2.has)
}
/**
* A patron cannot want a book he or she already has.
*/
fact F7_Cannot_want_what_you_have {
all b : Patron | no (b.wants & b.has)
}
run{
some onReserve
some onShelves - onReserve
some wants
some has
some Patron.has - Patron.wants
some Patron.has & Patron.wants
some has.Book & wants.Book
} for exactly 3 Patron, exactly 8 Book
The meaning of your F4 is "for all patrons every book he wants is among those he has". I suggest
fact F4 {
all p:Patron | p.wants in (Patron - p).has
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.