clara

http://www.clara-rules.org/
cfleming 2017-12-22T02:02:50.000138Z

Is Clara’s fact destructuring as described here: http://www.clara-rules.org/docs/expressions/ the same as Clojure’s destructuring?

2017-12-22T02:17:35.000115Z

@cfleming the part of the syntax shown there uses Clojure destructuring. It basically ends up being a clojure function arglist that takes a single object.

2017-12-22T02:18:00.000068Z

But yes. It just “flows through” to standard destructuring.

cfleming 2017-12-22T02:18:04.000011Z

Ok, great, thanks.

2017-12-22T02:18:40.000127Z

No problem.

cfleming 2017-12-22T02:24:19.000080Z

@mikerod One more question while I have you - in the doc, is FACT_CONSTRAINT always a Fact Expression as defined in the doc, or is it any condition?

cfleming 2017-12-22T02:25:05.000172Z

(I’m working on specs for the Clara macros right now)

2017-12-22T02:27:25.000032Z

taking a look

2017-12-22T02:28:40.000124Z

I don’t see a FACT_CONSTRAINT referenced in http://www.clara-rules.org/docs/expressions/ ?

2017-12-22T02:28:51.000116Z

nevermind see it

cfleming 2017-12-22T02:29:12.000005Z

It’s in Boolean Expressions and also Accumulators

2017-12-22T02:30:43.000072Z

Ok, it is a fact expression as referred to above

cfleming 2017-12-22T02:31:00.000016Z

Great, thanks.

cfleming 2017-12-22T02:31:29.000224Z

Hopefully I’ll have something basic working soon, I’ll push it for comments - there are still a bunch of TODOs in there.

2017-12-22T02:31:52.000091Z

There may be times when it is odd to do something like bind a fact to a variable, but I think the syntax typically allows these cases - even if they don’t end up being useful.

2017-12-22T02:31:58.000008Z

That is cool. Sounds interesting

2017-12-22T02:32:15.000058Z

I’ll try to give a look at it too once you have it out there.

cfleming 2017-12-22T02:32:22.000148Z

Great, thanks - this is re: https://github.com/cerner/clara-rules/issues/367

2017-12-22T02:32:23.000008Z

I’m still catching up on the GitHub conversation from earlier

cfleming 2017-12-22T02:32:37.000158Z

Cool, no rush.

cfleming 2017-12-22T03:09:39.000106Z

I’ve pushed https://github.com/cursive-ide/clara-specs

cfleming 2017-12-22T03:10:22.000151Z

It contains a first cut at specs to match the macros in the Clara DSL - they match all the examples from the documentation correctly as far as I can tell.

cfleming 2017-12-22T03:10:45.000062Z

There are still some TODOs in there which weren’t clear to me from the doc, mostly stubbed out with any?

cfleming 2017-12-22T03:11:11.000176Z

My next task is to try it on the clara-examples repo and make sure it works for the examples there too.

🎉 1
cfleming 2017-12-22T03:12:04.000061Z

@alex-dixon @mikerod ^^ FYI

2017-12-22T03:19:05.000078Z

@cfleming nice. This is looking pretty good. I have looked over it fairly quick. I see a few things to tweak but mostly it is looking pretty close to what I’d think is right

cfleming 2017-12-22T03:19:53.000204Z

Great, thanks - feel free to file an issue or just let me know what to change and I’ll update it.

cfleming 2017-12-22T03:21:11.000075Z

I’ll have to figure out how the symbol resolution should work for unification variables too.

cfleming 2017-12-22T03:21:23.000147Z

(in Cursive, that is, not required for the specs).

2017-12-22T03:21:57.000092Z

Tomorrow I can give some better notes. A GitHub issue there perhaps to hold them.

2017-12-22T03:22:20.000041Z

Easier things: the LHS can have 0 conditions.

cfleming 2017-12-22T03:22:31.000023Z

Great, thanks. I’m going to be in and out over the holiday period but I’ll try to get it fixed up when I get a moment.

2017-12-22T03:22:32.000200Z

The RHS can have multiple forms now I believe.

cfleming 2017-12-22T03:22:46.000163Z

Ok, so the RHS is like a body?

2017-12-22T03:23:11.000097Z

Fact type really can be like anything. So that’s a harder one I think.

2017-12-22T03:23:32.000138Z

Yeah RHS is just like an implicit do

2017-12-22T03:23:35.000049Z

Block

cfleming 2017-12-22T03:23:39.000087Z

Ok.

cfleming 2017-12-22T03:24:16.000031Z

But I guess it should always have at least one form?

2017-12-22T03:24:39.000131Z

