# First Order Logic, First Order Logic + Recurrence and SQL

we know that SQL standard is equivalent to First Order Logic (FOL). I've seen at my lecture that graph connectivity cannot be expressed by FOL, so in SQL as well. But we know that we can easily solve that problem in PTIME. And I've seem the following table:

Query Language   Data Comp.   Expression Comp.
FOL              LOGSPACE     PSPACE
FP               PTIME        EXPTIME


I am not sure what is FP. But, I suppose that it is FIXPOINT. I mean, a first order logic with recursion + fixpoint.

I don't understand that table. I understand the Data Comp. But, I cannot what Expression Comp. means and why Expression Comp. for FP requires so much time.

• What's the source for the table? Have you asked them? Where did you see the table? What does "Data Comp." and "Expression Comp." mean? Is there any surrounding context? You're asking us to read the mind of the person who wrote that table, and we're more likely to be able to do that effectively if you can give us as much information about context as possible. – D.W. Jan 29 '18 at 17:43
• It looks like 'Data Comp.' is the data complexity and 'Expression Comp. ' is the combined complexity. In particular, the data complexity is measured with respect to determining if a fixed formula holds in a given structure A (so the structure is input), where the combined complexity takes both the formula and the structure as input. – Sam McGuire Jan 29 '18 at 17:49

## 1 Answer

Yes, FP will be first-order fixed-point logic.

Data complexity is the maximum complexity of the problem of evaluating a fixed formula of the logic on a database, as a function of the size of the database. Expression complexity (also known as formula complexity) is the complexity of evaluating a formula on a fixed database, as a function of the formula size (e.g., its length as a string of characters). Combined complexity, which isn't mentioned in your table, is the complexity of evaluating a formula on a database as a function of the size of those two things.

The expression complexity of first-order logic is high because, for example, a formula $\forall x_1\dots \forall x_k$ requires time $n^k$ to evaluate on a database of size $n$, so a formula of length $\ell$ can take time $n^\ell$, which is an exponential function of $\ell$ when $n$ is treated as a fixed constant. However, we can do this in polynomial space, since all we need to do is loop through potential values of variables and that requires storing just one value per variable.

• Database is an universum? – Carol Jan 29 '18 at 18:06
• "However, we can do this in polynomial space, since all we need to do is loop through potential values of variables and that requires storing just one value per variable." I don't understand. Before, you said that it requires exponential time and I agree with that. – Carol Jan 29 '18 at 18:07
• "Universum" isn't an English word so I'm not sure what you mean -- sorry! Programs can require exponential time and polynomial space. For example, for i=1 to 2^n do [...] takes time exponential in $n$ but you can store the loop variable using only $n$ bits, which is polynomial space. – David Richerby Jan 29 '18 at 18:16