package prolog.builtins

import prolog.Answers
import prolog.Substitutions
import prolog.ast.logic.LogicOperand
import prolog.ast.logic.LogicOperator
import prolog.ast.terms.Goal

class Query(val query: LogicOperand) : LogicOperator("?-", rightOperand = query) {
    override fun satisfy(subs: Substitutions): Answers = query.satisfy(subs)
}

/**
 * For all alternative bindings of Cond, Action can be proven.
 * It does not say which is wrong if one proves wrong.
 *
 * @see [SWI-Prolog Predicate forall/2](https://www.swi-prolog.org/pldoc/doc_for?object=forall/2)
 */
class ForAll(private val condition: LogicOperand, private val action: Goal) :
    Not(Conjunction(condition, Not(action))) {
    override fun toString() = "forall($condition, $action)"
}

