<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Logica-TGD: Transforming Graph Databases Logically</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Evgeny Skvortsov</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yilin Xia</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Bertram Ludäscher</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Shawn Bowers</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Gonzaga University, Department of Computer Science</institution>
          ,
          <addr-line>Spokane, WA</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Google LLC</institution>
          ,
          <addr-line>WA</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>University of Illinois Urbana-Champaign, School of Information Sciences</institution>
          ,
          <addr-line>IL</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Graph transformations are a powerful computational model for manipulating complex networks, but handling temporal aspects and scalability remain significant challenges. We present a novel approach to implementing these transformations using Logica, an open-source logic programming language and system that operates on parallel databases like DuckDB and BigQuery. Leveraging the parallelism of these engines, our method enhances performance and accessibility, while also ofering a practical way to handle time-varying graphs. We illustrate Logica's graph querying and transformation capabilities with several examples, including the computation of the well-founded solution to the classic “Win-Move” game, a declarative program for pathfinding in a dynamic graph, and the application of Logica to the collection of all current facts of Wikidata for taxonomic relations analysis. We argue that clear declarative syntax, built-in visualization and powerful supported engines make Logica a convenient tool for graph transformations.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;Logic rules</kwd>
        <kwd>graph queries</kwd>
        <kwd>graph transformations</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Graph transformations are a powerful and versatile method
for modeling and manipulating complex systems across
diverse fields, ranging from software engineering [
        <xref ref-type="bibr" rid="ref1 ref2">1, 2</xref>
        ] and
social network analysis [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] to biology and chemistry [
        <xref ref-type="bibr" rid="ref4 ref5 ref6">4, 5, 6</xref>
        ].
These transformations typically operate by applying rewrite
rules to a graph, altering its structure and properties. While
these transformations are known for their expressiveness
and flexibility, their implementation can often be complex,
especially when dealing with time-varying graphs or
requiring scalable solutions. Existing graph database systems
often provide limited support for such evolution mechanisms,
creating a gap between theoretical models and practical
implementations.
      </p>
      <p>
        Logic programming, on the other hand, provides a
declarative approach to problem solving by expressing rules and
relationships rather than explicitly stating control-flow.
Logic-based systems (e.g., Prolog and Answer Set
Programming [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]) are well-established in various areas, including
(symbolic) AI and knowledge representation and
reasoning. More recently, Logica (Logic + Aggregation) [
        <xref ref-type="bibr" rid="ref8 ref9">8, 9</xref>
        ], an
open-source logic programming language and system, has
emerged, which employs parallel data processing
environments such as DuckDB and BigQuery. Logica combines the
declarative power of logic programming with the scalability
and eficiency of modern databases, ofering a promising
new path for tackling graph transformation challenges.
      </p>
      <p>This paper explores the application of Logica to the
domain of graph transformations, bridging the gap between
these two paradigms. Our approach leverages Logica’s
ability to process large datasets in a parallel and eficient
manner, providing a novel means of implementing and
executing graph transformations at scale using logical rules. We
demonstrate that with a graph transformation mindset, logic
programming can provide a natural, powerful, and intuitive
approach for defining transformations, opening new
opportunities within both communities. Crucially, Logica also
enables a practical approach to addressing issues that are
dificult in classical graph transformation approaches, such
as temporal transformations and seamless scalability.</p>
      <p>
        To illustrate the practical nature of our approach, we
introduce several example Logica programs implementing
diferent types of graph transformations. Specifically, we
show how Logica can be used to define and perform basic
graph transformations including message passing, removing
transitively implied graph edges, and solving (i.e., labeling
or coloring) win-move graphs. We also introduce a novel
approach to time-aware pathfinding (e.g., [
        <xref ref-type="bibr" rid="ref10 ref11 ref12">10, 11, 12</xref>
        ]), directly
addressing the need for principled and tractable mechanisms
to handle evolving graph data, a notoriously dificult
problem in classical graph transformation approaches. These
examples serve both to show the expressiveness of our
approach, and to illustrate its potential benefits.
      </p>
      <p>The rest of this paper is structured as follows: Secion 2
provides an overview of Logica. Section 3 demonstrates how
to express graph transformations in Logica. We conclude in
Section 4 with a discussion of the limitations and potential
avenues for future research.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Logica Overview</title>
      <p>
        Logica is a freely available, open-source variant of Datalog
combining the declarative features of expressive rule-based
languages with aggregation. Logica is a descendant of
Yedalog [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ] and inherits several of its features including support
for aggregators, functional predicates, user-defined
functions, and complex data types. Logica also supports rules
involving recursion and negation. A key feature of the
implementation is that it converts programs into SQL. This
conversion can be configured by the user and rules can be
compiled into: (a) self-contained SQL scripts with fixed
recursion depth; or (b) Python-driven pipelines that chain
together SQL queries when deep recursion is needed.
      </p>
      <p>An overview of the Logica system is shown in Figure 1.
Developers can work with Logica from the command line
or via a Jupyter notebook. Programs can import functions
and other rules via a module system. Logica parses and
analyzes program files and produces a collection of SQL
queries in the dialect of the target database engine
(currently SQLite, DuckDB, PostgreSQL, or BigQuery). To help
manage diferences among platforms, Logica employs a type
inference engine to create correct SQL for each underlying
I mImppoortretedd</p>
      <p>Logica
e Logica
tm MMoodduuleless
s
y
S
e
il
’rsseFU SScQriLpt
shallow or
nonrecursive rules
Embedded DBs</p>
      <p>Logica Parser</p>
      <p>Type Inference Engine</p>
      <p>Logica Program Compiler
Rule Compiler</p>
      <p>Expression Compiler
deep recursion
DuckDB</p>
      <p>SQLite</p>
      <p>Logica Pipeline Object (SQL-query iteration)
CSV
File</p>
      <p>JSON
File</p>
      <p>Parquet
File</p>
      <p>Qi</p>
      <p>Logica Pipeline Driver (Python)
UI
Qi</p>
      <p>External DB Engines</p>
      <p>PostgreSQL
BigQuery
system. If the set of rules to be evaluated is non-recursive
(or if the user has indicated via a directive that a fixed-depth,
non-iterative recursion is suficient), a self-contained SQL
script is generated that can be directly executed. For
programs requiring deep recursion, Logica generates a pipeline
script that iteratively executes the generated SQL queries
stage-by-stage until a fixpoint or a user-defined termination
condition is reached.</p>
      <p>For long-running queries, users can monitor rule
execution in the Logica UI: predicate results are rendered as they
are being evaluated, so the user knows which (iterated)
relations are still running. This information can also be saved
and used for logging and profiling program execution.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Transforming Graphs with Logica</title>
      <p>In Logica, as in Prolog and Answer-Set Programming,
graphs can be naturally represented: Nodes are denoted
using unique identifiers and edges are represented as facts
about the nodes. Graphs can be represented as predicates
with two or more positional arguments. For example, a
simple directed graph can be represented as a binary relation
E(source,target), where source and target are nodes
connected by a directed edge. Additional graph data, e.g., node
or edge attributes, can be expressed using separate
predicates or extra positional (in Logica also named) arguments.
For instance, a graph whose edges are assigned colors can
be represented using a ternary predicate and facts of the
form E(source,target,color).</p>
      <p>Graph transformations can be implemented by defining
new predicates that depend on the original graph: e.g., given
a graph with edges E, a new graph E2 extending E by adding
new edges between nodes that are separated by two “hops”
can be derived as follows.1
This simple example demonstrates an important aspect of
defining graph transformations with logic rules. In native
graph transformation languages users define how the graph
changes, and edges not involved in the change remain.
However, when defining graph transformations logically, we
1In Logica, variables are lowercase, predicates are uppercase, “∼ ” is
used for negation, and semicolons denote the end of rules.
must include rules to preserve edges not involved in the
transformation (line 2).</p>
      <sec id="sec-3-1">
        <title>3.1. Message Passing</title>
        <p>
          Our first example involves the simple passing of a message