Yeah I believe the RHS needs at least one form.

2017-12-22T03:25:00.000102Z

If it didn’t it wouldn’t be a useful rule at least. Hah

cfleming 2017-12-22T03:25:40.000139Z

Hehe

2017-12-22T03:25:54.000106Z

Thanks for trying this out!

cfleming 2017-12-22T03:26:13.000003Z

Also, in the defquery doc it shows CONDITION repeated inside []

2017-12-22T19:14:17.000377Z

This is just a mistake in the docs. it should be the same as a rule in this part of a query

cfleming 2017-12-23T02:08:13.000063Z

Great, thanks Mike

cfleming 2017-12-23T02:09:08.000072Z

Looks like these are pretty close to correct then. Thanks for the great doc, a few ambiguities and mistakes like the above aside, it was great and really helpful in making these.

cfleming 2017-12-23T02:09:30.000083Z

Once these are done perhaps the doc could be created from them in the future.

2017-12-23T02:23:56.000085Z

Yeah t is looking good. I agree too that it would be nice to align the docs to it potentially could help ensure they stay correct too.

2017-12-23T02:25:20.000103Z

So I guess we need to figure out how to go about getting the specs in the repo. I think it’d be good to hear some feedback from at least @wparker on it too. He is on vacation and traveling a bit I believe (common for many right now in US). That’s probably why he hasn’t said much on the subject yet.

cfleming 2017-12-23T02:26:11.000014Z

Ok, no problem. They could be provided as a separate clara-specs artifact, too, if getting them in the main repo were undesirable.

2017-12-23T02:27:30.000166Z

Yeah a separate artifact is easy enough. I am thinking the main repo may be a good place too though. I just wanted to hear a bit of feedback from others there. It looks like it could be like an optional require sort of thing too so it wouldn’t mean that Clara couldn’t still support older clj for those not using it yet.

cfleming 2017-12-23T02:28:03.000026Z

Right, as long as users on <=1.8 don’t require that ns, they won’t have a problem.

2017-12-23T02:28:14.000056Z

Clara already has an “optional” sort of dependency on Fressian (for a default durability layer impl). So it wouldn’t be the first of that sort.

2017-12-23T02:28:56.000059Z

We should reference your repo in the github issue on Clara related to this spec’ing too to be sure everyone sees it

2017-12-23T02:31:13.000065Z

I’m sure people will like to get some cursive support from this too. That seems like it could be really useful

cfleming 2017-12-23T02:31:53.000067Z

Yeah, Cerner are big Cursive users so it will help a lot of people there (and elsewhere) I think.

cfleming 2017-12-23T02:32:32.000049Z

I’ll probably have some questions about how the symbol resolution in conditions works too, once I get that far.

cfleming 2017-12-23T02:32:45.000096Z

That looks a little tricky.

2017-12-23T02:33:20.000029Z

Yeah it sounds like there is a good audience for it. It is a good way to get the cursive functionality some good exposure and perhaps testing too.

2017-12-23T02:34:10.000094Z

Yeah. Let me know if you have any questions about Clara concerning that. I can try to assist with what I can in terms of Clara semantics or whatever.

cfleming 2017-12-23T02:35:13.000081Z

Great, thanks. I’m unlikely to get much done until the beginning of Jan now, but I might tinker a bit over the holidays.

2017-12-23T02:36:13.000048Z

Sounds good

cfleming 2017-12-23T02:37:04.000032Z

Thanks for all the help, and happy holidays!

2017-12-23T02:37:15.000068Z

Thanks. You too!

cfleming 2017-12-22T03:26:42.000194Z

I’m not sure what that’s supposed to look like, the examples don’t have repeated vectors inside that.

2017-12-22T03:26:56.000025Z

I’ll have to check that one out.

cfleming 2017-12-22T03:27:02.000102Z

Ok, thanks.

cfleming 2017-12-22T03:27:52.000091Z

Ok, I’ve got to step out now, thanks for the feedback! It’s already Friday afternoon here so if you can file an issue or something with any further feedback I’ll get to it when I can.

2017-12-22T03:28:54.000047Z

Sounds good. Thursday night here. Hah. I’ll see what else I can point on there likely tomorrow morning.

cfleming 2017-12-22T03:29:05.000043Z

Perfect, thanks Mike!

👍 1
amarjeet 2017-12-22T12:31:05.000132Z

@mikerod I experimented after your notes. Have better understanding now. Your note helped 🙂

souenzzo 2017-12-22T13:31:58.000282Z

There is docs about props? http://www.clara-rules.org/docs/rules/ :salience is the unique "relevant" value inside this map?

