# Exclude certain predicates from a trace?

**URL:** <https://swi-prolog.discourse.group/t/exclude-certain-predicates-from-a-trace/802>\
**Category:** Help!\
**Created:** [June 12, 2019, 4:41pm UTC](https://swi-prolog.discourse.group/t/exclude-certain-predicates-from-a-trace/802 "2019-06-12T16:41:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![prodog](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@prodog](https://swi-prolog.discourse.group/u/prodog)\
**Post date:** [June 12, 2019, 4:41pm UTC](https://swi-prolog.discourse.group/t/exclude-certain-predicates-from-a-trace/802/1 "2019-06-12T16:41:38Z")

</div>

I’m using: SWI-Prolog version 8.0.2

@ericGT - Is predicate the correct term here? `functor` seems weird to me in this particular context. Should I use that instead? Or perhaps simply `function`?

Is there a way to exclude certain predicates from activating the debugger during a trace? For example, suppose I didn’t want `consult()` to activate the debugger even if I’m currently tracing, when I reconsult a file from the console?

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [June 12, 2019, 5:07pm UTC](https://swi-prolog.discourse.group/t/exclude-certain-predicates-from-a-trace/802/2 "2019-06-12T17:07:00Z")

</div>

> [@prodog](#):
>
> Is predicate the correct term here? `functor` seems weird to me in this particular context. Should I use that instead? Or perhaps simply `function` ?

See: [What’s the difference between functor, a fact, a predicate and a rule in Prolog?](https://stackoverflow.com/questions/53266306/whats-the-difference-between-functor-a-fact-a-predicate-and-a-rule-in-prolog)

I personally choose to not use `function` when describing Prolog. I will sometimes use it to bridge the concepts from the functional programming world to logic programming but avoid the use of the word if possible.

In this question I would go with predicate as I am guessing that you want to exclude multiple clauses with the same name/arity.

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [June 12, 2019, 6:05pm UTC](https://swi-prolog.discourse.group/t/exclude-certain-predicates-from-a-trace/802/3 "2019-06-12T18:05:31Z")

</div>

The difference between a _term_ and a _predicate_ (or _goal_) can be subtle. They look the same and are distinguished by context. For example:

```prolog
foo(1).
foo(2).
foo_results(Results) :- setof(X, foo(X), Results).
?- foo_results(Results).
Results = [1, 2].

```

The _predicate_ `foo/1` has two clauses. The predicate `foo_results/1` calls this, but indirectly … the `setof/3` meta-predicate takes a _term_ as its second argument, which it interprets as a predicate. In other words, a functor (name/arity) is the skeleton of a kind of term; some meta-predicates (e.g., `call/1`, `setof/3`, etc.) can interpret a term (functor/arity) as a predicate.

(BTW, in an earlier posting, I got this wrong, and still might not have some details of terminology correct.)

In your case, I’d say that “exclude certain predicates” is correct and understandable; but technically speaking, you specify the “certain predicates” using terms (you don’t actually _call_ the predicates but use their name/arity to specify them).

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [June 12, 2019, 7:41pm UTC](https://swi-prolog.discourse.group/t/exclude-certain-predicates-from-a-trace/802/4 "2019-06-12T19:41:18Z")

</div>

> [@peter.ludemann](#):
>
> you specify the “certain predicates” using terms (you don’t actually _call_ the predicates but use their name/arity to specify them

The use of the word `specify` caught me off guard, I had to pull out the ISO Prolog specification and search for the word. I am use to the word `execute`.

**3.67 execution (verb: to execute):** The process by which a Prolog _processor_ tires to _satisfy a goal_ (_see 7.7.1_).

**7.7.1 Execution**

Execution is a sequence of activations which attempt to satisfy a goal. Side effects (7.7.9) may occur during execution.

Each execution step is represented by a sequence of  
execution states.

…

Call is mostly noted as **call/1**

**7.8.3 call/1**

**7.8.3.1 Description**

call(G) is true iif G represents a goal which is true.

…

---

<div class="post-metadata">

**Author:** ![peter.ludemann](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/peter.ludemann/32/48_2.png) [@peter.ludemann](https://swi-prolog.discourse.group/u/peter.ludemann)\
**Post date:** [June 12, 2019, 10:06pm UTC](https://swi-prolog.discourse.group/t/exclude-certain-predicates-from-a-trace/802/5 "2019-06-12T22:06:37Z")

</div>

I didn’t mean “specify” in any technical sense; and certainly not in any ISO-Prolog sense.

Anyway, perhaps this example will help:

```prolog
times(0, 10, 0). % A trivial predicate for this example
times(1, 10, 10).
times(2, 10, 20).

append_arg_and_call(Call, Arg) :-
    Call =.. CallList,
    append(CallList, [Arg], CallPlusArgList),
    CallPlusArg =.. CallPlusArgList,
    call(CallPlusArg).

```

And running it:

```prolog
?- append_arg_and_call(times(1, 10), Z).
Z = 10.

```

The call to `eval/2` passes in the _term_ `times(1,10)`, which gets an additional argument added to it before it’s called. In a functional programming language, you’d create a “closure” or “partial function”, but in Prolog, it’s just a term that is _interpreted_ by the `call` predicate to execute a goal (“execute” in the ISO-Prolog sense).

```prolog
?- trace, append_arg_and_call(times(1, 10), Z).
   Call: (10) append_arg_and_call(times(1, 10), _2522) ? 
   Call: (11) times(1, 10)=.._2844 ? 
   Exit: (11) times(1, 10)=..[times, 1, 10] ? 
   Call: (11) lists:append([times, 1, 10], [_2522], _2870) ? 
   Exit: (11) lists:append([times, 1, 10], [_2522], [times, 1, 10, _2522]) ? 
   Call: (11) _2884=..[times, 1, 10, _2522] ? 
   Exit: (11) times(1, 10, _2522)=..[times, 1, 10, _2522] ? 
   Call: (11) times(1, 10, _2522) ? % <=== executes the *goal*
   Exit: (11) times(1, 10, 10) ? 
   Exit: (10) append_arg_and_call(times(1, 10), 10) ? 
Z = 10.

```

(Normally, you wouldn’t define `append_arg_and_call/2` because the builtin `call/2` handles appending an arg; I wrote a pure-Prolog implementation to show you that it takes a _term_, manipulates that term, and finally _interprets_ the manipulated term as a goal.)
