summaryrefslogtreecommitdiff
path: root/README.org
blob: 96338308354e4ff2359ba540d7993313f19580e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
-*- 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).

* Overview
** RDF
** Parsing
** Querying with Datalog
* Caveats
** GOOPS

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]].

** Experimental

Things will break...🧪💥

* Todos
** Schemantic
*** 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.


*** TODO RDFS inference

Implement [[https://sci-hub.se/https://doi.org/10.1016/j.websem.2009.07.003][Simple and Efficient Minimal RDFS]] using Datalog.

** 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.
- [[http://rdf.js.org/data-model-spec/][RDF/JS: Data model specification]] :: An abstract specification of an RDF data model for interoperability between Javascript libraries. We use some ideas from the specification. In particular the fact that ~<iri>~, ~<literal>~ and ~<lvar>~ extend the ~<term>~ class.
- [[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.

** Datalog
*** 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.

*** Blogs

- [[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.

*** Implementations

**** Clojure

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.

**** Other

- [[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.

*** Extensions

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.
**