encyclopegia.org

Cut (logic programming)

The cut, in Prolog, is a goal, written as ! , which always succeeds but cannot be backtracked. Cuts can prevent unwanted backtracking, which could add unwanted solutions and/or space/time overhead to a query. The cut should be used sparingly. While cuts can be inserted into code containing errors, if a test is unnecessary because a cut has guaranteed that it is true, it is good practice to say so in a comment at the appropriate place. Some programmers call the cut a controversial control facility because it was added for efficiency reasons only and is not a logical formula.

The cut, in Prolog, is a goal, written as ! , which always succeeds but cannot be backtracked. Cuts can prevent unwanted backtracking, which could add unwanted solutions and/or space/time overhead to a query. The cut should be used sparingly. While cuts can be inserted into code containing errors, if a test is unnecessary because a cut has guaranteed that it is true, it is good practice to say so in a comment at the appropriate place. Some programmers call the cut a controversial control facility because it was added for efficiency reasons only and is not a logical formula. gamble(X) :- gotmoney(X),!. gamble(X) :- gotcredit(X), \+ gotmoney(X). This is called a cut operator. The ! tells the interpreter to stop looking for alternatives; however, if fails it will check the second rule. Checking for in the second rule may appear redundant since Prolog's appearance is dependent on failing before, otherwise the second rule would not be evaluated in the first place. Adding guarantees that the second rule will always work, even if the first rule is removed by accident, changed, or moved after the second one. gamble(X) :- gotmoney(X),!. gamble(X) :- gotcredit(X). Proper placement of the cut operator and the order of the rules are required to determine their logical meaning. If for any reason the first rule is removed (e.g. by a cut-and-paste accident) or moved after the second one, the second rule will be broken, i.e., it will not guarantee the rule . min(X,Y,X) :- !, X =

References

No reference rows published for this article.

Cite this article

MLA

"Cut (logic programming)." encyclopegia.org, 2026, https://encyclopegia.org/wiki/cut-logic-programming. Accessed 24 November 2026.

Chicago

"Cut (logic programming)." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/cut-logic-programming.

APA

encyclopegia.org. (2026). Cut (logic programming). Retrieved November 24, 2026, from https://encyclopegia.org/wiki/cut-logic-programming

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1342506889 · 0.5 · snapshot enwiki-001342506889

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.