Are there any guarantees for upper bounds on the time complexity of the standard Prolog predicates?
For example: is it certain that sort(+List, ?SortedList)
runs in O(nlog(n)) time (n being the length of List
) in any standard compliant Prolog system?
tl;dr: No and no.
Let's start with
sort/2
which ideally would need n ld(n) comparisons. Fine, but how long does one comparison take? Let's try this out:On SICStus 4.3.1 and SWI 7.1.28
By duplicating the size we can easily estimate what the runtime will be. If it duplicates as well, it is linear, and if it quadruples it is quadratic. Clearly both have at least quadratic runtime.
Describing the precise runtime in an abstract manner might be possible, but it is very difficult to ensure that everything is fine. In any case, it is next-to-impossible to mandate a concrete promise in a standard document. Also, it is very difficult to validate such claims.
The best abstract measure might be the number of inferences, often they can be easily observed. See the largest integer or factors. But again, this is only an abstract measure - so something has been torn away, abstraxit. It might very well be the case that the key features have been torn away too.
In general, the ISO standard ISO/IEC 13211-1:1995 core, does not mandate any guarantee for runtime complexities which are clearly out of scope. It mentions explicitly in a note that also resource limits are out of scope:
Always remember that a technical standard is a precondition to ensure that a system is fit for some purpose. It is not a sufficient condition. See the example under Purpose in this answer for a somewhat extreme example.