<< Back to previous view

[LOGIC-102] generalize the notion of hash for robustness Created: 07/Jan/13  Updated: 28/Jul/13  Resolved: 07/Jan/13

Status: Closed
Project: core.logic
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Nada Amin Assignee: David Nolen
Resolution: Completed Votes: 0
Labels: None

Attachments: File logic-102.diff     File refactoring.diff    

 Description   

The second nom/hash throws an exception, because the nom/hash constraint is ran before the predc one.

(is (= (run* [q]
         (nom/fresh [x]
           (fresh [y]
             (predc y nom? `nom?)
             (nom/hash y x)
             (== y 'foo))))
      ()))

(is (= (run* [q]
         (nom/fresh [x]
           (fresh [y]
             (nom/hash y x)
             (predc y nom? `nom?)
             (== y 'foo))))
      ()))

Perhaps, we can generalize the notion of hash.



 Comments   
Comment by David Nolen [ 07/Jan/13 10:52 AM ]

Hmm but why throw in nom/hash like that instead of just failing?

Comment by David Nolen [ 07/Jan/13 10:59 AM ]

Closed wrong ticket

Comment by Nada Amin [ 07/Jan/13 11:11 AM ]

ok, seems reasonable to fail.

The fix to logic-101 is not entirely satisfactory, because we can now get constraints like _1#[_1]. so i think i also want to not use predc (but still use fixc), but have a custom constraint instead of the predc that takes the two rands into account.

implementing this now.

Comment by Nada Amin [ 07/Jan/13 12:39 PM ]

The patch logic-102.diff gives up on predc and fixc, and instead does a lot of ugly special-casing to cover the new TDD test cases.

Not too happy about this change...

Comment by David Nolen [ 07/Jan/13 1:23 PM ]

Is there something we could do to make it easier to rely on `fixc` and `predc`? Or is there some lacking feature of constraints?

Comment by David Nolen [ 07/Jan/13 1:52 PM ]

Also if you're OK w/ this patch, more than happy to move forward w/ this for now and it can be improved later.

Comment by Nada Amin [ 07/Jan/13 2:38 PM ]

OK, as discussed, please go ahead with the patch, and I'll think of some alternatives / refactoring soon.

Comment by David Nolen [ 07/Jan/13 7:06 PM ]

fixed, http://github.com/clojure/core.logic/commit/417246ad0d854f9f82ae3b5aeb566ea00249eb2c

Comment by Nada Amin [ 08/Jan/13 7:04 AM ]

refactoring.diff refactors the logic a bit. Hopefully it's more readable.

For now, it seems too much trouble for the gain to generalize hash or try to write it using more primitive constraints.

Comment by David Nolen [ 08/Jan/13 7:12 AM ]

Makes sense will apply later today.

Comment by Nada Amin [ 11/Mar/13 12:27 PM ]

I am going to apply the refactoring to master.

Comment by Nada Amin [ 11/Mar/13 12:30 PM ]

Applied in https://github.com/clojure/core.logic/commit/43d325bd8e3770f3483cc8be7d332adfae3a6a96

Generated at Thu Oct 23 13:44:13 CDT 2014 using JIRA 4.4#649-r158309.