# Predicate

**URL:** https://swi-prolog.discourse.group/c/help/predicate-choice/20.md

[Latest](https://swi-prolog.discourse.group/latest.md) · [Categories](https://swi-prolog.discourse.group/categories.md) · [Tags](https://swi-prolog.discourse.group/tags.md)

---

## [About the Predicate category](https://swi-prolog.discourse.group/t/about-the-predicate-category/1945)

<div class="topic-metadata">

**Author:** [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Replies:** 0

</div>

When you are not sure which SWI-Prolog base or library predicate, combination of predicates, or options for a predicate(s) to use.

---

## [Using sum in subsumptive tabling](https://swi-prolog.discourse.group/t/using-sum-in-subsumptive-tabling/9499)

<div class="topic-metadata">

**Author:** [@CapelliC](https://swi-prolog.discourse.group/u/CapelliC)\
**Replies:** 1\
**Last updated:** [January 28, 2026, 10:53am UTC](https://swi-prolog.discourse.group/t/using-sum-in-subsumptive-tabling/9499 "2026-01-28T10:53:12Z")

</div>

I’ve solved day 11, part 2 (advent of code 2025), with subsumptive tabling, but cannot find the right syntax/semantic to use the table sum specification. That is this works :- table count\_paths(+,+,+,-). count\_paths(T,…

---

## [Crash when initializing GMP](https://swi-prolog.discourse.group/t/crash-when-initializing-gmp/9249)

<div class="topic-metadata">

**Author:** [@nvetrini](https://swi-prolog.discourse.group/u/nvetrini)\
**Replies:** 5\
**Last updated:** [September 22, 2025, 6:21am UTC](https://swi-prolog.discourse.group/t/crash-when-initializing-gmp/9249 "2025-09-22T06:21:15Z")

</div>

Hi, after upgrading to 2380532402c1ccf86bf8992fe6ed52a16234172f (thanks Jan for the patch) on Linux/x86\_64 I was running some regression tests on my application, and I noticed a crash tied to GMP. Naturally swipl is buil…

---

## [Getting parentheses to indicate precedence when interpreting clause bodies](https://swi-prolog.discourse.group/t/getting-parentheses-to-indicate-precedence-when-interpreting-clause-bodies/3838)

<div class="topic-metadata">

**Author:** [@JCR](https://swi-prolog.discourse.group/u/JCR)\
**Replies:** 1\
**Last updated:** [April 19, 2021, 11:24am UTC](https://swi-prolog.discourse.group/t/getting-parentheses-to-indicate-precedence-when-interpreting-clause-bodies/3838 "2021-04-19T11:24:57Z")

</div>

Hi, I don’t understand how to preserve parentheses that indicate precedence when interpreting clause bodies. The query test below yields \[a, ∧ ,b, ∨ ,c\] but i was expecting something like \[a, ∧ , '(', b, ∨ ,c, ')'\]; i.e…

---

## [Help with http\_get/3](https://swi-prolog.discourse.group/t/help-with-http-get-3/9225)

<div class="topic-metadata">

**Author:** [@remy.s](https://swi-prolog.discourse.group/u/remy.s)\
**Replies:** 4\
**Last updated:** [August 26, 2025, 5:17pm UTC](https://swi-prolog.discourse.group/t/help-with-http-get-3/9225 "2025-08-26T17:17:51Z")

</div>

I am using http\_get/3 to connect to a foreign server with the following code: % SWI-Prolog (threaded, 64 bits, version 9.3.28) :- use\_module(library(http/http\_header)). :- use\_module(library(http/http\_client)). :- use\_…

---

## [Copy\_term/2 is not relational and this is a problem](https://swi-prolog.discourse.group/t/copy-term-2-is-not-relational-and-this-is-a-problem/9079)

<div class="topic-metadata">

**Author:** [@gabe-rbo](https://swi-prolog.discourse.group/u/gabe-rbo)\
**Replies:** 3\
**Last updated:** [June 27, 2025, 9:51pm UTC](https://swi-prolog.discourse.group/t/copy-term-2-is-not-relational-and-this-is-a-problem/9079 "2025-06-27T21:51:10Z")

</div>

I’m currently trying to create an EBG using SWI-Prolog, however, copy\_term/2 is not working properly as it should in the ISO Standard. When i try to copy something like: copy\_term( (n\_queens( GenQueens, GenSolution ), …

---

## [\`message\_hook\` dropping messages during \`xref\_source\`](https://swi-prolog.discourse.group/t/message-hook-dropping-messages-during-xref-source/9060)

<div class="topic-metadata">

**Author:** [@eignnx](https://swi-prolog.discourse.group/u/eignnx)\
**Replies:** 4\
**Last updated:** [June 25, 2025, 4:42pm UTC](https://swi-prolog.discourse.group/t/message-hook-dropping-messages-during-xref-source/9060 "2025-06-25T16:42:56Z")

</div>

I’m trying to capture swipl’s error messages (specifically import\_private(\_,\_), attempting to import from a module a predicate not exported by that module) via message\_hook/3. This is work for the LSP, and we call xref\_…

---

## [Why doesn't ord\_subset generate subsets?](https://swi-prolog.discourse.group/t/why-doesnt-ord-subset-generate-subsets/3682)

<div class="topic-metadata">

**Author:** [@panasenco](https://swi-prolog.discourse.group/u/panasenco)\
**Replies:** 12\
**Last updated:** [June 6, 2025, 5:05pm UTC](https://swi-prolog.discourse.group/t/why-doesnt-ord-subset-generate-subsets/3682 "2025-06-06T17:05:56Z")

</div>

I’m interested in generating all subsets of an ordered set of a fixed length on backtracking. What I get: ?- use\_module(library(ordsets)). true. ?- ord\_subset(S, \[1,2,3\]). S = \[\] ; false. What I hoped for: ?- ord\_sub…

---

## [Some small omissions in prolog\_read\_source\_term/4?](https://swi-prolog.discourse.group/t/some-small-omissions-in-prolog-read-source-term-4/8899)

<div class="topic-metadata">

**Author:** [@jamesnvc](https://swi-prolog.discourse.group/u/jamesnvc)\
**Replies:** 3\
**Last updated:** [May 28, 2025, 8:09am UTC](https://swi-prolog.discourse.group/t/some-small-omissions-in-prolog-read-source-term-4/8899 "2025-05-28T08:09:32Z")

</div>

I’ve been working on adding automatic code formatting support to my LSP server (thanks to @logicmoo). It currently has support for some basic formatting, but I’ve encountered some issues with prolog\_read\_source\_term/4: W…

---

## [Is it possible to serialise PCE Classes?](https://swi-prolog.discourse.group/t/is-it-possible-to-serialise-pce-classes/8889)

<div class="topic-metadata">

**Author:** [@l4e21](https://swi-prolog.discourse.group/u/l4e21)\
**Replies:** 3\
**Last updated:** [March 22, 2025, 12:14pm UTC](https://swi-prolog.discourse.group/t/is-it-possible-to-serialise-pce-classes/8889 "2025-03-22T12:14:00Z")

</div>

I have a project where I’m serialising all my predicates and modules (AKA performing source dumps) but I realised that I can’t seem to serialise PCE Classes. Usually if I want to dump source of a module I do listing(Modu…

---

## [How to replace empty atoms with fresh variables in a dict?](https://swi-prolog.discourse.group/t/how-to-replace-empty-atoms-with-fresh-variables-in-a-dict/8767)

<div class="topic-metadata">

**Author:** [@Rscho314](https://swi-prolog.discourse.group/u/Rscho314)\
**Replies:** 1\
**Last updated:** [February 3, 2025, 8:05am UTC](https://swi-prolog.discourse.group/t/how-to-replace-empty-atoms-with-fresh-variables-in-a-dict/8767 "2025-02-03T08:05:36Z")

</div>

Hi, I am receiving dicts at runtime from reading a csv file, such as: D = \_{a:\[1,2,'',4\],b:\[w,x,y,z\]}. Each list value corresponds to a column in the original csv. Empty atoms are missing values. I would like to repla…

---

## [Needing help with call\_with\_depth\_limit/3](https://swi-prolog.discourse.group/t/needing-help-with-call-with-depth-limit-3/7398)

<div class="topic-metadata">

**Author:** [@joseph-vidal-rosset](https://swi-prolog.discourse.group/u/joseph-vidal-rosset)\
**Replies:** 40\
**Last updated:** [July 6, 2024, 9:02am UTC](https://swi-prolog.discourse.group/t/needing-help-with-call-with-depth-limit-3/7398 "2024-07-06T09:02:07Z")

</div>

Hello everybody, It is said about call\_with\_depth\_limit/3 that This predicate may be used for theorem provers to realise techniques like iterative deepening. The code below is a theorem prover for classical F.O.L. t…

---

## [Prolog](https://swi-prolog.discourse.group/t/prolog/8536)

<div class="topic-metadata">

**Author:** [@andrewpivo](https://swi-prolog.discourse.group/u/andrewpivo)\
**Replies:** 1\
**Last updated:** [October 15, 2024, 6:56pm UTC](https://swi-prolog.discourse.group/t/prolog/8536 "2024-10-15T18:56:31Z")

</div>

solve square systems of linear equations using LU decomposition. I am very new to prolog and would really appreciate it how to do it. To be honest it’s quite hard to even understand LU decomposition algorithm

---

## [Sgml\_parse "omitted" event flag seems to not work](https://swi-prolog.discourse.group/t/sgml-parse-omitted-event-flag-seems-to-not-work/8513)

<div class="topic-metadata">

**Author:** [@mika](https://swi-prolog.discourse.group/u/mika)\
**Replies:** 1\
**Last updated:** [October 4, 2024, 8:40am UTC](https://swi-prolog.discourse.group/t/sgml-parse-omitted-event-flag-seems-to-not-work/8513 "2024-10-04T08:40:25Z")

</div>

Hi, mostly just wanted to report my observation: it seems to me that sgml\_parse wrongly flags end tags as explicit because it releases a warning for them same ones being omitted at the same time. I can surely workaroun…

---

## [Set a default value for a variable if it is not provided by user](https://swi-prolog.discourse.group/t/set-a-default-value-for-a-variable-if-it-is-not-provided-by-user/7760)

<div class="topic-metadata">

**Author:** [@konokaiden](https://swi-prolog.discourse.group/u/konokaiden)\
**Replies:** 14\
**Last updated:** [September 6, 2024, 8:12pm UTC](https://swi-prolog.discourse.group/t/set-a-default-value-for-a-variable-if-it-is-not-provided-by-user/7760 "2024-09-06T20:12:40Z")

</div>

I want to make a rule where I have three variables, Input, Compare, Output. If the user supplies the Compare value, I want it to be run with that. If the user does not supply a Compare, I want to set it. Does SWI-Prolo…

---

## [Question about message\_hook/3 and backtracking](https://swi-prolog.discourse.group/t/question-about-message-hook-3-and-backtracking/7565)

<div class="topic-metadata">

**Author:** [@Christophe\_Rey](https://swi-prolog.discourse.group/u/Christophe_Rey)\
**Replies:** 0\
**Last updated:** [July 3, 2024, 2:44pm UTC](https://swi-prolog.discourse.group/t/question-about-message-hook-3-and-backtracking/7565 "2024-07-03T14:44:20Z")

</div>

Hi, I do not understand the behaviour of the following program related to the interaction bewteen backtracking and the message\_hook/3 predicate. message\_hook(\_, informational, \_). message\_hook(frame(\_:Atom,trace(exit,\_…

---

## [Why the answer contains a \`false\`?](https://swi-prolog.discourse.group/t/why-the-answer-contains-a-false/5425)

<div class="topic-metadata">

**Author:** [@chansey97](https://swi-prolog.discourse.group/u/chansey97)\
**Replies:** 16\
**Last updated:** [May 14, 2024, 12:18pm UTC](https://swi-prolog.discourse.group/t/why-the-answer-contains-a-false/5425 "2024-05-14T12:18:29Z")

</div>

My SWI-Prolog knowledge base contains the following three facts: data(catalog1, mike, deposit, 100). data(catalog1, bob, deposit, 150). data(catalog2, mike, deposit, 200). The query is: ?- data(catalog1, mike, deposit…

---

## [\`settings:env\` as arithmetic function](https://swi-prolog.discourse.group/t/settings-env-as-arithmetic-function/7212)

<div class="topic-metadata">

**Author:** [@ridgeworks](https://swi-prolog.discourse.group/u/ridgeworks)\
**Replies:** 19\
**Last updated:** [February 3, 2024, 9:35pm UTC](https://swi-prolog.discourse.group/t/settings-env-as-arithmetic-function/7212 "2024-02-03T21:35:00Z")

</div>

After the recent change to support for user defined arithmetic functions, I’ve been experimenting with library(settings); the doc suggests that env (arity 1 and 2) should evaluate to numeric values in arithmetic expressi…

---

## [Passing HTML element to callback in swipl-wasm](https://swi-prolog.discourse.group/t/passing-html-element-to-callback-in-swipl-wasm/7147)

<div class="topic-metadata">

**Author:** [@mjano314](https://swi-prolog.discourse.group/u/mjano314)\
**Replies:** 8\
**Last updated:** [January 26, 2024, 12:18pm UTC](https://swi-prolog.discourse.group/t/passing-html-element-to-callback-in-swipl-wasm/7147 "2024-01-26T12:18:52Z")

</div>

Hi, I am not able to figure out, how to properly pass HTML element to bind/4 from library(dom). The minimum HTML example is like this: \<html\> \<body\> \<script src="https://SWI-Prolog.github.io/npm-swipl-wasm/latest…

---

## [CLP(FD) labeling/2 predicate](https://swi-prolog.discourse.group/t/clp-fd-labeling-2-predicate/6847)

<div class="topic-metadata">

**Author:** [@albangabillon](https://swi-prolog.discourse.group/u/albangabillon)\
**Replies:** 3\
**Last updated:** [September 15, 2023, 11:27pm UTC](https://swi-prolog.discourse.group/t/clp-fd-labeling-2-predicate/6847 "2023-09-15T23:27:46Z")

</div>

Hi, I cannot figure out how the ff option works for the labeling/2 predicate X in 1..5, Y in 1..2, X + Y #= 6, labeling(\[ff\],\[X,Y\]). X = 4, Y = 2 X = 5, Y = 1 I would have expected solution X=5 and Y=1 to come up fir…

---

## [About the usage of load\_files/2 with stream option](https://swi-prolog.discourse.group/t/about-the-usage-of-load-files-2-with-stream-option/6757)

<div class="topic-metadata">

**Author:** [@yourein](https://swi-prolog.discourse.group/u/yourein)\
**Replies:** 7\
**Last updated:** [August 9, 2023, 2:26am UTC](https://swi-prolog.discourse.group/t/about-the-usage-of-load-files-2-with-stream-option/6757 "2023-08-09T02:26:31Z")

</div>

I’m using: SWI-Prolog version 9.0.4 I want the code to: use the predicate load\_files/2 with a string stream. To make a stream from a string, I used open\_string/2. When compiling the code of the string, I used the option…

---

## [Predicate that always returns true](https://swi-prolog.discourse.group/t/predicate-that-always-returns-true/6752)

<div class="topic-metadata">

**Author:** [@Muppet39](https://swi-prolog.discourse.group/u/Muppet39)\
**Replies:** 17\
**Last updated:** [July 28, 2023, 6:29pm UTC](https://swi-prolog.discourse.group/t/predicate-that-always-returns-true/6752 "2023-07-28T18:29:06Z")

</div>

Hi everyone. I’m trying to build a network analyzer that uses SWI-Prolog as knowledge base. I’m creating a predicate whose purpose is to check if a network is already present in the KB, otherwise it must perform other …

---

## [Best way to write terms for interoperability](https://swi-prolog.discourse.group/t/best-way-to-write-terms-for-interoperability/4709)

<div class="topic-metadata">

**Author:** [@dgelessus](https://swi-prolog.discourse.group/u/dgelessus)\
**Replies:** 17\
**Last updated:** [July 21, 2023, 10:44am UTC](https://swi-prolog.discourse.group/t/best-way-to-write-terms-for-interoperability/4709 "2023-07-21T10:44:21Z")

</div>

This is half a question and half me sharing what I already found out. In short: when exchanging Prolog terms (in text form) with a different Prolog system or other software that reads Prolog terms, how do I make SWI-Prol…

---

## [What is the opposite of write\_canonical to read it back in?](https://swi-prolog.discourse.group/t/what-is-the-opposite-of-write-canonical-to-read-it-back-in/6727)

<div class="topic-metadata">

**Author:** [@mvolkmann](https://swi-prolog.discourse.group/u/mvolkmann)\
**Replies:** 5\
**Last updated:** [July 21, 2023, 7:10am UTC](https://swi-prolog.discourse.group/t/what-is-the-opposite-of-write-canonical-to-read-it-back-in/6727 "2023-07-21T07:10:55Z")

</div>

What is the opposite of write\_canonical to read it back in? It seems there is no read\_canonical.

---

## [Unexpected behavior of findnsols (&findall)](https://swi-prolog.discourse.group/t/unexpected-behavior-of-findnsols-findall/6551)

<div class="topic-metadata">

**Author:** [@hmz-15](https://swi-prolog.discourse.group/u/hmz-15)\
**Replies:** 2\
**Last updated:** [May 15, 2023, 8:26am UTC](https://swi-prolog.discourse.group/t/unexpected-behavior-of-findnsols-findall/6551 "2023-05-15T08:26:16Z")

</div>

Hello! I’m new to prolog and found this unexpected behavior when using ‘findnsols’ (which calls '‘findall’). Not all solutions returned satisfy the goal, which really confuses me. Do I misunderstand something? This is t…

---

## [Setting user\_error for a thread pool](https://swi-prolog.discourse.group/t/setting-user-error-for-a-thread-pool/6341)

<div class="topic-metadata">

**Author:** [@jamesnvc](https://swi-prolog.discourse.group/u/jamesnvc)\
**Replies:** 4\
**Last updated:** [March 6, 2023, 7:52am UTC](https://swi-prolog.discourse.group/t/setting-user-error-for-a-thread-pool/6341 "2023-03-06T07:52:13Z")

</div>

When making web services in SWI-Prolog, I typically set up a thread pool for the handlers as follows: :- multifile thread\_pool:create\_pool/1. thread\_pool:create\_pool(handler\_pool) :- thread\_pool\_create(handler\_pool…

---

## [Web Sockets status - a few questions](https://swi-prolog.discourse.group/t/web-sockets-status-a-few-questions/6333)

<div class="topic-metadata">

**Author:** [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Replies:** 0\
**Last updated:** [March 2, 2023, 3:40pm UTC](https://swi-prolog.discourse.group/t/web-sockets-status-a-few-questions/6333 "2023-03-02T15:40:15Z")

</div>

Found in the C code for web sockets there is a status property. There is also a Prolog predicate ws\_propetry/2 which does not support the status property. Here is the C code which can be used in Prolog as websocket:…

---

## [Event Calculus in SWI-Prolog?](https://swi-prolog.discourse.group/t/event-calculus-in-swi-prolog/5233)

<div class="topic-metadata">

**Author:** [@d-vyd](https://swi-prolog.discourse.group/u/d-vyd)\
**Replies:** 23\
**Last updated:** [February 26, 2023, 6:02pm UTC](https://swi-prolog.discourse.group/t/event-calculus-in-swi-prolog/5233 "2023-02-26T18:02:39Z")

</div>

I’ve started reading Mueller’s Commonsense Reasoning An Event Calculus Based Approach (2014). The Ciao version of sCASP includes a basic event calculus (BEC) file and folders of examples from this book. When I include sC…

---

## [Using library(hub)](https://swi-prolog.discourse.group/t/using-library-hub/6270)

<div class="topic-metadata">

**Author:** [@jamesnvc](https://swi-prolog.discourse.group/u/jamesnvc)\
**Replies:** 12\
**Last updated:** [February 20, 2023, 8:42pm UTC](https://swi-prolog.discourse.group/t/using-library-hub/6270 "2023-02-20T20:42:17Z")

</div>

I’m trying to put together a simple test-case for library(hub), but I can’t seem to have messages be sent back-and-forth as expected. My code looks as follows: :- http\_handler(root(ws), http\_upgrade\_to…

---

## [Http\_read\_data](https://swi-prolog.discourse.group/t/http-read-data/6263)

<div class="topic-metadata">

**Author:** [@heiheshang](https://swi-prolog.discourse.group/u/heiheshang)\
**Replies:** 1\
**Last updated:** [February 17, 2023, 4:19pm UTC](https://swi-prolog.discourse.group/t/http-read-data/6263 "2023-02-17T16:19:58Z")

</div>

i got the list from Request http\_read\_data. http\_read\_data(Request, Data, \[\]), Data = \[param1=value1,param2=value2\] how to use it ? how to get the value param1 ?

[Next page](https://swi-prolog.discourse.group/c/help/predicate-choice/20.md?page=1)