along the directed edges of a graph, as described in [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ].
1 M0(0); # start node
2 # Rule 1: Message initialization.
3 M(x) :- M=nil, M0(x);
4 # Rule 2: Message passing.
5 M(y) :- M(x), E(x, y);
6 # Rule 3: Message retention.
7 M(x) :- M(x), ~E(x, y);
Fact M0(0) states that initially the message is at node 0.
Rule 1 initializes the message relation M. It states that node
x has a message M if it was specified as the initial node
in M0(x). Condition M=nil makes the rule fire (trigger)
only at the start of the recursive iteration. The message
propagates from node x to its neighbors y through the Rule
2. Finally, Rule 3 requires the message of a node x to be
retained if x has no outgoing edges.
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>3.2. Computing Distances in a Graph</title>
        <p>Logica has native support for aggregation. Predicate level
aggregation is computed over the specified values of the
ifelds of the defined predicate. The following Logica
program computes the minimum distance D(x) of a node x
from a given Start node.
1 # Rule 1: Distance from the Start node is 0.
2 D(Start()) Min= 0;
3 # Rule 2: Triangle inequality.
4 D(y) Min= D(x) + 1 :- E(x,y);
Start() is used as a functional predicate: All Logica
relations have an additional “special attribute” (named
logica_value) to store and access a relation’s functional
value, i.e., its value when used syntactically as a function.
Here, Start() simply returns (a predefined) starting value.
Rule 1 assigns the distance 0 to the starting node, where
D(x) is also a functional predicate that returns the
(minimum) distance of a node x. Rule 2 computes the distance to
a node y as at most one more than the distance to its
predecessor x. The Min= aggregation operator specifies that the
minimum distance will be taken among all possible paths.</p>
      </sec>
      <sec id="sec-3-3">
        <title>3.3. Solving Win-Move Games</title>
        <p>
          Win-Move is a two-player combinatorial game played on
a finite directed graph (representing a board) where nodes
represent positions and edges represent moves [
          <xref ref-type="bibr" rid="ref15 ref16">15, 16</xref>
          ].
After choosing a starting position (node), the two players take
turns moving a game pebble along the edges of the graph.
A player who cannot move loses the game. We propose to
compute the solution to Win-Move games in a new way,
inspired by graph transformations. A concise formulation
of the game is given by the logic rule:
        </p>
        <p>Win(x) :- Move(x,y), ~Win(y).</p>
        <p>
          A solution to the game can be computed using the
3valued well-founded semantics [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ]. The moves of the game
are given by the predicate Move. A game starting at node x
is objectively won if there exists a (winning) move to some
y that is lost. Then, no matter how an opponent (Player II)
moves from y (assuming there is an outgoing move to begin
with), Player I can always force a win after the opponent
has moved. The well-founded model assigns Win(x) the
value true, false, and undefined if and only if x is objectively
won, lost, and drawn, respectively. In contrast, the 2-valued
stable model semantics does not compute the desired game
solution: There can be 0, 1, or more stable models, none of
which may agree with the correct, well-founded solution.
Similarly, in Logica, the above rule cannot be used as-is.
        </p>
        <p>Looking at the problem through a graph-transformation
lens, however, we can define a new predicate W(x,y),
indicating that the move from x to y is a winning move.
Computation of W, from a graph transformation perspective,
amounts to selecting a collection of winning moves. In
Logica this can be specified with a single rule:
1 W(x,y) :- Move(x,y), (Move(y,z1) =&gt; W(z1,z2));
The rule says: A move from x to y is winning if for every
opponent move from y to some z1 there exists a move from
z1 to z2 for Player I that is again winning! The logical
implication Move(y,z1) =&gt; W(z1,z2) is a shorthand for
the nested negation ~(Move(y,z1), ~W(z1,z2)).</p>
        <p>The position values can now be derived from the winning
moves W. The source and target nodes x and y of a winning
move are won and lost positions, respectively. Positions
that are neither won nor lost are drawn:
1 Won(x), Lost(y) :- W(x,y);
2 Drawn(x) :- Position(x), ~Won(x), ~Lost(x);
Here, the unary predicate position is defined as the union
of the domain and range of the Move relation:
1 Position(x) :- x in [a,b], Move(a,b);</p>
      </sec>
      <sec id="sec-3-4">
        <title>3.4. Finding Paths in Evolving Graphs</title>
        <p>
          Graphs that change over time [
          <xref ref-type="bibr" rid="ref10 ref11 ref12">10, 11, 12</xref>
          ] can be naturally
