Title: Logics for Graphs and Graph Transformations
1Logics for Graphs and Graph Transformations
- For course Logics for knowledge representation
and reasoning by Luciano Serafini. Aliaksei
Novikau.
2The plan
- What is Tropos
- Graph grammars String grammars
- String Grammars with more details
- Turing machines
- Graph Grammars different types
- MSO logic
- Transductions
- F-magma
- VR and HR grammars decidable
- Decidability of the task in common
- Conclusions
3Tropos Bresciani2003
- Tropos is based on two key ideas.
-
- First, the notion of agent and all related
mentalistic notions (for instance goals and
plans) are used in all phases of software
development, from early analysis down to the
actual implementation. - Second, Tropos covers also the very early phases
of requirements analysis, thus allowing for a
deeper understanding of the environment where the
software must operate, and of the kind of
interactions that should occur between software
and human agents.
4Tropos
5Tropos graph development rules
The rule for goal decomposition.
6Tropos - graph transformation approach advantages
- Requirement traceability history graph and saved
sequence of applied rules - Consistency of the developed diagram to a
metamodel because the set of the rules is
consistent with the metamodel - ???
7Graph Grammar
- Graph grammar Bardohl1999 G (L, T, S, P)
- L finit set of labels for nodes and edges
- T terminal symbols
- S an axiom, i.e., an initial graph
- P productions
- Each node, respectively edge, can be equipped
with an element of the label set. These element
can be used as types or as terminal or
nonterminal symbols. - The difference with a string grammar
concatenation
8String Grammars Matuszek1996
- A grammar G is a quadruple G (V, T, S, P)where
- V is a finite set of (meta)symbols, or variables.
- T is a finite set of terminal symbols.
- S is a distinguished element of V called the
start symbol. - P is a finite set of productions (or rules).
- A production has the form where
9String Grammars Regular Grammars
- In a right-linear grammar, all productions have
one of the two forms - V -gt TV or V -gt T
- In a left-linear grammar, all productions have
one of the two forms - V -gt VT or V -gt T
- A regular grammar is either a right-linear
grammar or a left-linear grammar. - Exmp. S -gt null
- S -gt a X
- X -gt S b is not a regular.
10String Grammars Regular Grammars, Finita
Automata
- Regular grammars are equal to regular expressians
and describe regular languages. Regular
expressions and grammars are equivalent to NFAs
(Nondeterministic Finita Automata) by doing two
things - For any given regular expression/grammar it is
possible to build an NFA that accepts the same
language and vice-versa. - The following automaton and
- grammar both recognize the
- set of strings consisting of an
- even number of 0's and an even
- number of 1's.
- S -gt null S -gt 0 B S -gt 1 AA -gt 0 C
A -gt 1 SB -gt 0 S B -gt 1 CC -gt 0 A C
-gt 1 B
11String Grammars Context-Free Grammars
- A grammar G (V, T, S, P) is a context free
grammar (cfg) if all productions in P have the
form - A -gt x, where
- A V, and
- x (V ? T)
- Since T?(V ? T) and TV?(V ? T), it follows
that every right-linear grammar is also a
context-free grammar, similary left-linear and
thus regular.
12String Grammars Context-Free Grammars,
Derivation Tree
- For example, for the following derivation the
tree will look like - S-gtABC-gtaABC-gtaABcC-gtaBcC-gtabBcC-gtabBc-gtabbBc-gtabb
c - A shape of the tree does not depend on
productions application.
13String Grammars Context-Free Grammars
- Chomsky Normal Form
- A -gt BC or A -gt a where A, B, and C are
variables and a is a terminal. Greibach Normal
Form - Greibach Normal Form
- A -gt ax where a is a terminal and x -gt V.
- Greibach Normal Form -gt proving the equivalence
of CFGs and NPDAs (the grammars are usually
ugly). - Any CFG can be put to Greibach, except containing
null.
14String Grammars Context-Free Grammars,
Nondeterministic Pushdown Automata
- An example of NPDA
- NPDAs recognises the
- same language as
- and Contextual-Free
- grammars.
- The explaining example
15String Grammars the Summarizing Table (The
Chomsky hierarchy)
16Turing Machine
- Turing machine uses a tape, infinite in both
directions. The tape consists of a series of
squares, each of which can hold a single symbol.
The tape head, or read-write head, can read a
symbol from the tape, write a symbol to the tape,
and move one square in either direction. Turing
machines can be deterministic or
nondeterministic. - Unlike the other automata, a Turing machine does
not read "input." Instead, there may be (and
usually are) symbols on the tape before the
Turing machine begins the Turing machine might
read some, all, or none of these symbols. The
initial tape may, if desired, be thought of as
"input." - The transition function of Turing machine
17Turing Machine
- Turing Machine can read a word from input, accept
it (come to accepting state), reject it (come to
rejection state) and buzz forever. The last case
Turing Machine Halt. - A Turing machine might halt for one input string,
but go into an infinite loop when given some
other string. The halting problem asks Is it
possible to tell, in general, whether a given
machine will halt for some given input? - It is possible to imitate a Turing machine by
another Turing (universal) machine. - Theorem. Turing machine
- WillHalt(M,w) does not exist.
- The proof is by appeared
- paradox.
- Many things proved by
- reduction to the halt problem.
18Turing Machine
- Turing machines - an attempt to formalize the
notion of an effective procedure ("algorithm").
The same time - Alonzo Church -- Lambda calculus
- Emil Post -- Production systems
- Raymond Smullyan -- Formal systems
- Stephen Kleene -- Recursive function theory
- Noam Chomsky -- Unrestricted grammars
- All of these formalisms were proved equivalent
to one another. - Turing's Thesis (weak form) A Turing machine can
compute anything that can be computed by a
general-purpose digital computer. - Turing's Thesis (strong form) A Turing machine
can compute anything that can be computed.
19Graph Grammars
- The main difference is concatenation.
- Bardohl1999 A visual programming language is a
programming language with at least some
constructs which have an either inherently or
superimposed multi-dimensional representation. - A string has only two members to concatenate to
(left and right), but a graph object has many
choices (dimensions). - Why can not we represent graph grammars as string
grammars (despite we can represent a graph as a
string)? - A graph change the string representation
unpedictably with some graph transformations
(applications of graph grammar productions)
20Graph Grammars
- Generally there are two main graph transformation
approaches single pushout and double pushout
Corradini1997. - If we have finite L?R then L LnR will be
defined and we can use single pushout
Single pushout
Double pushout
21Graph Grammars - Types
- Context-Free Vertex Replacement graph grammar
Engelfriet1997
22Graph Grammars - Types
- Context-Free Hypergraph Replacement graph grammar
Drewes1997 (Nassi-Shneiderman diagram example)
23Graph Grammars - Types
- Unrestricted graph grammars.
24And now - the subject
Logics!!!!
25Structures
- Relational structures (without functions)
- Ds the domain and (Rs) are the relations on
the domain p(R) is the arity of the relations -
- 1) Structure for strings
26Structures Courcelle1997
- 2) Structures for graphs.
- The first structure G1
- this structure can not express a graph with many
edges between two nodes - The second structure G2
27Logics
- First Order Logic decidable on finite sets but
not expressible enough - Second Order Logic the most expressible, but
undecidable in full its volume - Limitations on the SOL is Monadic Second Order
Logic!
28Monadic Second-Order Logic (MSO or MS)
- The subset of SOL but with quantifiers only on
unary relations (sets). So it consists of
formulas on a domain, fixed relations and
quantified sets, includes FOL quantifiers also. - The name monadic unary relations mono in
contrast to relations of higher arity
polyadic - The example. The MSO formula
expresses that a word in A has an odd
length. The property does not depend on letter
we do not use relations labx
29MSO
- There are different types of MSO logic
- MSO0 without FOL quantifiers but with relations
on sets and Sing() singleton function. Has the
same power (all expressions in MSO can be
expressed in MSO0). The Sing() function - The advantage it has simpler syntax.
- All the second order quantifiers can be shifted
in front of first order quantifiers. For example
is equivalent to - Now if such formula has only existentional
quantifiers in front of first order quantifiers
it is Existentional Monadic Second-Order formula
or EMSO formula. - And at lest weak MSO is MSO on finite sets.
30MSO
- An expressivity of the logic (the question which
properties we can express with it) depends on a
logic of course and on structures we apply the
logic and even on relation properties of the
structure (transitivity, reflexivity and
symmetry/asymetry/antysimmetry). - Which properties on graphs we can express with
MSO?
31MSO graph expressivity
- MSO with G1 structure can express
etc.
32MSO graph expressivity
- But MSO with G2 can express even more
- But!!! Another important question of a logic is
decidability. A theory on some structure is
decidable if it is recursive. -
33MSO recognizability and decidability
- There are two main theorems about decidability of
MSO logic Thomas1996 - Theorem 1 (Buchi, Elgot) A language of finite
words is recognizable by a finite automation iff
it is MSOS (another name S1S)- definable, and
both conversions, from automata to formulas and
vice versa, are effective. - MSOS or S1S is a MSO logic on structure with
one successor (binary relation). The consequence
of the theorem is equivalence of regular
languages (they are definable on S1S) and finita
automata.
34MSO recognizability and decidability
- Theorem 2 (Rabin Tree Theorem) The theory S2S
(MSO with 2 successor structure) is decidable. - This theorem is celebrated because many modal
logics like temporal or mu-calculus were proved
to be decidable because they can be expressed in
MSO on structures with 2-successors. - One of the structures is binary tree with two
childs 0successor and 1successor.
35Transductions Courcelle1997
- A binary relation where A and B
are sets (typically of words or trees) can be
considered as multivalued partial mapping
associating with certain elements of A one or
more elements of B. This is transduction A-gtB
(rational transduction in language theory). - There is no convenient notion of graph
transduction. But with interpretation we can
define transformations on structures. - The formulas defining a structure T inside
another one S (or k copies of S) will be MS
formula.
36Transductions Courcelle1997
- R and l - two finit ranked sets of relation
symbols, W set of variables (parameters). A
(R,l) definition scheme is a tulpe of formulas
37Transductions Courcelle1997
- The example
- Transduction that maps a word u in a,b to the
word u3. - The 3-coping definition scheme without
parameters is -
38F-magma Courcelle1997
- F-magma or f-algebra generalization of
context-free grammars for graphs. - Let S be a set of sorts, S-signature is a set F
with two mappings - A F-magma is
where Ms is a nonempty set called the domain
of sort s of M and for each f belonging to F the
object fM is a total mapping - - operations on M
-
-
39F-magma
- A term ts of some sort s is a combination of
functions f. - A polynomial system over F is a sequence of
equations S ltu1p1,,unpngt where u1un are
S-sorted variables or unknowns of S. Each term p
is polynomial i.e. term of the form null or
t1st2sstm. An operation s is like a union.
40F-magma an example
- The example is the context-free grammar
- The system of equations for the grammar will be
41F-magma, MSO and transductions
- If a transformation system can be described with
a sequence of equations of a f-magma and every
terminal can be described in MSO logic and there
is a transduction from the terminal to the final
sort can be formulated as MSO transduction then
the transformation system is recognizable. - Vertex Replacement and Hyperedge Replacement
transformation systems can be described in S2S
the way proposed above. So they are recognizable
and we can make model checking on them (the profe
is in Courcelle1997)
42Unrestricted Grammars and Turing Machines
- The initial task for Tropos
- We have an unrestricted grammar G and some
requirements to the language of the grammar R. Is
this a decidable task in common case? - Lets say we have a Turing machine for G (a
logical description or anything else) and we have
a Turing machine CheckGR(G,R) which should check
if the language of G if it is appropriate to the
requirements R as a string - According to the Turing machine halt problem this
task is undecidable for random G and R. -
43Conclusions
- It seems like there is logic description only for
VR and HR grammars. They are the easiest type of
graph grammars - But the task of checking a grammar G of arbitrary
kind is undecidable in common - I should look for some restrictions on the graph
grammar and the metamodel requirements to make
the task real.
44References
- Bresciani2003 Paolo Bresciani, Paolo Georgini,
Fausto Giunchiglia, John Mylopolous, Anna Perini,
Trpos An Agent-Oriented Software Development
Methodology, Jan 16 2003 - Bardohl1999 R. Bardohl and others, Application
of Graph Transformation to Visual Languages.
Handbook of Graph Grammars and Computing by Graph
Transformation, Volume 2. 1999. - Matuszek1996 David Matuszek, Syllabus for CSC
4170-50 Theory of Computation, 1996,
http//www.netaxs.com/people/nerp/automata/syllabu
s.html - Corradini1997 A. Corradini and others,
Algebraic Approach to Graph Transformation.
Handbook of Graph Grammars and Computing by Graph
Transformation, Volume 1. 1997. - Engelfriet1997 J. Engelfriet and others, Node
Replacement Graph Grammars. Handbook of Graph
Grammars and Computing by Graph Transformation,
Volume 1. 1997.
45References
- Drewes1997 F. Drewes and others, Hyperedge
Replacement Graph Grammars. Handbook of Graph
Grammars and Computing by Graph Transformation,
Volume 1. 1997. - Courcelle1997 B. Courcelle, The Expression of
Graph Properties and Graph Transformations in
Monadic Second-Order Logic. Handbook of Graph
Grammars and Computing by Graph Transformation,
Volume 1. 1997. - Thomas1996 Wolfgang Thomas, Languages,
Automata, and Logic. 1996.