When AI Struggles to Find Answers: Why a Computer's 'Cooking Order' Matters

A robot finding its way through a complex, entangled maze of data
AI Summary

Discusses the 'nontermination' issue that occurs when using recursion in database query languages and the importance of control evaluation strategies.

Imagine you ask your assistant to ‘Find all the friends of my friends.’ The assistant checks the list of friends, then checks the friends of those friends. But what if the friend relationships form a cyclical structure, endlessly looping back on themselves? The assistant might spend their entire life on this task, never able to leave work, and you might never receive the results.

A similar situation occurs in computer science. When ‘recursion,’ a powerful method of calling oneself, is added to ‘Query Languages’ (languages used to retrieve or manipulate data) that we use to fetch information from databases, programs can get stuck in a state where they don’t terminate. Computer scientists call this the ‘nontermination’ problem.

Why Is This Important?

The smartphone apps and web services we use daily all execute countless database queries behind the scenes. If these queries don’t complete properly and continuously consume system resources, the app becomes ‘unresponsive.’ Especially today, AI services and recommendation systems deal with much more complex data structures to understand human relationships or information connections. The more intricately data is intertwined, the more critical it becomes for the computer to determine ‘from where and how to process the work,’ which is a core issue determining service stability.

Easy to Understand: The Secret of Evaluation Order

Simply put, the ‘Evaluation Strategy’ (the rules for calculating expressions) by which a computer processes commands is like a chef deciding the order of cooking. Source 6

For example, let’s assume you are preparing a meal to serve three invited friends.

  1. Left-to-right: Cook dishes one by one strictly in the order they appear on the menu.
  2. Nondeterministic: Cook based on the order ingredients become available, starting with whatever is at hand.
  3. Parallel ‘and’: Start all three dishes simultaneously, cooking them a little at a time.

When recursion is included in query languages, the order in which data is processed is crucial. Just as the outcome of a meal depends on the cooking order, a query can either successfully produce an answer or fall into an infinite loop depending on the strategy used. Source 1, Source 2

In the traditional database world, this concern was not largely necessary. Queries like SQL (traditional database languages) are ‘declarative.’ This means if a user simply requests ‘Give me this data,’ the database engine would figure out the most efficient order to retrieve it, making execution order an issue for the system itself. Source 5

However, things became complicated when recursion was introduced. Because recursion continuously calls itself, if not managed properly, it can lead to an infinite loop of self-calls. To address this, academia has been researching various evaluation strategies like left-to-right, nondeterministic, and parallel ‘and’ to figure out ‘how to make it stop.’ Source 3, Source 2

Current Situation: Where Do We Stand?

Currently, we are walking a tightrope between the ‘efficiency’ and ‘stability’ of query languages. Database engines optimize physical execution order to enhance performance, but they must also accurately maintain the logical outcome during this process. Source 4 Query language designers are refining sophisticated rules that ensure user-written code does not fall into infinite loops, while simultaneously delivering results quickly. Source 7

What’s Next?

The relationships within data are becoming increasingly complex. Especially as the AI models we encounter daily must connect vast amounts of information to provide answers, the ‘nontermination’ problem will be faced more frequently. In the future, technology that allows systems to automatically select the most efficient and safe ‘smart evaluation strategies’ for task termination, without developers needing to individually agonize over order, will become even more crucial. Source 1

A Look from MindTickleBytes’ AI Reporter

As data becomes more interconnected, the process of self-thinking to find answers to questions also becomes more complex. The concept of ‘evaluation order,’ which helps computers avoid getting lost, resembles our own methods for solving complex daily tasks. Our strategies of solving things step-by-step, handling multiple tasks concurrently, or tackling the most apparent issues first are mirrored within computers.

References

  1. Datalog Nontermination
  2. Evaluation order and nontermination in query languages
  3. Evaluation order and nontermination in query languages
  4. [Understanding the Run-Time Order of Evaluation in Query Processing by SAMI ARIDAL Medium](https://medium.com/@s.aridal/understanding-the-run-time-order-of-evaluation-in-query-processing-fe46e9dd9e61)
  5. Formal semantics and analysis of object queries
  6. Evaluation strategy - Wikipedia
  7. A Novel Evaluation of Query Processing and Optimization in DBMS – IJERT
Test Your Understanding
Q1. What is the primary cause of the 'nontermination' problem in query languages?
  • Too much data
  • When using recursion
  • Lack of evaluation strategy
Recursive structures call themselves repeatedly, so if conditions are not properly set, the program can fall into a nonterminating state.
Q2. Why was the evaluation order of query languages not critical in traditional relational databases?
  • SQL is very simple
  • Because queries are declarative
  • Little data
In the traditional relational world, queries were strongly 'declarative,' defining what to obtain, so the result was guaranteed regardless of the physical execution order.
Q3. What are the three evaluation strategies mentioned in the text for handling recursion?
  • Left-to-right, nondeterministic, parallel 'and'
  • Top-down, static, sequential
  • Random, priority-based, optimization-based
To solve the recursion problem in query languages, left-to-right, nondeterministic, and parallel 'and' strategies are discussed.
When AI Struggles to Find A...
0:00