# Datalog Self Interpretation

According to https://link.springer.com/article/10.1007%2Fs001530050135 (Logics that define their own semantics, Imhof 1999) the logic FO[LFP] can define its own semantics, though the proof (of corollary 6.4) is somehow fuzzy. It is known from finite model theory that Datalog is equivalent to FO[LFP] (on ordered structures). Can someone help me see (at least partially) how to write a Datalog self-interpreter? The main difficulty is to express modus-ponens considering unification without involving existential variables in heads (i.e. variables in heads which don't appear in bodies and are understood to be existentially quantified).

Another related puzzle of mine is, if LFP's data complexity is P, and its query complexity is EXPTIME, how come it can interpret itself indeed? (I have no doubt that it can as the paper above supplied two different proofs for that. also we know that provably P!=EXPTIME)

For me, the paper is behind a paywall. So I can base this only on its abstract and your question.

I believe you have a point with your complexity doubts. I can see how to write an FO[LFP] self-interpreter, provided there is a way to handle large arities. In particular, the self-interpreter has a single, fixed, maximum arity and number of variables while the interpreted formulae should be unbounded with respect to arity and number of variables. I can see a few ways to go about that:

1. There is in fact not a single self-interpreter, but a family of such, indexed by maximum arity.

2. The structure that encodes the input (the formula plus the original structure) has in its domain not only (subformulae of the formula and) elements of the original structure, but also tuples of the original structure up to the required arity. Then, converting the original input into its encoding structure already imposes an exponential blowup.

3. For infinite structures, tuples can be encoded as single elements using a pairing function. On well-ordered structures, FO[LFP] can define (ordinal) arithmetic and hence such a pairing function. Possibly, the statement in the paper does not address finite structures at all?

For the Datalog self-interpreter, I suggest you start with a Datalog interpreter written in FO[LFP] and then convert that formula into a Datalog query.

• thanks, yes we can think of an interpreter per arity, and we (and the paper) rather consider only finite structures, so can also consider an interpreter per universe size. and ofc we'd like to avoid encoding all possible tuples (which would end up with polynomial rather exponential blowup), and the mentioned paper doesn't seem to require to encode them indeed – Troy McClure Mar 24 '19 at 21:35
{"ft_lang_label":"__label__en","ft_lang_prob":0.9446391,"math_prob":0.8942206,"size":908,"snap":"2020-24-2020-29","text_gpt3_token_len":214,"char_repetition_ratio":0.071902655,"word_repetition_ratio":0.0,"special_character_ratio":0.22687225,"punctuation_ratio":0.11176471,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9652943,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-06-05T05:06:53Z\",\"WARC-Record-ID\":\"<urn:uuid:78eee201-e173-4932-9355-c852f44e2e67>\",\"Content-Length\":\"142999\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7779bd4d-d1a0-46fd-b825-44ce35712f26>\",\"WARC-Concurrent-To\":\"<urn:uuid:d36b78de-954e-4cb4-8c28-848e112e7720>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://cs.stackexchange.com/questions/105854/datalog-self-interpretation\",\"WARC-Payload-Digest\":\"sha1:UHFS2SHHBFGVTYNOZKXTBSMALL72Z46B\",\"WARC-Block-Digest\":\"sha1:HMDUEDLG7KBV5QIYDFYSD6RLRBXH5XFM\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590348493151.92_warc_CC-MAIN-20200605045722-20200605075722-00321.warc.gz\"}"}