-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to delay reduction until bindings are ready? #659
Comments
Maybe one could solve that problem by supporting guards, as in functional programming (see https://downloads.haskell.org/~ghc/5.02/docs/set/pattern-guards.html). For instance, in my case, one could write
where |
I will try looking to it. |
First I would like to list what happens here and why it fails. First (bc &kb (: $prf (0⍃' $x)) (S (S Z)))
=> (bc &kb (: $prfabs1 (-> (: $prfarg1 $prms1) (0⍃' $x))) (S Z))
==> (bc &kb (: $prfabs2 (-> (: $prfarg2 $prms2) (-> (: $prfarg1 $prms1) (0⍃' $x)))) Z) At this point recursive call is matched with the first
Here in Using |
Simple way of fixing it in this specific rule base is changing "CPU check" by removing proof only when we are sure the result is
This works successfully and returns:
|
I don't know how the proper general case fix show look like. On the one hand it is very similar to #546 raised by Alexey. Following this logic Another way is to code |
This implements you suggestion of proving parts in arbitrary order. It might still fail if there are dependencies between multiple CPU terms. Do do that we would need a Set type where order of elements is always the same even if added in different order (so it stays unifiable).
|
It is not required to keep elements in some predictable order to make Set type unifiable. One can introduce a grounded type Set with custom |
Describe the bug
The backward chainer requires the interpreter to be able to delay reduction under certain conditions, such as the arguments are fully grounded.
To Reproduce
Run the following MeTTa script
I tried to provide the simplest possible knowledge base, thus the moronic theory used here.
Expected behavior
It should output
Actual behavior
It outputs instead
Additional context
Without "minimal", the output is(let* (((: $prfabs#34 (-> (: $prfarg#35 $prms#38) (0⍃' $x))) (bc GroundingSpace-0x2b472b8 (: $prfabs#34 (-> (: $prfarg#35 $prms#38) (0⍃' $x))) (S Z))) ((: $prfarg#35 $prms#38) (bc GroundingSpace-0x2b472b8 (: $prfarg#35 $prms#38) (S Z)))) (: ($prfabs#34 $prfarg#35) (0⍃' $x)))
.!(bc &kb (: $prf (0⍃' 2)) (S (S Z)))
, meaning that$x
is already grounded, then the backward chainer is able to find the proof.is-closed
in the body of0<
, as followsNotReducible
may help but I did not succeed so far.The text was updated successfully, but these errors were encountered: