File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
src/main/scala/io/github/kelvindev15/prolog/solver Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ trait Solver:
39
39
def admitsSolutions (program : PrologProgram ): Boolean =
40
40
val solutions = solve(program)
41
41
solutions.hasNext && solutions.next().isInstanceOf [Solution .Yes ]
42
-
42
+
43
43
object Solver :
44
44
/** A mapping from [[Variable ]]s to [[Term ]]s */
45
45
type Substitution = Map [Variable , Term ]
@@ -147,12 +147,22 @@ object Solver:
147
147
): LazyList [Solution ] =
148
148
solver lazySolve (PrologProgram .emptyTheory withGoal query)
149
149
150
+ /** Returns true if the program admits at least one solution.
151
+ *
152
+ * @param solver the solver that should be used.
153
+ * @param program the program to solve.
154
+ */
150
155
def hasSolutionForProgram (using solver : Solver = tuPrologSolver())(
151
156
program : PrologProgram
152
157
): Boolean =
153
158
val solutions = solve(program)
154
159
solutions.hasNext && solutions.next().isInstanceOf [Solution .Yes ]
155
160
161
+ /** Returns true if the program admits at least one solution.
162
+ *
163
+ * @param solver the solver that should be used.
164
+ * @param goal the program to satisfy.
165
+ */
156
166
def hasSolutionForGoal (using solver : Solver = tuPrologSolver())(
157
167
goal : Term
158
168
): Boolean = hasSolutionForProgram(PrologProgram .emptyTheory withGoal goal)
You can’t perform that action at this time.
0 commit comments