Knowledge Base Updates

Flora contains a number of operators that can directly modify the state of the KB. These operators allow you to add and remove fact at runtime, from a rule or a query. They can be used, for example, when Sunflower is connected to a database, or a source of knowledge such as a user interface with knowledge entry forms.

The insert operator is used to insert facts into the KB, and the delete operator to remove knowledge.

insert{Greg : Person [ child -> {Louisa, Kellie} ]}. // composite facts are allowed
delete{Greg : Person}.
delete{?x : Person}.   // variables can be used, all matching facts are removed

Flora also has “transactional” versions of these operators, prefixed with t_, for examples, t_insert and t_delete. The difference is that KB updates done by the transactional operators are undone during backtracking, that is, if subsequent updates to the rule fail.

The Flora-2 Manual [1] describes these operators in detail in the section “Updating the Knowledge Base”.

[1]Kifer, Michael, Guizhen Yang, Wan Hui, and Chang Zhao. 2014. Flora-2: User’s Manual. 1.0. Stony Brook University, Stony Brook: Department of Computer Science.