Checkpoint
This commit is contained in:
parent
438af6c053
commit
6eca9dfcb7
25 changed files with 309 additions and 113 deletions
|
@ -1,5 +1,6 @@
|
|||
package prolog.components.expressions
|
||||
|
||||
import prolog.components.Resolvent
|
||||
import prolog.components.terms.Functor
|
||||
import prolog.components.terms.Goal
|
||||
|
||||
|
@ -9,7 +10,7 @@ import prolog.components.terms.Goal
|
|||
* If a goal is proved, the system looks for a predicate with the same functor, then uses indexing
|
||||
* to select candidate clauses and then tries these clauses one-by-one.
|
||||
*/
|
||||
class Predicate : Expression {
|
||||
class Predicate : Resolvent {
|
||||
val functor: Functor
|
||||
val clauses: MutableList<Clause>
|
||||
|
||||
|
@ -47,8 +48,8 @@ class Predicate : Expression {
|
|||
this.clauses.addAll(clauses)
|
||||
}
|
||||
|
||||
override fun evaluate(goal: Goal): Boolean {
|
||||
override fun solve(goal: Goal): Boolean {
|
||||
require(goal.functor == functor) { "Goal functor does not match predicate functor" }
|
||||
return clauses.any { it.evaluate(goal) }
|
||||
return clauses.any { it.solve(goal) }
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue