Feature structure unification in minikanren











up vote
5
down vote

favorite
3












How would one define a feature structure unification and subsumption in minikanren if we represent feature structures with lists?



The general behaviour would be something like this (I think):



(run* (q) (unifyo '(a b) '(a b) q))) => (a b)

(run* (q) (unifyo '(x (a b)) '(x (c d)) q)) => (x (a b) (c d)) (x (c d) (a b))

(run* (q) (unifyo '(x (a b)) '(x (a d)) q)) => () ; fails because '(a b) is
; incompatible with '(a d)
(run* (q)
(fresh (y) (unifyo '(x (a b)) `(x ,y) q)) => (x (a b)))

(run* (q) (unifyo q '(x (a b)) '(x (a b) (c d)))) => (x (c d))




The following code sort of works, but backwards unification gets stuck when ran with run*:



;; unifies f1 with l2
(define unify-f-with-list°
(lambda (f1 l2 out)
(conde
[(== '() l2) (== `(,f1) out)]
[(fresh (la ld a2 d2 a1 d1 res)
(=/= '() l2)
(== `(,la . ,ld) l2)
(== `(,a2 . ,d2) la)
(== `(,a1 . ,d1) f1)
(conde
[(== a2 a1)
(== `(,res . ,ld) out)
(unify° f1 la res)]
[(fresh ()
(=/= a2 a1) ;; if not
(== `(,la . ,res) out)
(unify-f-with-list° f1 ld res))]))])))

(define unify-list-with-list°
(lambda (l1 l2 out)
(conde
[(== '() l1) (== l2 out)]
[(== '() l2) (== l1 out)]
[(fresh (a1 d1 res)
(=/= '() l1)
(== `(,a1 . ,d1) l1)
(unify-f-with-list° a1 l2 res)
(unify-list-with-list° d1 res out))])))

(define unify°
(lambda (f1 f2 out)
(conde
[(== f1 f2) (== f1 out)]
[(fresh (a1 d1 a2 d2)
(=/= f1 f2)
(== `(,a1 . ,d1) f1)
(== `(,a2 . ,d2) f2)
(== a1 a2)
(fresh (res)
(unify-list-with-list° d1 d2 res)
(== `(,a1 . ,res) out)))])))









share|improve this question
























  • whats fts? 123456
    – rain1
    Nov 23 at 14:45










  • feature structure, I changed it.
    – Matías Guzmán Naranjo
    Nov 23 at 15:32








  • 1




    Could you clarify what the three inputs mean, more precisely? In particular it's not clear what the form of the third argument is supposed to be. And also, what are "variables" and what are "atoms"? Why is (a b) compatible with (c d) in the 2nd example, but (a b) is incompatible with (a d) in the 3rd example?
    – Alex Knauth
    Nov 25 at 15:22






  • 2




    Could you explain each sample call's context and meaning? Include some links to define all the terms you're using? At least some link to some relevant page or something?
    – Will Ness
    Nov 25 at 16:26








  • 1




    for a possible Prolog implementation, see attr/2. With it, the last example in 13.5.1 is achieved with attr(X, [cat-s, head-Head]), attr(Head, [agr-Agr, subj-Subj]), attr(Subj, [agr-Agr]), attr(Agr, [num-sg,pers-3]).. or maplist(attr, [X, Head, Subj, Agr], [[cat-s, head-Head], [agr-Agr, subj-Subj], [agr-Agr], [num-sg,pers-3]])..
    – Will Ness
    Dec 1 at 14:52

















up vote
5
down vote

favorite
3












How would one define a feature structure unification and subsumption in minikanren if we represent feature structures with lists?



The general behaviour would be something like this (I think):



(run* (q) (unifyo '(a b) '(a b) q))) => (a b)

(run* (q) (unifyo '(x (a b)) '(x (c d)) q)) => (x (a b) (c d)) (x (c d) (a b))

(run* (q) (unifyo '(x (a b)) '(x (a d)) q)) => () ; fails because '(a b) is
; incompatible with '(a d)
(run* (q)
(fresh (y) (unifyo '(x (a b)) `(x ,y) q)) => (x (a b)))

(run* (q) (unifyo q '(x (a b)) '(x (a b) (c d)))) => (x (c d))




The following code sort of works, but backwards unification gets stuck when ran with run*:



;; unifies f1 with l2
(define unify-f-with-list°
(lambda (f1 l2 out)
(conde
[(== '() l2) (== `(,f1) out)]
[(fresh (la ld a2 d2 a1 d1 res)
(=/= '() l2)
(== `(,la . ,ld) l2)
(== `(,a2 . ,d2) la)
(== `(,a1 . ,d1) f1)
(conde
[(== a2 a1)
(== `(,res . ,ld) out)
(unify° f1 la res)]
[(fresh ()
(=/= a2 a1) ;; if not
(== `(,la . ,res) out)
(unify-f-with-list° f1 ld res))]))])))

(define unify-list-with-list°
(lambda (l1 l2 out)
(conde
[(== '() l1) (== l2 out)]
[(== '() l2) (== l1 out)]
[(fresh (a1 d1 res)
(=/= '() l1)
(== `(,a1 . ,d1) l1)
(unify-f-with-list° a1 l2 res)
(unify-list-with-list° d1 res out))])))

(define unify°
(lambda (f1 f2 out)
(conde
[(== f1 f2) (== f1 out)]
[(fresh (a1 d1 a2 d2)
(=/= f1 f2)
(== `(,a1 . ,d1) f1)
(== `(,a2 . ,d2) f2)
(== a1 a2)
(fresh (res)
(unify-list-with-list° d1 d2 res)
(== `(,a1 . ,res) out)))])))









share|improve this question
























  • whats fts? 123456
    – rain1
    Nov 23 at 14:45










  • feature structure, I changed it.
    – Matías Guzmán Naranjo
    Nov 23 at 15:32








  • 1




    Could you clarify what the three inputs mean, more precisely? In particular it's not clear what the form of the third argument is supposed to be. And also, what are "variables" and what are "atoms"? Why is (a b) compatible with (c d) in the 2nd example, but (a b) is incompatible with (a d) in the 3rd example?
    – Alex Knauth
    Nov 25 at 15:22






  • 2




    Could you explain each sample call's context and meaning? Include some links to define all the terms you're using? At least some link to some relevant page or something?
    – Will Ness
    Nov 25 at 16:26








  • 1




    for a possible Prolog implementation, see attr/2. With it, the last example in 13.5.1 is achieved with attr(X, [cat-s, head-Head]), attr(Head, [agr-Agr, subj-Subj]), attr(Subj, [agr-Agr]), attr(Agr, [num-sg,pers-3]).. or maplist(attr, [X, Head, Subj, Agr], [[cat-s, head-Head], [agr-Agr, subj-Subj], [agr-Agr], [num-sg,pers-3]])..
    – Will Ness
    Dec 1 at 14:52















up vote
5
down vote

favorite
3









up vote
5
down vote

favorite
3






3





How would one define a feature structure unification and subsumption in minikanren if we represent feature structures with lists?



The general behaviour would be something like this (I think):



(run* (q) (unifyo '(a b) '(a b) q))) => (a b)

(run* (q) (unifyo '(x (a b)) '(x (c d)) q)) => (x (a b) (c d)) (x (c d) (a b))

(run* (q) (unifyo '(x (a b)) '(x (a d)) q)) => () ; fails because '(a b) is
; incompatible with '(a d)
(run* (q)
(fresh (y) (unifyo '(x (a b)) `(x ,y) q)) => (x (a b)))

(run* (q) (unifyo q '(x (a b)) '(x (a b) (c d)))) => (x (c d))




The following code sort of works, but backwards unification gets stuck when ran with run*:



;; unifies f1 with l2
(define unify-f-with-list°
(lambda (f1 l2 out)
(conde
[(== '() l2) (== `(,f1) out)]
[(fresh (la ld a2 d2 a1 d1 res)
(=/= '() l2)
(== `(,la . ,ld) l2)
(== `(,a2 . ,d2) la)
(== `(,a1 . ,d1) f1)
(conde
[(== a2 a1)
(== `(,res . ,ld) out)
(unify° f1 la res)]
[(fresh ()
(=/= a2 a1) ;; if not
(== `(,la . ,res) out)
(unify-f-with-list° f1 ld res))]))])))

(define unify-list-with-list°
(lambda (l1 l2 out)
(conde
[(== '() l1) (== l2 out)]
[(== '() l2) (== l1 out)]
[(fresh (a1 d1 res)
(=/= '() l1)
(== `(,a1 . ,d1) l1)
(unify-f-with-list° a1 l2 res)
(unify-list-with-list° d1 res out))])))

(define unify°
(lambda (f1 f2 out)
(conde
[(== f1 f2) (== f1 out)]
[(fresh (a1 d1 a2 d2)
(=/= f1 f2)
(== `(,a1 . ,d1) f1)
(== `(,a2 . ,d2) f2)
(== a1 a2)
(fresh (res)
(unify-list-with-list° d1 d2 res)
(== `(,a1 . ,res) out)))])))









share|improve this question















How would one define a feature structure unification and subsumption in minikanren if we represent feature structures with lists?



The general behaviour would be something like this (I think):



(run* (q) (unifyo '(a b) '(a b) q))) => (a b)

(run* (q) (unifyo '(x (a b)) '(x (c d)) q)) => (x (a b) (c d)) (x (c d) (a b))

(run* (q) (unifyo '(x (a b)) '(x (a d)) q)) => () ; fails because '(a b) is
; incompatible with '(a d)
(run* (q)
(fresh (y) (unifyo '(x (a b)) `(x ,y) q)) => (x (a b)))

(run* (q) (unifyo q '(x (a b)) '(x (a b) (c d)))) => (x (c d))




The following code sort of works, but backwards unification gets stuck when ran with run*:



;; unifies f1 with l2
(define unify-f-with-list°
(lambda (f1 l2 out)
(conde
[(== '() l2) (== `(,f1) out)]
[(fresh (la ld a2 d2 a1 d1 res)
(=/= '() l2)
(== `(,la . ,ld) l2)
(== `(,a2 . ,d2) la)
(== `(,a1 . ,d1) f1)
(conde
[(== a2 a1)
(== `(,res . ,ld) out)
(unify° f1 la res)]
[(fresh ()
(=/= a2 a1) ;; if not
(== `(,la . ,res) out)
(unify-f-with-list° f1 ld res))]))])))

(define unify-list-with-list°
(lambda (l1 l2 out)
(conde
[(== '() l1) (== l2 out)]
[(== '() l2) (== l1 out)]
[(fresh (a1 d1 res)
(=/= '() l1)
(== `(,a1 . ,d1) l1)
(unify-f-with-list° a1 l2 res)
(unify-list-with-list° d1 res out))])))

(define unify°
(lambda (f1 f2 out)
(conde
[(== f1 f2) (== f1 out)]
[(fresh (a1 d1 a2 d2)
(=/= f1 f2)
(== `(,a1 . ,d1) f1)
(== `(,a2 . ,d2) f2)
(== a1 a2)
(fresh (res)
(unify-list-with-list° d1 d2 res)
(== `(,a1 . ,res) out)))])))






scheme racket unification minikanren






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday

























asked Nov 22 at 17:17









Matías Guzmán Naranjo

2001315




2001315












  • whats fts? 123456
    – rain1
    Nov 23 at 14:45










  • feature structure, I changed it.
    – Matías Guzmán Naranjo
    Nov 23 at 15:32








  • 1




    Could you clarify what the three inputs mean, more precisely? In particular it's not clear what the form of the third argument is supposed to be. And also, what are "variables" and what are "atoms"? Why is (a b) compatible with (c d) in the 2nd example, but (a b) is incompatible with (a d) in the 3rd example?
    – Alex Knauth
    Nov 25 at 15:22






  • 2




    Could you explain each sample call's context and meaning? Include some links to define all the terms you're using? At least some link to some relevant page or something?
    – Will Ness
    Nov 25 at 16:26








  • 1




    for a possible Prolog implementation, see attr/2. With it, the last example in 13.5.1 is achieved with attr(X, [cat-s, head-Head]), attr(Head, [agr-Agr, subj-Subj]), attr(Subj, [agr-Agr]), attr(Agr, [num-sg,pers-3]).. or maplist(attr, [X, Head, Subj, Agr], [[cat-s, head-Head], [agr-Agr, subj-Subj], [agr-Agr], [num-sg,pers-3]])..
    – Will Ness
    Dec 1 at 14:52




















  • whats fts? 123456
    – rain1
    Nov 23 at 14:45










  • feature structure, I changed it.
    – Matías Guzmán Naranjo
    Nov 23 at 15:32








  • 1




    Could you clarify what the three inputs mean, more precisely? In particular it's not clear what the form of the third argument is supposed to be. And also, what are "variables" and what are "atoms"? Why is (a b) compatible with (c d) in the 2nd example, but (a b) is incompatible with (a d) in the 3rd example?
    – Alex Knauth
    Nov 25 at 15:22






  • 2




    Could you explain each sample call's context and meaning? Include some links to define all the terms you're using? At least some link to some relevant page or something?
    – Will Ness
    Nov 25 at 16:26








  • 1




    for a possible Prolog implementation, see attr/2. With it, the last example in 13.5.1 is achieved with attr(X, [cat-s, head-Head]), attr(Head, [agr-Agr, subj-Subj]), attr(Subj, [agr-Agr]), attr(Agr, [num-sg,pers-3]).. or maplist(attr, [X, Head, Subj, Agr], [[cat-s, head-Head], [agr-Agr, subj-Subj], [agr-Agr], [num-sg,pers-3]])..
    – Will Ness
    Dec 1 at 14:52


















whats fts? 123456
– rain1
Nov 23 at 14:45




whats fts? 123456
– rain1
Nov 23 at 14:45












feature structure, I changed it.
– Matías Guzmán Naranjo
Nov 23 at 15:32






feature structure, I changed it.
– Matías Guzmán Naranjo
Nov 23 at 15:32






1




1




Could you clarify what the three inputs mean, more precisely? In particular it's not clear what the form of the third argument is supposed to be. And also, what are "variables" and what are "atoms"? Why is (a b) compatible with (c d) in the 2nd example, but (a b) is incompatible with (a d) in the 3rd example?
– Alex Knauth
Nov 25 at 15:22




Could you clarify what the three inputs mean, more precisely? In particular it's not clear what the form of the third argument is supposed to be. And also, what are "variables" and what are "atoms"? Why is (a b) compatible with (c d) in the 2nd example, but (a b) is incompatible with (a d) in the 3rd example?
– Alex Knauth
Nov 25 at 15:22




2




2




Could you explain each sample call's context and meaning? Include some links to define all the terms you're using? At least some link to some relevant page or something?
– Will Ness
Nov 25 at 16:26






Could you explain each sample call's context and meaning? Include some links to define all the terms you're using? At least some link to some relevant page or something?
– Will Ness
Nov 25 at 16:26






1




1




for a possible Prolog implementation, see attr/2. With it, the last example in 13.5.1 is achieved with attr(X, [cat-s, head-Head]), attr(Head, [agr-Agr, subj-Subj]), attr(Subj, [agr-Agr]), attr(Agr, [num-sg,pers-3]).. or maplist(attr, [X, Head, Subj, Agr], [[cat-s, head-Head], [agr-Agr, subj-Subj], [agr-Agr], [num-sg,pers-3]])..
– Will Ness
Dec 1 at 14:52






for a possible Prolog implementation, see attr/2. With it, the last example in 13.5.1 is achieved with attr(X, [cat-s, head-Head]), attr(Head, [agr-Agr, subj-Subj]), attr(Subj, [agr-Agr]), attr(Agr, [num-sg,pers-3]).. or maplist(attr, [X, Head, Subj, Agr], [[cat-s, head-Head], [agr-Agr, subj-Subj], [agr-Agr], [num-sg,pers-3]])..
– Will Ness
Dec 1 at 14:52














1 Answer
1






active

oldest

votes

















up vote
1
down vote













You can implement this by modifying the code for unification in your minikanren implementation.



I would recommend not using lists to represent feature structures though, instead you could define a new record type than holds a list that always terminates in a fresh variable and one of these would represent a feature structure. Then you can still use lists and other objects as well as having these new objects available.



When the unification code sees two feature structures it would need to unify all the matching keys recursively and extend the 'rest' part of each one to contain the fields unique to the other feature structure (no destructive mutation).






share|improve this answer





















  • I've managed to write an almost working solution, but it gets stuck when querying backwards since it cannot figure out there is a finite number of solutions. Any ideas how to fix it? (I've added the code to my question).
    – Matías Guzmán Naranjo
    Dec 9 at 19:26






  • 1




    @MatíasGuzmánNaranjo You are trying to implement this in minikanren. I don't recommend that. (It is not going to work well because mk doesn't have the non-logical control constructs prolog has like cut) Instead implement it in scheme as an additional feature to the minikanren system.
    – rain1
    Dec 9 at 20:44












  • Why do you think 'cut' is necessary for this to work? And the whole point of this is to have a unification relation which can run in either direction.
    – Matías Guzmán Naranjo
    Dec 9 at 21:00






  • 1




    I don't think you should use cut. The prolog code that you linked in the question uses cut. This feature structure stuff can't be expressed in purely logical mk code. That's why you need to drop down to the scheme implementation of unification to write this. If implemented correctly it will be bidirectional just like unification is.
    – rain1
    Dec 9 at 22:42












  • the fact that the mk program doesn't terminate is AFAIK a clue that it requires cut. I agree with @rain1 and I think that the implementation must be done in scheme.
    – amirouche
    2 days ago











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435720%2ffeature-structure-unification-in-minikanren%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













You can implement this by modifying the code for unification in your minikanren implementation.



I would recommend not using lists to represent feature structures though, instead you could define a new record type than holds a list that always terminates in a fresh variable and one of these would represent a feature structure. Then you can still use lists and other objects as well as having these new objects available.



When the unification code sees two feature structures it would need to unify all the matching keys recursively and extend the 'rest' part of each one to contain the fields unique to the other feature structure (no destructive mutation).






share|improve this answer





















  • I've managed to write an almost working solution, but it gets stuck when querying backwards since it cannot figure out there is a finite number of solutions. Any ideas how to fix it? (I've added the code to my question).
    – Matías Guzmán Naranjo
    Dec 9 at 19:26






  • 1




    @MatíasGuzmánNaranjo You are trying to implement this in minikanren. I don't recommend that. (It is not going to work well because mk doesn't have the non-logical control constructs prolog has like cut) Instead implement it in scheme as an additional feature to the minikanren system.
    – rain1
    Dec 9 at 20:44












  • Why do you think 'cut' is necessary for this to work? And the whole point of this is to have a unification relation which can run in either direction.
    – Matías Guzmán Naranjo
    Dec 9 at 21:00






  • 1




    I don't think you should use cut. The prolog code that you linked in the question uses cut. This feature structure stuff can't be expressed in purely logical mk code. That's why you need to drop down to the scheme implementation of unification to write this. If implemented correctly it will be bidirectional just like unification is.
    – rain1
    Dec 9 at 22:42












  • the fact that the mk program doesn't terminate is AFAIK a clue that it requires cut. I agree with @rain1 and I think that the implementation must be done in scheme.
    – amirouche
    2 days ago















up vote
1
down vote













You can implement this by modifying the code for unification in your minikanren implementation.



I would recommend not using lists to represent feature structures though, instead you could define a new record type than holds a list that always terminates in a fresh variable and one of these would represent a feature structure. Then you can still use lists and other objects as well as having these new objects available.



When the unification code sees two feature structures it would need to unify all the matching keys recursively and extend the 'rest' part of each one to contain the fields unique to the other feature structure (no destructive mutation).






share|improve this answer





















  • I've managed to write an almost working solution, but it gets stuck when querying backwards since it cannot figure out there is a finite number of solutions. Any ideas how to fix it? (I've added the code to my question).
    – Matías Guzmán Naranjo
    Dec 9 at 19:26






  • 1




    @MatíasGuzmánNaranjo You are trying to implement this in minikanren. I don't recommend that. (It is not going to work well because mk doesn't have the non-logical control constructs prolog has like cut) Instead implement it in scheme as an additional feature to the minikanren system.
    – rain1
    Dec 9 at 20:44












  • Why do you think 'cut' is necessary for this to work? And the whole point of this is to have a unification relation which can run in either direction.
    – Matías Guzmán Naranjo
    Dec 9 at 21:00






  • 1




    I don't think you should use cut. The prolog code that you linked in the question uses cut. This feature structure stuff can't be expressed in purely logical mk code. That's why you need to drop down to the scheme implementation of unification to write this. If implemented correctly it will be bidirectional just like unification is.
    – rain1
    Dec 9 at 22:42












  • the fact that the mk program doesn't terminate is AFAIK a clue that it requires cut. I agree with @rain1 and I think that the implementation must be done in scheme.
    – amirouche
    2 days ago













up vote
1
down vote










up vote
1
down vote









You can implement this by modifying the code for unification in your minikanren implementation.



I would recommend not using lists to represent feature structures though, instead you could define a new record type than holds a list that always terminates in a fresh variable and one of these would represent a feature structure. Then you can still use lists and other objects as well as having these new objects available.



When the unification code sees two feature structures it would need to unify all the matching keys recursively and extend the 'rest' part of each one to contain the fields unique to the other feature structure (no destructive mutation).






share|improve this answer












You can implement this by modifying the code for unification in your minikanren implementation.



I would recommend not using lists to represent feature structures though, instead you could define a new record type than holds a list that always terminates in a fresh variable and one of these would represent a feature structure. Then you can still use lists and other objects as well as having these new objects available.



When the unification code sees two feature structures it would need to unify all the matching keys recursively and extend the 'rest' part of each one to contain the fields unique to the other feature structure (no destructive mutation).







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 9 at 0:41









rain1

31918




31918












  • I've managed to write an almost working solution, but it gets stuck when querying backwards since it cannot figure out there is a finite number of solutions. Any ideas how to fix it? (I've added the code to my question).
    – Matías Guzmán Naranjo
    Dec 9 at 19:26






  • 1




    @MatíasGuzmánNaranjo You are trying to implement this in minikanren. I don't recommend that. (It is not going to work well because mk doesn't have the non-logical control constructs prolog has like cut) Instead implement it in scheme as an additional feature to the minikanren system.
    – rain1
    Dec 9 at 20:44












  • Why do you think 'cut' is necessary for this to work? And the whole point of this is to have a unification relation which can run in either direction.
    – Matías Guzmán Naranjo
    Dec 9 at 21:00






  • 1




    I don't think you should use cut. The prolog code that you linked in the question uses cut. This feature structure stuff can't be expressed in purely logical mk code. That's why you need to drop down to the scheme implementation of unification to write this. If implemented correctly it will be bidirectional just like unification is.
    – rain1
    Dec 9 at 22:42












  • the fact that the mk program doesn't terminate is AFAIK a clue that it requires cut. I agree with @rain1 and I think that the implementation must be done in scheme.
    – amirouche
    2 days ago


















  • I've managed to write an almost working solution, but it gets stuck when querying backwards since it cannot figure out there is a finite number of solutions. Any ideas how to fix it? (I've added the code to my question).
    – Matías Guzmán Naranjo
    Dec 9 at 19:26






  • 1




    @MatíasGuzmánNaranjo You are trying to implement this in minikanren. I don't recommend that. (It is not going to work well because mk doesn't have the non-logical control constructs prolog has like cut) Instead implement it in scheme as an additional feature to the minikanren system.
    – rain1
    Dec 9 at 20:44












  • Why do you think 'cut' is necessary for this to work? And the whole point of this is to have a unification relation which can run in either direction.
    – Matías Guzmán Naranjo
    Dec 9 at 21:00






  • 1




    I don't think you should use cut. The prolog code that you linked in the question uses cut. This feature structure stuff can't be expressed in purely logical mk code. That's why you need to drop down to the scheme implementation of unification to write this. If implemented correctly it will be bidirectional just like unification is.
    – rain1
    Dec 9 at 22:42












  • the fact that the mk program doesn't terminate is AFAIK a clue that it requires cut. I agree with @rain1 and I think that the implementation must be done in scheme.
    – amirouche
    2 days ago
















I've managed to write an almost working solution, but it gets stuck when querying backwards since it cannot figure out there is a finite number of solutions. Any ideas how to fix it? (I've added the code to my question).
– Matías Guzmán Naranjo
Dec 9 at 19:26




I've managed to write an almost working solution, but it gets stuck when querying backwards since it cannot figure out there is a finite number of solutions. Any ideas how to fix it? (I've added the code to my question).
– Matías Guzmán Naranjo
Dec 9 at 19:26




1




1




@MatíasGuzmánNaranjo You are trying to implement this in minikanren. I don't recommend that. (It is not going to work well because mk doesn't have the non-logical control constructs prolog has like cut) Instead implement it in scheme as an additional feature to the minikanren system.
– rain1
Dec 9 at 20:44






@MatíasGuzmánNaranjo You are trying to implement this in minikanren. I don't recommend that. (It is not going to work well because mk doesn't have the non-logical control constructs prolog has like cut) Instead implement it in scheme as an additional feature to the minikanren system.
– rain1
Dec 9 at 20:44














Why do you think 'cut' is necessary for this to work? And the whole point of this is to have a unification relation which can run in either direction.
– Matías Guzmán Naranjo
Dec 9 at 21:00




Why do you think 'cut' is necessary for this to work? And the whole point of this is to have a unification relation which can run in either direction.
– Matías Guzmán Naranjo
Dec 9 at 21:00




1




1




I don't think you should use cut. The prolog code that you linked in the question uses cut. This feature structure stuff can't be expressed in purely logical mk code. That's why you need to drop down to the scheme implementation of unification to write this. If implemented correctly it will be bidirectional just like unification is.
– rain1
Dec 9 at 22:42






I don't think you should use cut. The prolog code that you linked in the question uses cut. This feature structure stuff can't be expressed in purely logical mk code. That's why you need to drop down to the scheme implementation of unification to write this. If implemented correctly it will be bidirectional just like unification is.
– rain1
Dec 9 at 22:42














the fact that the mk program doesn't terminate is AFAIK a clue that it requires cut. I agree with @rain1 and I think that the implementation must be done in scheme.
– amirouche
2 days ago




the fact that the mk program doesn't terminate is AFAIK a clue that it requires cut. I agree with @rain1 and I think that the implementation must be done in scheme.
– amirouche
2 days ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435720%2ffeature-structure-unification-in-minikanren%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

Alexandru Averescu

Trompette piccolo