blob: 2f8ae8b53a123ddd0d05d65e281c69af24dd2235 (plain
-*- mode: org; coding: utf-8; -*-
#+TITLE: Guile Schemantic
A [[https://www.gnu.org/software/guile/][Guile]] library for the Semantic Web. Implements the Resource Description Framework (RDF).
** Querying with Datalog
Guile Schemantic uses GOOPS, the object oriented extension to Guile. This is an
experiment to improve developer ergonomics. For a Guile RDF library that does
not use GOOPS see the excellent [[https://framagit.org/tyreunom/guile-rdf][guile-rdf]].
Things will break...🧪💥
*** TODO Documentation
*** TODO Serialization
There are many serialization formats for RDF. Currently guile-schemantic only supports RDF/Turtle via guile-rdf.
It would be nice to support more formats and also be able to write out in different formats. Maybe one could use existing C libraries such as [[https://github.com/drobilla/serd][serd]] or [[http://librdf.org/raptor/][Raptor]].
*** TODO Blank Node Skolemization
An transducer that skolemizes Blank Nodes while parsing - deal with Blank Nodes before they enter. Possible Skolemization schemes:
- Random UUIDs
- Canonical labeling a la [[https://blabel.github.io/][blabel]] (preferable)
*** TODO Datatypes
**** TODO XSD Datatypes
**** TODO Parsing / Mapping from <generic-literal> to specific literals
While parsing it would be nice to parse into the most specific supported literal (e.g. literal with datatype ~xsd:integer~ should be parsed as a <xsd:literal> and not as a generic literal). This requires a mapping from datatype iri to appropriate literal class.
*** DONE RDFS inference
Implement [[https://sci-hub.se/https://doi.org/10.1016/j.websem.2009.07.003][Simple and Efficient Minimal RDFS]] using Datalog.
*** TODO Split into separate library
A Datalog library seems to be useful by itself.
*** TODO Documentation
*** TODO Sets
Currently we are using a make-shift set datatype based on VHahses (~(datalog vhash-set)~). It would be nice to just be able to use [[https://srfi.schemers.org/srfi-113/][SRFI-113]] (not yet in Guile).
*** TODO Negation
*** TODO Less naive evaluation
Explore things like Query-Sub-Query, Magic Sets et. al.
*** TODO GOOPS?
Maybe not necessary for the Datalog part. Probably even better without it...
* Inspiration and further reading
** RDF Libraries
Many existing RDF libraries served as inspiration:
- [[https://rdf-elixir.dev/][RDF.ex]] :: An Elixir RDF library that the author uses and thinks is great.
- [[https://github.com/cordawyn/schemantic-web][Schemantic Web]] :: A collection of tools related to the Semantic Web for Scheme48 (mostly portable). We stole the cool name from them...
- [[https://framagit.org/tyreunom/guile-rdf][Guile RDF]] :: Guile library for RDF. Guile-Schemantic uses the RDF/Turtle parser from Guile RDF.
*** Books & Papers
- [[https://personal.utdallas.edu/~gupta/courses/acl/papers/datalog-paper.pdf][What You Always Wanted to Know About Datalog (And Never Dared to Ask) (1989)]] :: A good first introduction to Datalog. Includes Deatalog semantics, relation to Prolog and relational algebra as well as illustrating optimization techniques used by Datalog compilers.
- [[http://libgen.rs/book/index.php?md5=CCBD7C8C89D6EB56219E030CD81BFDD2][Logic Programming and Databases]] :: An in-depth treatment of Datalog describing the semantics, relationship to relational algebra and Prolog. Gives an overview of inference algorithms as well as extensions. This served as reference when implementing this library.
- [[https://cs.uwaterloo.ca/~david/fdb/][Foundation of Databases]] :: Course and Book on Databases highlighting the logical foundations including Datalog.
- [[https://x775.net/2019/03/18/Introduction-to-Datalog.html][Introduction to Datalog]] :: A very nice introduction which goes into the different semantics of Datalog.
The Clojure community has embraced Datalog as a query language. The makers of the language have developed a database that uses Datalog as query language ([[https://www.datomic.com/][Datomic]]). Other (open-source) implementations exist:
- [[https://github.com/tonsky/datascript][datascript]] :: A Clojure/ClojureScript in-memory Datalog implementation.
- [[https://github.com/replikativ/datahike][datahike]] :: A durable Datalog database that started as a datascript port.
- [[https://github.com/c-cube/datalog][datalog (OCaml)]] :: An in-memory OCaml implementation of Datalog.
- [[https://docs.racket-lang.org/datalog/index.html][datalog (Racket)]] :: A Racket implementation of Datalog.
- [[https://abcdatalog.seas.harvard.edu/][AbcDatalog]] :: A Java implementation of Datalog that also supports stratified negation and has a nice GUI to play with.
- [[https://github.com/ramsdell/datalog][Datalog (C/Lua)]] :: A C/Lua implementation of Datalog.
A selection of extensions and applications of Datalog.
- [[https://drops.dagstuhl.de/opus/volltexte/2015/5017/pdf/7.pdf][Yedalog]] :: A Datalog implementation for massive scale data (compiles to MapReduce). One of the authors (Mark S. Miller) was at ActivityPub Conference 2019 and pointed me to this work.
- [[https://mobisocial.stanford.edu/papers/vldb14s.pdf][Distributed SociaLite: A Datalog-Based Language for Large-Scale Graph Analysis]] :: Datalog extension allowing parallel/distributed computation.