Occurs check

Occurs check

In computer science, the occurs check is a part of algorithms for syntactic unification. It causes unification of a logic variable V and a structure S to fail if S contains V.

In theorem proving, unification without the occurs check can lead to unsound inference. For example, the Prolog goal

X = f(X).

will succeed, binding X to a cyclic structure. Clearly however, if f is taken to stand for a function rather than a constructor, then the above equality is only valid if f is the identity function.

By default, Prolog implementations omit the occurs check for reasons of efficiency. The worst case complexity of unifying term1 with term2

O(max(size(term1), size(term2)))

is reduced without occurs check to

O(min(size(term1), size(term2)))

In the frequent case of variable-term unifications, an O(size(term)) runtime shrinks to O(1).

A naive omission of the occurs check leads to the creation of cyclic structures and may cause unification to loop forever. Modern implementations use rational tree unification to avoid looping.

ISO Prolog implementations have the built-in predicate unify_with_occurs_check/2 for sound unification but are free to use unsound or even looping algorithms when unification is invoked otherwise. Implementations offering sound unification for all unifications (optionally, via a runtime flag) are ECLiPSe and SWI-Prolog.

Weijland (1990) defines a complete unification algorithm in terms of Colmerauer's consistency algorithm.

References

  • "Semantics for Logic Programs without Occur Check", W.P. Weijland, Theoretical Computer Science 71 (1990) pp 155-174.

This article was originally based on material from the Free On-line Dictionary of Computing, which is licensed under the GFDL.


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Occurs check — Der Occurs check bezeichnet in der Informatik einen Teil des Unifikationsalgorithmus. Er verhindert, dass eine Variable durch einen Term ersetzt wird, der diese Variable enthält. Anwendung findet er bspw. bei der Typprüfung in funktionalen… …   Deutsch Wikipedia

  • Check It Out! with Dr. Steve Brule — Title screen Genre Comedy Created by John C. Reil …   Wikipedia

  • Check valve — Tilting disc inconel check valve …   Wikipedia

  • Check weigher — Example checkweigher. Product passes on the conveyor belt where it is weighed A checkweigher is an automatic machine for checking the weight of packaged commodities. It is normally found at the offgoing end of a production process and is used to… …   Wikipedia

  • Machine Check Exception — A Machine Check Exception (MCE) is a type of computer hardware error that occurs when a computer s central processing unit detects a hardware problem. Microsoft Windows displays the error using the blue screen of death containing the error… …   Wikipedia

  • Cyclic redundancy check — A cyclic redundancy check (CRC) is an error detecting code designed to detect accidental changes to raw computer data, and is commonly used in digital networks and storage devices such as hard disk drives. Blocks of data entering these systems… …   Wikipedia

  • Cross-check — This article is about a type of move in chess. Cross checking is also a penalty in ice hockey. In chess, a cross check is a tactic in which a check played in response to a check, especially when the original check is blocked by a piece that… …   Wikipedia

  • Bug check — A bug check (also known as a system crash, stop error, or kernel error) is when the Windows operating system halts the moment it reaches a condition where it cannot operate safely. A bug check can be deliberately caused from a kernel mode driver… …   Wikipedia

  • SCSI check condition — In computer terminology, a Check Condition occurs when a SCSI device needs to report an error. SCSI communication takes place between an initiator and a target. The initiator sends a command to the target which then responds. SCSI commands are… …   Wikipedia

  • Multidimensional parity-check code — A multidimensional parity check code (MDPC) is a simple type of error correcting code that operates by arranging the message into a multidimensional grid, and calculating a parity digit for each row and column. In general, an n dimensional parity …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”