Pereira@SRI-AI@sri-unix.UUCP (10/12/83)
If convenience for the programmer is what you are after, letting assertz modify running procedures is in at least 50% of the cases what you need. For example, to compute bottom-up the transitive closure c(X,Y) of r(U,V), do close :- connected(X,Y), connected(Y,Z), add_c(Y,Z), fail. close. connected(X,Y) :- r(X,Y). connected(X,Y) :- c(X,Y). add_c(X,Y) :- not_subsumed(c(X,Y)), assertz(c(X,Y)). not_subsumed(P) :- "the usual stuff". Programs of this kind can implement all sorts of bottom-up and mixed initiative deductive procedures, such as those derived from CF parsing algorithms like Cocke-Kasami-Young and Earley. What is interesting about these applications is that the implementation code is not pure logic, but they use the Prolog machinery to implement another correct inference procedure, which can be abstracted as the computation of the transitive closure of some relation (CKY has often been presented this way). So, either assertz is allowed to change running procedures, or two brands of assertz are created to provide the two alternative behaviors. In any case, trying to abstract frequently used operations as Richard has done is a good thing. -- Fernando Pereira