Unification not commutative
See original GitHub issue?- X = s(1), X = s(X). false. ?- X = s(X), X = s(1). X = 1 ;
Expected: While the second is STO (subject to occurs check) and thus undefined, it is still highly desirable if this fails. Either,
-
because
X = s(X)
fails due to the occurs check, or -
because
X = s(X)
creates an “infinite term” andX = s(1)
fails thereafter, or finally -
because
X = s(X)
produces an error - well that’s not failure …
I have never seen a system with this behavior, but very strictly speaking, that is still conforming. But I really cringe: “Why??”. I very much suspect that this is not intended.
Issue Analytics
- State:
- Created 5 years ago
- Comments:14
Top Results From Across the Web
Commutative Unification - Matthew Rocklin
This doesn't unify. While the first ( add , add ) and second ( x , 1 ) elements can match (if {x:...
Read more >The Exact Unification Type of Commutative Theories
The exact unification type of an equational theory is based on a new preorder on substitutions, called the exactness preorder, which is tailored ......
Read more >Unification not commutative · Issue #5 · tau-prolog/tau ... - GitHub
If f(X,X) unifies with another term, a substitution {X/something} is generated. Then, this substitution is applied to the rest of the goal, and ......
Read more >Unification Substitutions
Unification is a “mutual pattern matching" procedure that takes two terms (or atoms) as input, and returns "failure" if they do not match...
Read more >E-unification
Matijasevic, building on the work of Davis, Putnam, and Robinson, proved that there is no algorithm to determine if a finite system of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I don’t know. I didn’t implement rational term unification in my system. But algorithms for this problem should be around. Like for example Colmerauer was writing about them:
P R O L O G IN 10 F I G U R E S - Alain Colmerauer 4. INFINITE T R E E S https://www.ijcai.org/Proceedings/83-1/Papers/117a.pdf
SWI-Prolog has implemented such an algorithm. I guess if you do something along bisimulation, you might develop also such an algorithm. You need bisimulation for cases like this:
But making it efficient and not using a lot of extra data structures is the challenge here. SWI-Prolog has not only treated predicates such as (=)/2, but also predicate such as ground/1 and (==)/2.
I did recently something for term_variables/2, by a simple visited list:
public void safeVars(Object t, Display d) { https://github.com/jburse/jekejeke-devel/blob/master/jekrun/headless/jekpro/reference/structure/EngineVars.java#L299
I started using a separate name space, like safe_term_variables/2. I needed this to make the top-level a little safer, like GNU Prolog, I wanted to display <cyclic term> for cyclic terms and not crash.
Interesting. And how do you avoid the infinite loop in case
Y = s(s(Y)), Y = s(Y).
?