Inductive Triple Graphs: A purely functional approach to represent RDF
Upcoming SlideShare
Loading in...5
×
 

Inductive Triple Graphs: A purely functional approach to represent RDF

on

  • 510 views

Slides of my presentation on 3rd International Workshop on Graph Structures for Knowledge Representation, part of the International Joint Conference on Artificial Intelligence, Beijing, China. 4 ...

Slides of my presentation on 3rd International Workshop on Graph Structures for Knowledge Representation, part of the International Joint Conference on Artificial Intelligence, Beijing, China. 4 August 2013

Statistics

Views

Total Views
510
Views on SlideShare
510
Embed Views
0

Actions

Likes
0
Downloads
4
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Inductive Triple Graphs: A purely functional approach to represent RDF Inductive Triple Graphs: A purely functional approach to represent RDF Presentation Transcript

  • Inductive Triple Graphs: A purely functional approach to represent RDF Johan Jeuring Utrecht University Open University of the Netherlands The Netherlands j.t.jeuring@uu.nl Jose María Álvarez Rodríguez South East European Research Center The Netherlands jmalvarez@seerc.org Jose Emilio Labra Gayo University of Oviedo Spain labra@uniovi.es
  • Motivation Combine Purely Functional Programming and Semantic Web? Purely Functional Programming Referential transparency Immutable datastructures Scalability Concurrency, parallelism Higher-order functions Combinators Program transformation . . . Semantic Web RDF Graphs URIs as properties Blank nodes Graph manipulation SPARQL Inference Big Data . . . 2 separate communities
  • This talk in one slide Review Inductive definitions of Graphs ...so we can use the same techniques as with lists ...this work was done by M. Erwig 1st Proposal: Inductive Triple graphs ...predicates can be subjects and objects ...no need for index handling (simplified API) 2nd Proposal: Inductive RDF Graphs ...based on inductive triple graphs ...higher-order functions like foldRDFGraph
  • Inductive Graphs Define the context of a node Nodes are uniquely identified by an Int key type Context a b = ([(Int,b)], ─ Predecessors Int, ─ Node index a, ─ Label [(Int,b)] ─ Succesors ) ([(1,'p')], 2, 'b', [(1,'q'), (3,'r')] ) Context of b = a c b p q r s 1 2 3
  • Inductive graphs data Graph a b = Empty | Context a b :& Graph a b ([(2,'r')] ,3,'c',[(1,'s')]) :& Empty ([] ,1,'a',[] ) :& ([(1,'p')] ,2,'b',[(1,'q')]) :& ([(2,'q'),(3,'s')],1,'a',[(2,'p')]) :& Empty ([], 3,'c',[] ) :& ([], 2,'b',[(3,'r')]) :& Same graph can be represented in different ways a c b p q r s 1 2 3 a c b p q r s 1 2 3
  • Inductive graphs FGL library Widely used in Haskell since 2001 Users of the library handle node indexes (Int values) It is possible to create bad formed graphs. Empty ([], 1,'a',[] ) :& ([], 2,'b',[(42,'p')]) :& ? a b1 2 42 ? p
  • Inductive Triple Graphs Simplified representation of Inductive Graphs 1st Proposal
  • Assumptions Each node/edge hava a label Labels are unique Label of an edge can also be the label of a node Motivation No need for node indexes Edges that can also be nodes a b r p q
  • Contexts Context of node: list of predecessors, successors and related nodes type TContext a = ( a, ─ Node [(a,a)], ─ Predecessors [(a,a)], ─ Successors [(a,a)] ─ Nodes Related ) a c b p q r s Context of b = ('b', [('a','p')], [('q','a'),('r','c')], [] ) Context of r = ('r',[],[],[('b','c')])
  • Inductive definition data TGraph a = Empty | TContext a :& TGraph a ('a',[],[('p','b')],[]) :& a b r p q ('p',[],[('q','r')],[]) :& a b r p q ('r',[('p','q')],[],[]) :& Empty ('p',[],[],[('a','b')]) :& Empty Same graph can also be represented in several ways
  • API In Haskell they are implemented as a type class Can be seen as an API that hides internal representation class TGr gr where empty ∷ gr a match ∷ a → gr a → (TContext a,gr a) mkGraph ∷ [(a,a,a)] → gr a nodes ∷ gr a → [a] extend ∷ TContext a → gr a → gr a ─ empty graph ─ decompose a graph ─ Graph from triples ─ nodes of a graph ─ extend a graph (:&)
  • Folds It is possible to define the Fold combinator over inductive triple graphs foldTGraph ∷ TGr gr ⇒ b → (TContext a → b → b) → gr a → b foldTGraph e f g = case nodes g of [] → e (n:_) → let (ctx,g') = match n g in f ctx (foldTGraph e f g') Fold is one of the most general combinators. Captures primitive recursion Lots of operations can be defined in terms of folds
  • Other operations Map rev ∷ (TGr gr) ⇒ gr a → gr a rev = mapTGraph swapCtx where swapCtx (n,pred,succ,rels) = (n,succ,pred,map swap rels) Reverse the edges in a graph mapTGraph ∷ (TGr gr) ⇒ (TContext a → TContext b) → gr a → gr b mapTGraph f = foldTGraph empty (λc g → extend (f c) g) Other examples... Depth First Search, Breadth First Search, topological sort, ...
  • Review Users don't need to be aware of node indexes Not possible to define graphs with errors Conversion Inductive graphs Triple inductive graphs Algorithm presented in paper Triple inductive graphs Inductive graphs Triple inductive graphs are implemented using FGL
  • Inductive RDF Graphs Based on Inductive Triple Graphs 2nd Proposal
  • RDF Graphs RDF model = graph made from triples (s,p,o) where: s = subject (URI or blanknode) p = predicate (URI) o = Object (URI, blanknode, literal) _1:p :b_2 @prefix : <http://example.org#> . :a :p _:1 . :a :p _:2 . _:1 :q :b . _:2 :r :b . :q :year 2013 . :a :p :q :r :year 2013 Turtle syntax
  • RDF Graphs 3 aspects: Predicates (URIs) can be subjects or objects Each node has a unique label (URI, literal, BNode Id) Blank nodes (BNodes) are locally scoped BNodes can be seen as existential values x:p :by ∃x∃y :a :p :q :r :year 2013
  • Definition RDF Graphs can be: Ground: Inductive Triple Graphs over Resources Blank nodes: Encode bNodes with logical variables data Resource = IRI String | Literal String | BNode BNodeId type BNodeId = Int data RDFGraph = Ground (TGraph Resource) | Exists (BNodeId → RDFGraph)
  • Example with bNodes x:p :by ∃x :a :p :q :r :year 2013 Exists (λx → Exists (λy → Ground ( (IRI "a",[],[(IRI "p",BNode x),(IRI "p",BNode y)],[]) :& (IRI "b",[(BNode x,IRI "q"),(BNode y,IRI "r")],[],[]) :& (IRI "q", [(IRI "year",Literal "2013")], [], []) :& Empty ))) ∃y
  • Some operations Some operations on RDF Graphs Fold RDF graphs mergeRDF ∷ RDFGraph → RDFGraph → RDFGraph mergeRDF g (Exists f) = Exists (λx → mergeRDF g (f x)) mergeRDF g (Basic g1) = foldTGraph g (λc g' → compRDF c g') g1 Merge 2 graphs foldRDFGraph ∷ a → (TContext Resource → a → a) → RDFGraph → a foldRDFGraph e h = foldRDFGraph' e h 0 where foldRDFGraph' e h s (Basic g) = foldTGraph e h g foldRDFGraph' e h s (Exists f) = foldRDFGrap' e h (s + 1) (f s)
  • Implementation Haskell Scala
  • Haskell Implementation Haskell implementation Available at GitHub: https://github.com/labra/haws 2 Implementations Using Church like encoding Based on the FGL library
  • Scala Implementation Based on Graph for Scala (Peter Empen) Available in GitHub https://github.com/labra/wesin Triple graphs are implemented as Hypergraph with 3- hyperedges a b r p q a b r p q e1 e2
  • Conclusions RDF graphs can be encoded using Inductive Triple Graphs Possible applications: Higher-order combinators: Folds, maps, etc. Program transformation and reasoning Concurrency Purely Functional Programming RDF Graphs
  • Future Work Inductive Triple Graphs Other domains? Inductive RDF Graphs Algebra of RDF Graphs RDF Graph Library Datatype Literals, Named graphs Implement Common RDF algorithms Normalization and comparison RDF Querying and traversal Real applications and performance comparisons
  • End of presentation