Fork me on GitHub
#clara
<
2017-03-02
>
newres10:03:08

I have a question about using guards on rules in Clara. I am aiming to create rules that can never insert a fact that already exist. The guard statement works fine if I am manually inserting the fact that the guard stops, but if the rule itself is creating this statement the guard does not stop the rule from triggering again and I get an infinite loop.

zylox16:03:06

ya thats a tricky one ive dealt with too. i'm not sure what the solution is either.

newres16:03:26

with a naive implementation of rules where each rule is checked separately I can see this not being an issue as after each insertion the guard would be checked and with the new fact that guard would be passed. Could this be a bug in the implementation, where somehow not the full condition of the rule is checked for it to fire again?

zylox16:03:21

maybe i didnt understand what you meant by gaurds, but if a rule inserts something that that same rule looks at, its pretty much always going to cause another firing

zylox16:03:33

is my understanding

newres17:03:28

I think i figured out the roof of the problem

newres17:03:46

I compeltely glanced over the fact that clara does truth maintenance

newres17:03:05

this means if the result of the rule puts in the guard of the rule the fact loses support gets retracted and the rule fires again

newres17:03:18

I feel very dense about this

wparker17:03:05

You can use unconditional insertions that wonโ€™t use truth maintenance if necessary. In our use cases we strongly prefer truth maintenance and find that it makes the code simpler to reason about, but obviously use-cases differ

newres17:03:20

i was staring at this like a whole evening thinking what the problem could be, whoops.

wparker17:03:23

It is a common point of confusion ๐Ÿ™‚

newres17:03:04

It kind of solves pretty much every problem I had with clara though, so that is a relief

zylox17:03:07

so you are saying you were stuck in an infinite loop about the infinite loop and the truth about truth maintenence resolved it

newres17:03:11

yeah basically using a guard with truth maintenance, where the result of the rule (or another) triggers the guard can start an infinite loop

newres17:03:45

especially in the case where it is just a single rule that triggers the guard

zylox17:03:12

(i was just making a light hearted joke about how your proccess of realizing how it was working was similar to a rules network) though your understanding sounds correct to me

newres17:03:41

well like I said I feel dense today

nrayapati19:03:04

Overview of the talk @mikerod gave at the Clojure/conj 2016 conference.

mikerod20:03:17

Oh yes. Still cleaning up that site some. Going to change the theme since it sucks on mobile. However the content is there.

zylox20:03:09

nope this is permanent now

zylox20:03:23

weve seen everything

ryanbrush21:03:01

@mikerod Okay, I'll resist the urge to tweet about it until you have the finishing touches in place. ๐Ÿ˜„

mikerod21:03:37

Haha. Thanks. I'll fix it within a day or so. Out of town so I'm a bit slow.