Re: [racket-users] Apparent Datalog error?
On 1/31/2018 2:51 PM, Matthias Felleisen wrote: > On Jan 31, 2018, at 2:15 PM, George Neuner wrote: > > > On 1/31/2018 2:10 PM, Sam Caldwell wrote: >> Your definition of `ancestor` is one or two steps of parentage: >> >> > ancestor(A, B) :- parent(A, B). >> > ancestor(A, B) :- >> parent(A, C), >> parent(C, B). >> >> I suspect you want one of those lines to appeal to the `ancestor` relation to allow longer chains. > > Knowing nothing about datalog he asks naively: > > Shouldn't the ruleancestor(A, B) :- parent(A, C), parent(C, B). be applied recursively? It is — except that there’s no recursion. > Kevin's definition would work in Prolog. No it wouldn’t. Sorry ... brain freeze. Somehow I misread Kevin's code as being ancestor(A, B) :- parent(A, C), ancestor(C, B). which would work. You and Sam both are absolutely correct that it does not work as written. Apologies for the noise. George -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Apparent Datalog error?
> On Jan 31, 2018, at 2:15 PM, George Neuner wrote: > > > On 1/31/2018 2:10 PM, Sam Caldwell wrote: >> Your definition of `ancestor` is one or two steps of parentage: >> >> > ancestor(A, B) :- parent(A, B). >> > ancestor(A, B) :- >> parent(A, C), >> parent(C, B). >> >> I suspect you want one of those lines to appeal to the `ancestor` relation >> to allow longer chains. > > Knowing nothing about datalog he asks naively: > > Shouldn't the ruleancestor(A, B) :- parent(A, C), parent(C, B). be > applied recursively? It is — except that there’s no recursion. > Kevin's definition would work in Prolog. No it wouldn’t. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Apparent Datalog error?
On 1/31/2018 2:10 PM, Sam Caldwell wrote: Your definition of `ancestor` is one or two steps of parentage: > ancestor(A, B) :- parent(A, B). > ancestor(A, B) :- parent(A, C), parent(C, B). I suspect you want one of those lines to appeal to the `ancestor` relation to allow longer chains. Knowing nothing about datalog he asks naively: Shouldn't the rule ancestor(A, B) :- parent(A, C), parent(C, B). be applied recursively? Kevin's definition would work in Prolog. George -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Apparent Datalog error?
Your definition of `ancestor` is one or two steps of parentage: > ancestor(A, B) :- parent(A, B). > ancestor(A, B) :- parent(A, C), parent(C, B). I suspect you want one of those lines to appeal to the `ancestor` relation to allow longer chains. - Sam Caldwell On Wed, Jan 31, 2018 at 1:53 PM, Kevin Forchione wrote: > Walking through the datalog tutorial I got the following transcript: > > Welcome to DrRacket, version 6.12 [3m]. > Language: datalog, with debugging; memory limit: 512 MB. > > parent(john, douglas). > > parent(john, douglas)? > parent(john, douglas). > > parent(john, evlyn)? > > > parent(bob, john). > > parent(A, B)? > parent(john, douglas). > parent(bob, john). > > parent(ebbon, bob). > > parent(john, B)? > parent(john, douglas). > > parent(A, A)? > > > ancestor(A, B) :- parent(A, B). > > ancestor(A, B) :- > parent(A, C), > parent(C, B). > > ancestor(A, B)? > ancestor(ebbon, bob). > ancestor(bob, john). > ancestor(john, douglas). > ancestor(bob, douglas). > ancestor(ebbon, john). > > > > It seems that the correct answer should also include ancestor(ebbon, > douglas). Am I doing something wrong? > > -Kevin > > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.