Prolog has four database manipulation commands: assert, retract, asserta, and assertz. assert adds facts and rules to the database, retract removes them, and asserta and assertz control where asserted material is placed. There are three predicates for collecting all solutions to a query: findall, bagof, and setof. findall produces a list of all objects satisfying the goal. bagof produces a separate list for each instantiation of variables in the goal. setof orders solutions and removes redundancies.