modeled and computed over in Logica, where time can
represented using extra positional arguments, named arguments,
or as functional values. As a simple example, assume a
graph that changes over time is represented by the relation
E(x,y,t0,t1) stating that there exists an edge from node
x to y added to the graph between time moments t0 and
t1. For simplicity we assume that time starts at moment 0,
edges are transitioned instantly, and the start node is given
as Start(). The following Logica program computes the
earliest possible arrival time for each node.
1 # Rule 1: Starting condition.
2 Arrival(Start()) Min= 0;
3 # Rule 2: Traversal of an edge when edge exists.
4 Arrival(y) Min= Greatest(Arrival(x),t0)
:5 E(x,y,t0,t1), Arrival(x) &lt;= t1;
        </p>
        <p>Rule 1 sets the arrival time of the start node to 0 (the
assumed initial time). Rule 2 considers edge transitions: if
we arrive at the source x of an edge before the edge expires
(given by t1) then the arrival time of the edge’s target y
is set to the larger (latest) of x’s arrival time and the time
t0 that the edge was added to the graph. Once the arrival
times are computed, additional rules can be easily added
to select specific (time aware) paths of the graph. Figure 2
gives an example of path finding over an evolving graph.
An initial graph (with nodes A, B, etc., and colored blue) is
given with edges labeled by their start and end times. The
start node A is shown in green. The computed arrival times
are displayed as additional nodes (in yellow). The graph
in Figure 2 was created within Logica as further described
below in Section 3.6.</p>
      </sec>
      <sec id="sec-3-5">
        <title>3.5. Transitive Reduction of DAGs</title>
        <p>
          The transitive reduction [
          <xref ref-type="bibr" rid="ref18">18</xref>
          ] of a directed graph is a graph
with the fewest possible edges that has the same
reachability as the original graph. For directed acyclic graphs
(DAGs), the transitive reduction coincides with finding the
(unique) minimum equivalent subgraph, i.e., a proper
subgraph with the fewest possible edges needed to maintain the
same reachability relation as the original graph. While
finding a minimum equivalent subgraph for (arbitrary) graphs
with cycles is NP-complete, for DAGs, the problem can be
solved in PTIME. The following Logica program computes
the transitive reduction TR(x,y) of a DAG given by the
edge relation E(x,y). The program first computes the
transitive closure and then uses the transitive closure to remove
redundant edges.
1 # Rule 1: Transitive closure base case.
2 TC(x,y) distinct:- E(x,y);
3 # Rule 2: Transitive closure inductive step.
4 TC(x,y) distinct:- TC(x,z), TC(z,y);
5 # Rule 3: Transitive reduction.
6 TR(x,y) :- E(x,y), ~(E(x,z), TC(z,y));
        </p>
        <p>Rules 1 and 2 compute the transitive closure. Rule 3
identifies edges E(x,y) in the original graph that cannot
be bypassed by going to some other node and taking a
transitive path from there. These edges are the essential
edges needed to maintain reachability and make up the
edges of the resulting transitive reduction graph TR.</p>
      </sec>
      <sec id="sec-3-6">
        <title>3.6. Rendering Graphs with Logica</title>
        <p>One of the benefits of Logica is the convenience of
rendering graphs directly from predicate definitions. With just a
few lines of Logica code and a minimal Python wrapper, it
is possible to generate visually appealing and informative
graph representations that highlight case-specific attributes.
For example, consider the transitive reduction computed
in the previous section. Instead of exporting the TR and
E predicates and configuring their rendering in a separate
graphing library, Logica makes it possible to define a
predicate that directly specifies the visual attributes of the graph.
The following relations define graph visualization
properties in Logica highlighting the edges in both the original
graph and its transitive reduction:
1 R(x, y,
2 arrows:"to" ,
3 color?Max= "rgba (40, 40, 40, 0.5)",
4 dashes?Min= true,
5 width?Max= 2,
6 physics?Max= false,
7 smooth?Max= false)distinct:- E(x, y);
8 R(x, y,
9 arrows:"to" ,
10 color?Max= "rgba (90, 30, 30, 1.0)",
11 dashes?Min= false,
12 width?Max= 4,
13 physics?Max= true,
14 smooth?Max= true)distinct:- TR(x, y);</p>
        <p>The R(x,y,. . . ) relation defines the edges of the graph
and their visual properties. The first rule draws the
original edges from E(x, y) in a light gray, dashed style with
a thin line. The second rule draws the transitive
reduction edges from TR(x, y) in bold red, solid lines. The
distinct keyword triggers aggregation, so that each edge
occurs only once and values of attributes such as color,
dashes, etc., are chosen based on whether this edge
belongs to the transitive reduction. The visual attributes, e.g.,
arrows, color, dashes, width, physics, and smooth,
are directly embedded within the Logica rules. The question
mark in “color? Max=” indicates that the color can have
diferent values from diferent rules. The Max= indicates
that if there are multiple rules that apply to the same edge,
the maximum value will be used. The actual rendering is
then handled with a Python function call:
1 # from logica.common import graph
2 graph.SimpleGraph(
3 R, extra_edges_columns=[
4 "arrows" ,"physics" ,"dashes" ,"smooth" ],
5 edge_color_column="color" ,
6 edge_width_column="width" )</p>
        <p>This code leverages Logica’s graph module. The
SimpleGraph function takes the R predicate,
speciifes which columns in R represent edge attributes
(using extra_edges_columns, edge_color_column, and
edge_width_column), and provides overall graph options.
The resulting visualization is shown in Figure 3 (where
the transitive reduction graph is overlaid over the original
graph). The tight integration between logical definitions
and graph rendering makes Logica a powerful tool for
analyzing and understanding complex relationships in graph
data. The ability to define graph properties directly in
Logica, rather than relying on external tools, can significantly
streamline the data exploration and visualization process.</p>
      </sec>
      <sec id="sec-3-7">
        <title>3.7. Graph Condensation</title>
        <p>
          Graph condensation [
          <xref ref-type="bibr" rid="ref19">19</xref>
          ] is a technique for simplifying a
graph by collapsing strongly connected components (SCCs)
into single nodes. This can be useful for visualizing the
overall structure of a graph and for performing analyses
that are less sensitive to the details within SCCs. In the
condensed graph, each node represents an SCC, and an
edge exists between two nodes if there is an edge in the
original graph between nodes in the corresponding SCCs.
        </p>
        <p>The following Logica program computes the
condensation of a graph given by edges defined by the E(x,y)
relation, and where all nodes are defined by a Node(x)
predicate. We assume that transitive closure is already computed
as in Subsection 3.5.
1 # Minimal node ID of the component
2 # ..is used as the component ID.
3 CC(x) Min= x :- Node(x);
4 CC(x) Min= y :- TC(x,y), TC(y,x);
5 # Compute condensation graph edges.
6 ECC(CC(x),CC(y))
distinct:7 E(x,y), CC(x)!=CC(y);</p>
        <p>Once the condensation is computed, it can be easily
rendered using Logica’s graph visualization capabilities. To
enhance readability, we use the following naming
conventions: nodes in the original graph are named directly with
their IDs (e.g., “1”, “2”, “3”), while the condensed
components are prefixed with “c-” (e.g., “c-1”, “c-2”). The predicate
definitions for rendering both the original and condensed
graphs simultaneously are as follows:
1 NodeName(x) = ToString(ToInt64(x));
2 CompName(x) = "c-"++ ToString(ToInt64(x));
3
4 # Edges of the original graph.
5 Render(NodeName(a), NodeName(b),
6 physics:true,arrows:"to" ,
7 dashes:false,smooth:true,
8 color:"#33e"):- E(a, b);
9 # Edges of the condensation.
10 Render(CompName(x), CompName(y),
11 physics:true,arrows:"to" ,
12 dashes:false,smooth:true,
13 color:"#33e"):- ECC(x, y);
14 # Mapping from the graph to
15 # the condensation.
16 Render(NodeName(ToInt64(a)), CompName(CC(a)),
17 physics:false,arrows:"to" ,
18 dashes:true,smooth:false,
19 color:"#888");
The NodeName and CompName functions convert node and
component IDs to strings with appropriate prefixes. The
Render predicate then defines the appearance of the graph:
• Edges in the original graph (defined by E) are rendered
as solid blue lines.
• Edges between components (defined by ECC) are also
rendered as solid blue lines.
• Dashed gray lines connect each original node to its
corresponding component. The physics is disabled between
nodes and their condensation components to help with
readability.</p>
        <p>Figure 4 shows the result of using the above Logica code
and the appropriate Python wrapper as described in
Subsection 3.6 to view the original and corresponding condensed
graph. By combining the power of Logica for defining graph
structures and relationships with its seamless graph
rendering capabilities, it is possible to gain valuable insights into
complex systems through clear and concise visualizations.</p>
      </sec>
      <sec id="sec-3-8">
        <title>3.8. Inferring a Taxonomic Tree</title>
        <p>Another application of Logica lies in its ability to infer
relationships from large datasets and represent them as
graphs. Consider the problem of constructing a simplified
taxonomic tree for a set of species, showing their
evolutionary relationships leading back to common ancestors.
Logica can perform this task on massive amounts of data.
Here, we aim to build a taxonomic tree for Homo sapiens
(humans), Crocodylidae (crocodiles), Tyrannosaurus (T-Rex),
and Columbidae (pigeons). The input is a knowledge graph
of triples T(,,) and a functional predicate L() = ℓ
that maps objects  to human readable labels ℓ. We
deifne SuperTaxon(item,parent) as the result of the query
T(item,"P171",parent), which states that parent is a direct
supertaxon of item, and TaxonLabel() = L() to give
labels restricted to taxons. The following Logica program
builds the taxonomic tree.
1 # Use unbounded depth (-1) to find ancestors.
2 @Recursive(E, -1, stop: FoundCommonAncestor);
3 E(x, item,
4 TaxonLabel(x), TaxonLabel(item))
distinct:5 SuperTaxon(item,x),
6 ItemOfInterest(item) | E(item);</p>
        <p>Figure 5 shows an example output from running the
program, where the GraphViz2 library is used to render the
resulting tree. The input for the example consisted of the set
of statements obtained by a dump of Wikidata, which
contained 806M facts defined over 89M objects. When stored
using DuckDB, the entire input is 13GB in size. The full
recursive search was run on a Google Cloud c2d-standard-32
instance in under 7 seconds via DuckDB with no custom
index setup. The majority of the execution time was spent
selecting the taxonomy edges from all possible relations in
Wikidata. Note that the number of taxons returned by the
original program is large. The result shown in Figure 5 is
only a sample of the obtained taxonomic tree (where the
sampling is also performed by Logica; not shown above).</p>
        <p>By expressing the problem in Logica, we leverage its
ability to eficiently perform (recursive) query processing (e.g.,
through its compilation to DuckDB). In this case, Logica is
used to quickly navigate the complex relationships within
a large taxonomic database and generate output that can
then be displayed visually through its Python integration
(here, using the GraphViz library).
2https://graphviz.org/</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusion</title>
      <p>We have presented a novel approach to implementing graph
transformations using Logica, a free and open-source logic
programming language designed for parallel databases.
While Logica is typically used for data processing and
analysis, we have shown that it can also efectively be used for
graph transformations. By leveraging Logica’s ability to
process large datasets in a parallel and eficient manner, graph
transformations can be performed eficiently. By
showcasing several examples, including the Win-Move problem,
dynamic path finding, transitive reduction, graph
condensation, and graph querying, we demonstrated that graph
transformation problems can be expressed in an intuitive
and eficient manner. The examples show how describing
graph transformations using logic rules can lead to
concise declarative specifications that also improve readability.
For example, our approach models time-varying graphs in
a principled manner, an issue that can be challenging in
classical graph transformation languages.</p>
      <p>In future work, we plan to explore more complex graph
transformation patterns, including rewritings that may
require solving NP-hard problems. We also plan to
benchmark our approach against other graph transformation tools,
which would be valuable for demonstrating Logica’s
performance advantages on real-world datasets.</p>
      <p>We hope that Logica, with its ability to leverage
