W3C home > Mailing lists > Public > public-cwm-talk@w3.org > January to March 2008

sudoku in SWAP

From: naudts guido <naudts_vannoten@yahoo.com>
Date: Fri, 29 Feb 2008 15:56:34 -0800 (PST)
To: cwm <public-cwm-talk@w3.org>
Message-ID: <155336.98723.qm@web36308.mail.mud.yahoo.com>

for those who are intrested:
the implementation of sudoku in swap
(it's only a grid of 3 X 3 but this can easily be extended):

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . 
@prefix owl: <http://www.w3.org/2002/07/owl#> . 
@prefix : <http://www.example.com/sudoku#> . 
@prefix log: <http://www.w3.org/2000/10/swap/log#>.
@prefix list: <http://www.w3.org/2000/10/swap/list#>.

:l1 :hasCells (:c11 :c12 :c13).
:l2 :hasCells (:c21 :c22 :c23).
:l3 :hasCells (:c31 :c32 :c33).
:l4 :hasCells (:c11 :c21 :c31).
:l5 :hasCells (:c12 :c22 :c32).
:l6 :hasCells (:c13 :c23 :c33).

:c11 :hasValue "1".
:c22 :hasValue "2".
:c33 :hasValue "3". 

{?l :hasCells ?L. ?x1 list:in ?L} => {?l :hasCell ?x1}.

{?x1 :hasValue ?V.?l :hasCell ?x1. ?l :hasCell ?x2. 
?x1 log:notEqualTo ?x2.} => {?x2 :notHasValue ?V}.

{?x :notHasValue "1". ?x :notHasValue "2"} => { ?x :hasValue "3"}.
{?x :notHasValue "1". ?x :notHasValue "3"} => { ?x :hasValue "2"}.
{?x :notHasValue "3". ?x :notHasValue "2" } => { ?x :hasValue "1"}.

and the query is:

?x :hasValue ?y.

I find this to be an intresting example of using what I call
a declarative negation: the negation of having a value is done by 
creating a negative predicate: :notHasValue. In the same sense we could replace
log:notEqualTo with declarations:
:c11 :notEqualTo :c12.  etc...
and in the rule:
?x1 :notEqualTo ?x2.
which will have the desired effect because there
will be no declaration: :c11 :notEqualTo :c11.
But surely the builtin is more easy to use.
Anyway, I think the point is that negation in logic can not be

With kind regards, 

Guido Naudts
Lic. zoologie
Adviseur Department of Justice
Secretarisdreef 5@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . 

2288 Bouwel 

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 
Received on Friday, 29 February 2008 23:56:48 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:01:05 UTC