Skip to content

Commit

Permalink
release 1.10
Browse files Browse the repository at this point in the history
store rule in first rule base
  • Loading branch information
garfix committed Jun 1, 2020
1 parent 0d10a67 commit a2d230a
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changelog

##
## 1.10 strong negation - 01-06-2020

* strong negation: the negation operator for relations
* the predicate `exec` to execute a shell command
* changed the order child sense order evaluation from post-order to pre-order

## 1.9 generalized quantifiers - 02-05-2020
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Some of the techniques used:
* A dialog context to remember information from earlier in the conversation
* Anaphora resolution: the use of pronouns and other references to earlier entities
* Generalized quantifiers
* The distinction between classic negation (`not`) and strong negation (`-`)
* A generator to produce human readable responses

## Docs
Expand All @@ -39,4 +40,4 @@ Documentation is located in the docs directory, here you can find:

* [My personal log](doc/remarks.md)
* [The processing of a request](doc/manual/system-developer/processing.md)

* [The work of a knowledge engineer](doc/manual/knowledge-engineer/index.md)
37 changes: 37 additions & 0 deletions doc/manual/knowledge-engineer/functions-modification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Modification functions

These functions allow you to modify a database by asserting and retracting relations. The `writeMap` of a fact base determines which predicates are writable.

Rules are written to a rulebase.

## assert

Writes a relation to the database or adds a rule to the rule base.

assert(P)

* `P`: a relation (i.e. father(`luke`, `darth`))

The relation is offered to all fact bases; but only the ones that have the relation defined as head in their write map will write it. But only after the relation is converted to one or more rows of database tables.


assert(R)

* `R`: a rule (i.e. fly(X) :- bird(X))

Note the following restrictions to the use of adding rules, that currently exist:

* A rule is only appended at the end of the first rule base that was added to the problem solver
* Since rule bases are in-memory, the rules are not saved when the system instance end.


See [common-sense-reasoning](common-sense-reasoning.md) for examples of default rules and exceptions.

## retract

Deletes a relation from the database

retract(P)

* `P`: a relation (i.e. father(`luke`, `darth`))

6 changes: 6 additions & 0 deletions doc/remarks.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 2020-06-01

Haha, it was only slow because the rule was added to all rule bases. And the blocks world demo has 4. Evaluation time of the demo is back to 0.15 seconds.

I tried to find the reasons for the difference between `asserta` and `assertz` but could not find them. So for now I will not make the distinction and simply add rules at the end. Later I might want to add the possibility to specify in which rule base the rule is stored. For now I will simply take the first one.

# 2020-05-31

I had no idea Prolog was so complex! You can even add new rules at run-time:
Expand Down
3 changes: 3 additions & 0 deletions doc/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
Test if this works or make it work:

married_to(A, B) :- married_to(B, A);

* Allow the dynamically added rules to be saved (in the session).
* Specify which predicates a rule base allows to be added.

## Syntax

Expand Down
2 changes: 2 additions & 0 deletions lib/central/ProblemSolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ func (solver ProblemSolver) modifyKnowledgeBase(relation mentalese.Relation, bin
rule := relation.Arguments[0].TermValueRule.BindSingle(binding)
ruleBase.Assert(rule)
newBindings = append(newBindings, binding)
// only add the rule to a single rulebase
break
}
}
} else if relation.Predicate == mentalese.PredicateRetract {
Expand Down
1 change: 0 additions & 1 deletion tests/integration/BlocksWorld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func TestBlocksWorld(t *testing.T) {
// todo: must be: I don't know
{"Can a pyramid support a pyramid?", "No"},
{"Stack up two pyramids.", "I can't"},

{"The blue pyramid is mine", "I understand"},
{"I own blocks which are not red, but I don't own anything which supports a pyramid", "I understand"},
{"Do I own the box?", "No"},
Expand Down

0 comments on commit a2d230a

Please sign in to comment.