Prolog "chap11a"

Admin User, erstellt 26. Mai 2023
         
/**
* <title editable="nocomment">Chap11a</title>
* <h1>Chap11a: assertz</h1>
* <p>Prolog has two database manipulation commands:
* assertz and retract. Let’s see how these are used.
* Suppose we start with an empty database. So if we
* give the command:</p>
*/
?- listing.
/**
* <p>then Prolog will simply respond true; the listing (of course)
* is empty.</p><p>Suppose we now give this command:<p>
*/
?- assertz(happy(mia)).
/**
* <p>This succeeds ( assertz/1 commands always succeed). But what is
* important is not that it succeeds, but the side-effect it
* has on the database. For if we now give the command</p>
*/
?- listing.
/**
* <p>We get the fact. That is, the database is no longer empty:
* it now contains the fact we asserted.</p>
* <p>Suppose we then made four more assert commands:</p>
*/
?- assertz(happy(vincent)).
?- assertz(happy(marcellus)).
?- assertz(happy(butch)).
?- assertz(happy(vincent)).
/**
* <p>and then ask for a listing:</p>
*/
?- listing.
/**
* <p>All the facts we asserted are now in the knowledge base.
* Note that happy(vincent) is in the knowledge base twice.
* As we asserted it twice, this seems sensible.</p>
*/