[cl-unification-devel] a simpler example
Marco Antoniotti
marcoxa at cs.nyu.edu
Tue Jun 10 08:51:44 UTC 2008
On Jun 6, 2008, at 24:38 , Russell McManus wrote:
>
> Here are some examples:
>
> ;; this works
> (find-variable-value
> '?s
> (unify #T(list ?f ?s) '(a (b c))))
Yes.
>
> ;; this works
> (find-variable-value
> '?s1
> (unify #T(list ?f (?s1 ?s2)) '(a (b c))))
Yes.
>
> ;; this fails
> (find-variable-value
> '?s1
> (unify #T(list ?f (list ?s1 ?s2)) '(a (b c))))
As it should. What you want is
(unify #T(list ?f #T(list ?s1 ?s2)) '(a (b c)))
In your case you are trying to unify a template of type LIST with a
variable in FIRST and a list (LIST ?s1 ?s2) in SECOND. The second
element cannot unify with (B C), hence the failure.
>
> I was expecting the meaning of LIST to be the same whether
> it is encountered at top level in a template, or at a nested level.
>
> Is this a bug, or are my expectations wrong?
Sorry. It is your expectations. If you look at the most general
syntax for templates, you will see that it is #T(<type-spec> .
<stuff>). This is because it would be a nightmare to do otherwise.
Suppose you have a
(unify #T(list 42 (foo)) (list 42 (list 'foo)))
should unify. But is next you do
(defstruct foo a s d)
then
(unify #T(list 42 (foo)) (list 42 (list 'foo)))
may or may not unify pending interpretation.
Hope this clarifies things. Let me know if there are other pitfalls
or bugs in the code.
Cheers
Marco
>
--
Marco Antoniotti
More information about the cl-unification-devel
mailing list