Skip to content

Commit

Permalink
Introduce match method in Prolog Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
jzalacainllanes committed Jul 12, 2023
1 parent 2cdf442 commit 59b0f81
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public final boolean unify(PrologTerm t1, PrologTerm t2) {
return t1.unify(t2);
}

public Map<String, PrologTerm> match(PrologTerm t1, PrologTerm t2) {
return queryOne(t1 + "=" + t2);
}

public final boolean contains(String goal) {
return query(goal).hasSolution();
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/github/prolobjectlink/prolog/PrologEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,18 @@ public interface PrologEngine extends Iterable<PrologClause> {
*/
public boolean unify(PrologTerm t1, PrologTerm t2);

/**
* Match to other term returning list of substitutions. Used to compute the most
* general unifier.
*
* @param t1 the term to unify.
* @param t2 the term to unify.
* @return true if the specified term unify whit the current term, false
* otherwise.
* @since 1.2
*/
public Map<String, PrologTerm> match(PrologTerm t1, PrologTerm t2);

/**
* Parse the string creating internal prolog clause and returning true if the
* given goal have solution using the resolution engine mechanism. If wrapped
Expand Down

0 comments on commit 59b0f81

Please sign in to comment.