2017-12-22T14:15:56.000322Z

@souenzzo I’m not sure if there are docs about all props

👍 1
2017-12-22T14:16:17.000306Z

It is a map of keyword to anything. :salience is one supported one. The only other I can think of is :no-loop

2017-12-22T14:18:00.000212Z

and usually you shouldn’t need to worry about :no-loop

souenzzo 2017-12-22T14:25:53.000490Z

I'm annotating some data to use on inspect. outside a name conflict, should not be a problem, right?

2017-12-22T14:26:52.000495Z

You want to put additional information in the props map for your own purposes you mean?

souenzzo 2017-12-22T14:27:00.000181Z

Yep

2017-12-22T14:27:12.000622Z

I think that should be ok. You probably want to do something like use namespaced keywords though as keys

👍 1
alex-dixon 2017-12-22T18:14:25.000074Z

@mikerod Could no loop could be used as a modify? Like if I wanted to increment each match at most once per fire rules?

2017-12-22T18:35:56.000376Z

@alex-dixon like:

2017-12-22T18:36:01.000012Z

(r/defrule demo
  {:no-loop true}
  [?a &lt;- A]
  =&gt;
  (r/insert! (update ?a :some-val inc)))

2017-12-22T18:36:02.000450Z

?

2017-12-22T18:36:36.000448Z

and perhaps with a RHS (r/retract! ?a) before - actually not sure on this part - it is a secondary part of the question

alex-dixon 2017-12-22T18:40:48.000119Z

With retract yeah. To simulate mutation

2017-12-22T18:50:00.000373Z

It may be feasible, something you’d want to be careful for proliferating everywhere

2017-12-22T18:50:17.000101Z

with r/retract! I actually dont’ know

2017-12-22T18:50:36.000381Z

I can’t remember if :no-loop will stop a truth maintenance retraction sort of loop - perhaps you’ve tried?

2017-12-22T18:51:54.000033Z

I’ve mentioned on here before as well, if you don’t have a big concern with an always growing set of facts in working memory, you don’t need to retract. You can just “modify” and only base downstream logic on the “latest”

2017-12-22T18:52:38.000176Z

however, for something long running or with many of these changes, memory use would get too high

alex-dixon 2017-12-22T22:20:02.000074Z

@mikerod This is the first I’ve heard of no loop! I’m excited by it. Here’s an issue you raised a few years ago, looks like it led to truth maintenance being brought under the “no loop” umbrella as well: https://github.com/cerner/clara-rules/issues/99

2017-12-22T23:04:42.000143Z

@alex-dixon oh nice. The memory has returned to me now (after reading that issue and comments again) hah

2017-12-22T23:05:36.000025Z

It’d be interesting to see how doing something like you said would go then

2017-12-22T23:05:43.000058Z

if you retract the fact and insert the updated version of it

2017-12-22T23:06:26.000151Z

then all other rules that were based (or transitively based) only that removed fact would be retracted. However, the new updated version of the fact would then be available to rebuild those downstream results

2017-12-22T23:06:31.000058Z

That ma work out alright.

2017-12-22T23:10:38.000013Z

@alex-dixon but be aware there are some edge cases to RHS retracts still.

alex-dixon 2017-12-22T23:18:42.000020Z

I’m trying to understand the difference with that behavior and insert logical vs insert unconditional with an explicit retraction….kind of a head spinner. It seems a lot of the landmines and complexity are tied up with insert logical. Would you agree?

2017-12-22T23:35:37.000171Z

@alex-dixon Hmm. I think sticking to all logical insert is a reduction of complexity

2017-12-22T23:36:07.000030Z

There are just cases when it is difficult to express what you want with only the built-in logical truth maintenance.

2017-12-22T23:36:44.000010Z

Doing things like unconditional insert and RHS retracts are subversions to the truth maintenance system (aka TMS). With that comes difficulty

2017-12-22T23:37:27.000001Z

The reason TMS and logical insertion are so useful is that they allow for a much larger degree of rule order evaluation independence.

2017-12-22T23:37:51.000178Z

I think what Clara may be lacking most is a way to explicitly “update” a fact.

2017-12-22T23:38:25.000029Z

The more I think of it coming up, the more it seems like it’d be a nice first-class thing that ensured that it had well defined semantics with how it interacted with TMS.

2017-12-22T23:39:25.000168Z

However, I have mentioned before, that you can also make an external process that handles “updates” or retractions - leaving the rules part all logical insert + TMS.

2017-12-22T23:39:48.000030Z

However, that is still a manual thing right now. I’ve posted on here a few times what that sort of thing looks like though.