This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-18
Channels
- # admin-announcements (3)
- # announcements (7)
- # aws (1)
- # beginners (76)
- # boot (340)
- # cider (9)
- # clara (35)
- # cljs-dev (7)
- # cljsjs (16)
- # cljsrn (11)
- # clojars (1)
- # clojure (192)
- # clojure-dev (6)
- # clojure-madison (8)
- # clojure-russia (373)
- # clojurebridge (1)
- # clojured (9)
- # clojurescript (172)
- # community-development (1)
- # core-async (2)
- # cursive (7)
- # data-science (2)
- # datomic (12)
- # devcards (1)
- # dirac (63)
- # emacs (3)
- # events (10)
- # gsoc (3)
- # hoplon (1)
- # jobs (1)
- # juxt (20)
- # ldnclj (4)
- # lein-figwheel (12)
- # leiningen (1)
- # off-topic (21)
- # om (232)
- # onyx (64)
- # parinfer (8)
- # proton (21)
- # re-frame (8)
- # reagent (1)
- # ring (3)
- # ring-swagger (3)
- # slack-help (4)
- # spacemacs (6)
- # testing (3)
Heya @ryanbrush -- dumb question for you
Say I create a session, and insert 3 (->Temperature 100 "ABC") facts, and then retract (->Temperature 100 "ABC") once on that session
Are these top-level insert calls i.e. (clara.rules/insert session fact) or logical insertions and retractions? @devn
Logical retractions of equal facts from the same production currently have a truth maintenance bug; see https://github.com/rbrush/clara-rules/issues/171
session (-> (mk-session [grouping-query
grouping-convert-query])
(insert-all [(->Temperature 30 "MCI")
(->Temperature 10 "MCI")
(->Temperature 80 "MCI")
(->Temperature 80 "MCI")]))
retracted-session (-> session
(retract (->Temperature 80 "MCI")
(->Temperature 80 "MCI")))
So you insert 2 temperatures of 80 and then retract 2 of them; I’d expect there to be none left
I guess I halfway expected that, for instance, some deeper identity of a fact beyond just its equality with a corresponding fact in the session would have some bearing.
So if I bound (->Temperature 80 "MCI")
to high-temp
, and then used high-temp
twice in the insert-all
I was surprised, but I guess after thinking about it, it doesn't really matter which of the facts is retracted.
Yeah, at least for now I think the memory just uses equality and retracts one each time
https://github.com/rbrush/clara-rules/blob/master/src/main/clojure/clara/rules/memory.cljc
I was thinking that you know, under the covers, an instance of (-> Foo 1)
would have an object ID or something taken into account underneath
https://github.com/rbrush/clara-rules/pull/164/files#diff-d16f31f970a20e4115932869c9aa825dR310
@wparker: reading through the issue you filed, and thinking "boy, generative tests in this case would make a lot of sense."
I’m not super familiar with how accumulators work in the engine, but one thing to keep in mind there is that reduce-to-accum creates a retraction function
https://github.com/rbrush/clara-rules/blob/master/src/main/clojure/clara/rules/accumulators.cljc#L91
Regarding generative tests: that could be helpful, but I haven’t come up with any good ideas on how to make them (I haven’t thought about it that deeply though).
@wparker @devn A good suite of generative tests would be great, and may have found a number of issues in logical edge cases. This would require generating rules with different criteria and ensuring consistency to really do well, and how to do so doesn't seem obvious. But I like the thought if anyone wants to play with it.
As for retraction, Clara used Clojure equality semantics by design. This seems like the least surprising behavior to treat facts as values....just like the number 1 is 1 no matter what its "identity". Seems like the Clojure way to me, and is analogous to removing an item from a map or set.