n-triples2kif.pl: a hack with some formal aspects

OK... so I made good on my hint/promise/threat to
hack something to convert n-triples to KIF;
it's just 138 lines of perl, including comments:

  #!/usr/bin/perl
  #
  # converts n-triples to KIF
  #
  # USAGE:
  #  perl n-triples2kif.pl <foo.nt > foo.kif
  #
  # REFERENCES
  #  n-triples:  working specification
  #    is a message I sent 30 May
  #   
http://lists.w3.org/Archives/Public/w3c-rdfcore-wg/2001May/0264.html
  #    ratified in RDF Core WG 1 Jun telcon
  #   
http://lists.w3.org/Archives/Public/w3c-rdfcore-wg/2001Jun/0008.html "
  #
  #  KIF
  #    Knowledge Interchange Format draft proposed American National
Standard (dpANS)
  #    NCITS.T2/98-004
  #    Last Modified: Thursday, 25-Jun-98 22:31:37 GMT 
  #    http://logic.stanford.edu/kif/dpans.html
  #
[...]
  # $Id: n-triples2kif.pl,v 1.4 2001/06/07 20:03:37 connolly Exp $
  http://www.w3.org/2000/10/swap/n-triples2kif.pl


As a test case, I converted the DAML ontology from RDF
syntax to n-triples syntax and then to KIF syntax:

  http://www.daml.org/2001/03/daml+oil
    -- cwm + bug-workarounds -->
  http://www.w3.org/2000/10/swap/test/dpo/dpo.nt
    -- n-triples2kif.pl -->
  http://www.w3.org/2000/10/swap/test/dpo/dpo.kif

dpo.kif looks like:

(exists (?x0 ?x2 ?x1 )
 (and 
  (PropertyValue
http\:\/\/www\.w3\.org\/1999\/02\/22\-rdf\-syntax\-ns\#type
     http\:\/\/www\.daml\.org\/2001\/03\/daml\+oil
     http\:\/\/www\.daml\.org\/2001\/03\/daml\+oil\#Ontology)
  (PropertyValue http\:\/\/www\.daml\.org\/2001\/03\/daml\+oil\#imports
     http\:\/\/www\.daml\.org\/2001\/03\/daml\+oil
     http\:\/\/www\.w3\.org\/2000\/01\/rdf\-schema)
[...]
  (PropertyValue http\:\/\/www\.daml\.org\/2001\/03\/daml\+oil\#first
     ?x0
     http\:\/\/www\.daml\.org\/2001\/03\/daml\+oil\#Nothing)
  (PropertyValue http\:\/\/www\.daml\.org\/2001\/03\/daml\+oil\#rest
     ?x0
     ?x1)
  (PropertyValue http\:\/\/www\.daml\.org\/2001\/03\/daml\+oil\#first
     ?x1
     ?x2)
  (PropertyValue http\:\/\/www\.daml\.org\/2001\/03\/daml\+oil\#rest
     ?x1
     http\:\/\/www\.daml\.org\/2001\/03\/daml\+oil\#nil)
) )

While n-triples is only designed to capture the RDF
abstract syntax/graph, converting to KIF syntax implies
an underlying semantics too. I believe these
semantics (the so-called existential conjunctive
fragment of first order logic) are, implicitly,
in the RDF 1.0 spec.

One aspect of the interpretation is that I use
the PropertyValue idiom (from the DAML axiomatic semantics)
rather than holds (from KIF itself) to keep RDF predicates
and classes as objects rather than making them two-place
and one-place relations, resp.

i.e. this is input to issues such as
  http://www.w3.org/2000/03/rdf-tracking/#rdf-formal-semantics
  http://www.w3.org/2000/03/rdf-tracking/#rdfms-resource-semantics
  http://www.w3.org/2000/03/rdf-tracking/#rdfms-identity-anon-resources

I hope to elaborate on exactly how this little hack addresses
those issues eventually, but I'm going to send just this
much for now.

-- 
Dan Connolly, W3C http://www.w3.org/People/Connolly/

Received on Thursday, 7 June 2001 16:09:26 UTC