Cleanup 2
This commit is contained in:
parent
a9bb6e0338
commit
3c938749d0
22 changed files with 299 additions and 110 deletions
|
@ -3,18 +3,15 @@ package prolog.builtins
|
|||
import prolog.Answers
|
||||
import prolog.Substitutions
|
||||
import prolog.ast.logic.LogicOperand
|
||||
import prolog.ast.terms.Atom
|
||||
import prolog.ast.logic.LogicOperator
|
||||
import prolog.ast.terms.Goal
|
||||
import prolog.ast.terms.Operand
|
||||
import prolog.ast.terms.Operator
|
||||
|
||||
class Initialization(val goal: LogicOperand) : LogicOperator(Atom(":-"), null, goal) {
|
||||
class Initialization(val goal: LogicOperand) : LogicOperator(":-", rightOperand = goal) {
|
||||
override fun satisfy(subs: Substitutions): Answers = goal.satisfy(subs).take(1)
|
||||
override fun toString(): String = goal.toString()
|
||||
}
|
||||
|
||||
class Query(val query: LogicOperand) : LogicOperator(Atom("?-"), null, query) {
|
||||
class Query(val query: LogicOperand) : LogicOperator("?-", rightOperand = query) {
|
||||
override fun satisfy(subs: Substitutions): Answers = query.satisfy(subs)
|
||||
}
|
||||
|
||||
|
@ -24,7 +21,8 @@ class Query(val query: LogicOperand) : LogicOperator(Atom("?-"), null, query) {
|
|||
*
|
||||
* @see [SWI-Prolog Predicate forall/2](https://www.swi-prolog.org/pldoc/doc_for?object=forall/2)
|
||||
*/
|
||||
class ForAll(condition: LogicOperand, action: Goal) : Operator(Atom("forall"), condition, action) {
|
||||
private val not = Not(Conjunction(condition, Not(action)))
|
||||
override fun satisfy(subs: Substitutions): Answers = not.satisfy(subs)
|
||||
class ForAll(private val condition: LogicOperand, private val action: Goal) :
|
||||
Not(Conjunction(condition, Not(action))) {
|
||||
override fun toString() = "forall($condition, $action)"
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue