🤖 AI Summary
This paper addresses the precise expressibility characterization of Monadic Second-Order (MSO) and Guarded Second-Order (GSO) logic over finite structures in terms of Datalog programs. To establish expressibility criteria, we introduce an existential pebble game, combined with homomorphism-closure analysis, Constraint Satisfaction Problem (CSP) modeling, and countably categorical structure theory. This yields the first necessary and sufficient conditions for MSO/GSO definability by Datalog. In particular, we prove that every complement-closed, homomorphism-closed GSO class must be a finite union of countably categorical CSPs. We further propose the notion of *canonical Datalog programs*, enabling the construction of width-bounded (l,k)-optimal inference programs for homomorphism-closed MSO/GSO classes—programs that are sound and maximally complete among all sound Datalog programs. Our results establish a tight correspondence between logical expressibility and Datalog’s computational power.
📝 Abstract
We characterise the sentences in Monadic Second-order Logic (MSO) that are over finite structures equivalent to a Datalog program, in terms of an existential pebble game. We also show that for every class C of finite structures that can be expressed in MSO and is closed under homomorphisms, and for all integers l,k, there exists a *canonical* Datalog program Pi of width (l,k), that is, a Datalog program of width (l,k) which is sound for C (i.e., Pi only derives the goal predicate on a finite structure A if A is in C) and with the property that Pi derives the goal predicate whenever *some* Datalog program of width (l,k) which is sound for C derives the goal predicate. The same characterisations also hold for Guarded Second-order Logic (GSO), which properly extends MSO. To prove our results, we show that every class C in GSO whose complement is closed under homomorphisms is a finite union of constraint satisfaction problems (CSPs) of countably categorical structures.