underlying SQL engines, can make graph transformations a more
widely accessible and practical approach for managing
complex and dynamic data.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>F.</given-names>
            <surname>de la Parra</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Dean</surname>
          </string-name>
          ,
          <article-title>Survey of graph rewriting applied to model transformations</article-title>
          ,
          <source>in: International Conference on Model-Driven Engineering and Software Development</source>
          ,
          <year>2014</year>
          , pp.
          <fpage>431</fpage>
          -
          <lpage>441</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>T.</given-names>
            <surname>Kräuter</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Rutle</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>König</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Lamo</surname>
          </string-name>
          ,
          <article-title>Formalization and Analysis of BPMN Using Graph Transformation Systems</article-title>
          , in: International Conference on Graph Transformation,
          <year>2023</year>
          , p.
          <fpage>204</fpage>
          -
          <lpage>222</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>M.</given-names>
            <surname>Fernández</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Kirchner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Pinaud</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Vallet</surname>
          </string-name>
          ,
          <article-title>Labelled Graph Rewriting Meets Social Networks</article-title>
          ,
          <source>in: International Workshop on Rewriting Logic and Its Applications</source>
          , volume
          <volume>9942</volume>
          <source>of LNCS</source>
          , Springer,
          <year>2016</year>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>25</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>F.</given-names>
            <surname>Rosselló</surname>
          </string-name>
          , G. Valiente, Graph Transformation in Molecular Biology, Springer,
          <year>2005</year>
          , pp.
          <fpage>116</fpage>
          -
          <lpage>133</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>M.</given-names>
            <surname>Nagl</surname>
          </string-name>
          ,
          <article-title>Graph rewriting systems and their application in biology</article-title>
          ,
          <source>in: Mathematical Models in Medicine</source>
          , Springer,
          <year>1976</year>
          , pp.
          <fpage>135</fpage>
          -
          <lpage>156</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>F.</given-names>
            <surname>Rosselló</surname>
          </string-name>
          , G. Valiente, Chemical Graphs,
          <source>Chemical Reaction Graphs, and Chemical Graph Transformation, Electronic Notes in Theoretical Computer Science</source>
          <volume>127</volume>
          (
          <year>2005</year>
          )
          <fpage>157</fpage>
          -
          <lpage>166</lpage>
          .
          <source>Proceedings of the International Workshop on Graph-Based Tools.</source>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>M.</given-names>
            <surname>Gelfond</surname>
          </string-name>
          , Answer Sets, in: F. van
          <string-name>
            <surname>Harmelen</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          <string-name>
            <surname>Lifschitz</surname>
            ,
            <given-names>B. W.</given-names>
          </string-name>
          <string-name>
            <surname>Porter</surname>
          </string-name>
          (Eds.),
          <source>Handbook of Knowledge Representation, volume 3 of Foundations of Artificial Intelligence, Elsevier</source>
          ,
          <year>2008</year>
          , pp.
          <fpage>285</fpage>
          -
          <lpage>316</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>E. S.</given-names>
            <surname>Skvortsov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Xia</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Ludäscher</surname>
          </string-name>
          , Logica:
          <article-title>Declarative Data Science for Mere Mortals</article-title>
          , in: International Conference on Extending Database Technology,
          <year>2024</year>
          , pp.
          <fpage>842</fpage>
          -
          <lpage>845</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>E. S.</given-names>
            <surname>Skvortsov</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Xia</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Bowers</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Ludäscher</surname>
          </string-name>
          ,
          <article-title>The Logica System: Elevating SQL Databases to Declarative Data Science Engines</article-title>
          ,
          <source>in: International Workshop on the Resurgence of Datalog in Academia and Industry (Datalog-2.0)</source>
          , volume
          <volume>3801</volume>
          <source>of CEUR Workshop Proceedings</source>
          ,
          <year>2024</year>
          , pp.
          <fpage>69</fpage>
          -
          <lpage>73</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>D.</given-names>
            <surname>Kempe</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Kleinberg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Kumar</surname>
          </string-name>
          ,
          <article-title>Connectivity and inference problems for temporal networks</article-title>
          ,
          <source>J. Comput. Syst. Sci</source>
          .
          <volume>64</volume>
          (
          <year>2002</year>
          )
          <fpage>820</fpage>
          -
          <lpage>842</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>F.</given-names>
            <surname>Rosselló</surname>
          </string-name>
          , G. Valiente, Graph Transformation in Molecular Biology, Springer,
          <year>2005</year>
          , pp.
          <fpage>116</fpage>
          -
          <lpage>133</lpage>
          . URL: https://doi.org/10.1007/978-3-
          <fpage>540</fpage>
          -31847-
          <issue>7</issue>
          _
          <fpage>7</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>A.</given-names>
            <surname>Casteigts</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.-S.</given-names>
            <surname>Himmel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Molter</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Zschoche</surname>
          </string-name>
          ,
          <article-title>Finding Temporal Paths Under Waiting Time Constraints</article-title>
          ,
          <source>Algorithmica</source>
          <volume>83</volume>
          (
          <year>2021</year>
          )
          <fpage>2754</fpage>
          -
          <lpage>2802</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <given-names>B.</given-names>
            <surname>Chin</surname>
          </string-name>
          , D. von
          <string-name>
            <surname>Dincklage</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          <string-name>
            <surname>Ercegovac</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Hawkins</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <string-name>
            <surname>Miller</surname>
          </string-name>
          , et al.,
          <article-title>Yedalog: Exploring knowledge at scale</article-title>
          ,
          <source>Summit on Advances in Programming Languages</source>
          (
          <year>2015</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <given-names>B.</given-names>
            <surname>König</surname>
          </string-name>
          , Graph Transformation Meets Logic, GReTA - Graph
          <source>Transformation Theory and Applications Symposium</source>
          ,
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <surname>C.</surname>
          </string-name>
          <article-title>A. Smith, Graphs and composite games</article-title>
          ,
          <source>Journal of Combinatorial Theory</source>
          <volume>1</volume>
          (
          <year>1966</year>
          )
          <fpage>51</fpage>
          -
          <lpage>81</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <given-names>J.</given-names>
            <surname>Flum</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kubierschky</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Ludäscher</surname>
          </string-name>
          , Total and
          <string-name>
            <given-names>Partial</given-names>
            <surname>Well-Founded Datalog</surname>
          </string-name>
          Coincide,
          <source>in: Intl. Conf. on Database Theory (ICDT)</source>
          ,
          <source>LNCS 1186</source>
          , Springer,
          <year>1997</year>
          , pp.
          <fpage>113</fpage>
          -
          <lpage>124</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <surname>A. Van Gelder</surname>
            ,
            <given-names>K. A.</given-names>
          </string-name>
          <string-name>
            <surname>Ross</surname>
            ,
            <given-names>J. S.</given-names>
          </string-name>
          <string-name>
            <surname>Schlipf</surname>
          </string-name>
          ,
          <article-title>The Wellfounded Semantics for General Logic Programs</article-title>
          ,
          <source>Journal of the ACM</source>
          <volume>38</volume>
          (
          <year>1991</year>
          )
          <fpage>619</fpage>
          -
          <lpage>649</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <given-names>A. V.</given-names>
            <surname>Aho</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. R.</given-names>
            <surname>Garey</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. D.</given-names>
            <surname>Ullman</surname>
          </string-name>
          ,
          <article-title>The Transitive Reduction of a Directed Graph</article-title>
          ,
          <source>SIAM Journal on Computing</source>
          <volume>1</volume>
          (
          <year>1972</year>
          )
          <fpage>131</fpage>
          -
          <lpage>137</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <string-name>
            <given-names>R.</given-names>
            <surname>Tarjan</surname>
          </string-name>
          ,
          <string-name>
            <surname>Depth-First Search</surname>
          </string-name>
          and
          <article-title>Linear Graph Algorithms</article-title>
          ,
          <source>SIAM Journal on Computing</source>
          <volume>1</volume>
          (
          <year>1972</year>
          )
          <fpage>146</fpage>
          -
          <lpage>160</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>