# Status of mode directed tabling, especially min/max

**URL:** <https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180>\
**Category:** Help!\
**Created:** [September 6, 2019, 7:11am UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180 "2019-09-06T07:11:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [September 6, 2019, 7:11am UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/1 "2019-09-06T07:11:20Z")

</div>

I’m using: SWI-Prolog version 8.1.13 (Linux Ubuntu 18.04LTS)

I wander about the status of mode directed tabling is, especially the min/max modes.

Here is a simple example where tabling make the predicate just fail. The result should be 206 (103+103). But perhaps I don’t correctly understand how mode directed tabling works in SWI-Prolog.

```prolog
go :-
        abolish_all_tables,
        L1 = [1,2,3,5,98,3,103,4,4,21],

        % -> false
        test1(L1,L1, Val1),
        nl.

%%
%% Don't work as expected:
%% -> false
%% Should be 206.
%%
:- table test1(+,+,max).
test1(L,L2, Val) :-
        member(Val1,L),
        member(Val2,L2),
        Val is Val1+Val2.

```

Here are two more “serious” examples (i.e. Project Euler problems) where mode tabling with max/min give wrong answer or fails :

- [http://hakank.org/swi\_prolog/euler14.pl](http://hakank.org/swi_prolog/euler14.pl)  
The failing predicate is euler14xxx/0 which give the correct length of the longest Collatz cycle (525), but the number (N) that yield this longest cycle is not correct. It should be 837799, but seems to output the first number in the between/3 generated list of N’s (2).

- [http://hakank.org/swi\_prolog/euler18.pl](http://hakank.org/swi_prolog/euler18.pl)  
The failing predicate is euler18xxx which just fails when using the min mode.

Note: These programs use these modules:

- [http://hakank.org/swi\_prolog/hakank\_utils.pl](http://hakank.org/swi_prolog/hakank_utils.pl)
- [http://hakank.org/swi\_prolog/euler\_utils.pl](http://hakank.org/swi_prolog/euler_utils.pl)

[Both these tabling programs are ported from my Picat program. Picat is based on the B-Prolog engine and works - what I understand - as in B-Prolog. They where inspired by/copied from code by Neng-Fa Zhou.]

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 6, 2019, 9:11am UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/2 "2019-09-06T09:11:49Z")

</div>

Turns out to be a bug in trie\_gen/2,3. I start to understand what is wrong, but I fear it will keep me busy for a little while to understand it fully.

As a whole, mode directed tabling has fallen behind compared to normal tabling. The test set is fairly small and while there have been a lot of changes to the tables to improve the classical tabling, the code for mode directed tabling is updated minimally and without an extensive test set easily leads to regression.

When the normal tabling code becomes stable the plan is to fully synchronize the code for mode directed tabling. Until then, performance and memory usage are way worse than normal tabling and some regression is to be expected.

I’ll fix this, add this to the test cases and keep you posted. Thanks for the small and clear test.

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [September 6, 2019, 9:21am UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/4 "2019-09-06T09:21:36Z")

</div>

Thanks, Jan.

It’s good to know that it should work.

/Hakan

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 6, 2019, 10:30am UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/6 "2019-09-06T10:30:43Z")

</div>

> [@jan](#):
>
> Turns out to be a bug in trie\_gen/2,3

> [@anon95304481](#):
>
> [cant make mode directed tabling example work (Levenshtein distance) · Issue #490 · SWI-Prolog/swipl-devel · GitHub](https://github.com/SWI-Prolog/swipl-devel/issues/490)

Pushed 511594ae56c7ef35de1263f698ea4b73a6419f73, which fixes both.

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [September 6, 2019, 7:37pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/7 "2019-09-06T19:37:39Z")

</div>

@anon95304481. The two Euler problems mentioned above (#14 and #18) are ported to B-Prolog with the same result (and almost as fast) as the Picat versions.

[http://hakank.org/bprolog/euler14.pl](http://hakank.org/bprolog/euler14.pl)  
[http://hakank.org/bprolog/euler18.pl](http://hakank.org/bprolog/euler18.pl)

I’m not sure that I understand all your questions, but I’ll give it a try. Sorry for the long post (and I hope that it’s not off-topic for the forum).

Let’s start with euler14.pl ([http://hakank.org/bprolog/euler14.pl](http://hakank.org/bprolog/euler14.pl) )

```prolog
%%
%% From
%% http://hakank.org/picat/euler14.pi
%% which is slightly adjusted from
%% http://picat-lang.org/euler/p14.pi
%% 
%% All numbers 2..999999: 1.4s
%% Odd numbers: 3..2..999999: 1.3s
%% (My Picat version using odd numbers takes ~ 1.2s)
%%
euler14 :-
    max_chain(N,_Chain,Len),
    writeln([n=N,len=Len]).

:- table max_chain(-,-,max).
max_chain(N,Chain,Len) :-
        between(2,999999,N), % checking all numbers        
        % between(3,2,999999,N), % just checking the odd numbers
        gen(N,Chain,Len).

:- table gen(+,-,-).
gen(1,Chain,Len) :-
        Chain=[1],
        Len is 1.

gen(N,Chain,Len) :-
        N > 1,
        N mod 2 =:= 0,
        T is N div 2,
        gen(T,Chain1,Len1),
        Chain=[N|Chain1],
        Len is Len1+1.

gen(N,Chain,Len) :-
        N > 1,
        N mod 2 =:= 1,
        T is 3*N+1,
        gen(T,Chain1,Len1),
        Chain=[N|Chain1],
        Len is Len1+1.
    
between(From,Step,To,N) :-
        To2 is To div Step,
        between(From,To2,Tmp),
        N is (Tmp-From)*Step+From.

```

If the first table is commented out, i.e.  
`:- table max_chain(-,-,max).`  
then there’s no generation at all of the numbers: it just handle N=2 (the first number) and then stops. I.e. it acts as a kind of generator. I’m not sure how to consider this case.

The second tabling:

```prolog
:- table gen(+,-,-).

```

is just for caching the previous results. Commenting it out give the correct answer but takes a very long time (116s vs 1.5s).

Here’s the second example, euler18.pl ([http://hakank.org/bprolog/euler18.pl](http://hakank.org/bprolog/euler18.pl) )

```prolog
euler18 :-
        p18(Tri),
        pp(1,1,Tri,Sum),
        writeln(max_val=Sum).

p18(Triangle) :- 
        Triangle = [[75],
                     [95,64],
                     [17,47,82],
                     [18,35,87,10],
                     [20, 4,82,47,65],
                     [19, 1,23,75, 3,34],
                     [88, 2,77,73, 7,63,67],
                     [99,65, 4,28, 6,16,70,92],
                     [41,41,26,56,83,40,80,70,33],
                     [41,48,72,33,47,32,37,16,94,29],
                     [53,71,44,65,25,43,91,52,97,51,14],
                     [70,11,33,28,77,73,17,78,39,68,17,57],
                     [91,71,52,38,17,14,91,43,58,50,27,29,48],
                     [63,66, 4,68,89,53,67,30,73,16,69,87,40,31],
                     [4,62,98,27,23, 9,70,98,73,93,38,53,60, 4,23]].

%%
%% From Neng-Fa Zhou.
%%
:- table pp(+,+,+,max).
pp(Row,_Column,Tri,Sum) :-
        length(Tri,Len),
        Row > Len,
        Sum is 0.
pp(Row,Column,Tri,Sum) :-
        length(Tri,Len),
        Row =< Len,
        Row1 is Row+1,
        pp(Row1,Column,Tri,Sum1),
        matrix_element(Tri,Row,Column,TriRC),
        Sum is Sum1 + TriRC.

pp(Row,Column,Tri,Sum) :-
        length(Tri,Len),
        Row =< Len,
        Row1 is Row + 1, 
        Column1 is Column + 1,
        pp(Row1,Column1,Tri,Sum1),
        matrix_element(Tri,Row,Column,TriRC),        
        Sum is Sum1 + TriRC.    

matrix_element(X, I, J, Val) :-
        nth1(I, X, Row),
        nth1(J, Row, Val).

```

If the table statement

```prolog
:- table pp(+,+,+,max).

```

is commented out, the program don’t loop through the complete matrix, just a single pass of each line and then stops with an incorrect answer (the last). So it acts as a generator as well.

Does this answer any of your questions?

After your comments, I realize that these two examples might not work in SWI-Prolog even after Jan W have fixed the found tabling bug. They might just work in B-Prolog/Picat land.  
(Neng-Fa has written some other B-Prolog programs with tabling using min/max: [http://www.picat-lang.org/bprolog/examples/#TAB](http://www.picat-lang.org/bprolog/examples/#TAB) , but I have not analyzed them. )

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [September 7, 2019, 6:59am UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/9 "2019-09-07T06:59:37Z")

</div>

I have now tested the B-Prolog tabling examples from [http://www.picat-lang.org/bprolog/examples/#TAB](http://www.picat-lang.org/bprolog/examples/#TAB) in SWI-Prolog . The result is mixed: some works and some don’t work/yield errors.

Below is the full list. For most of the programs I had to slightly edit the B-Prolog programs, e.g. skipping user input and change the timing statistics. Note that I’m not sure if this comparison is really that useful since it seems that the tabling in B-Prolog is not (exactly ) the same as in SWI-Prolog.

- ackerman.pl  
`:- table a/3.`  
[http://hakank.org/swi\_prolog/ackermann2.pl](http://hakank.org/swi_prolog/ackermann2.pl)  
Works as expected.

- farmer.pl  
`:-table plan(+,-,min).`  
[http://hakank.org/swi\_prolog/farmer2.pl](http://hakank.org/swi_prolog/farmer2.pl)  
works as expected.

- fib.pl  
`:- table fib/2.`  
[http://hakank.org/swi\_prolog/fib.pl](http://hakank.org/swi_prolog/fib.pl)  
works as expected.

- knapsack.pl  
`:- table knapsack(+, +, max).`  
[http://hakank.org/swi\_prolog/knapsack2.pl](http://hakank.org/swi_prolog/knapsack2.pl)  
This does not work as expected:  
$ swipl knapsack2.pl  
?- make,go.  
% 8,796,210 inferences, 1.166 CPU in 1.166 seconds (100% CPU, 7542280 Lips)  
false.

- lcs.pl  
`:- table lcs(+,+,max).`  
[http://hakank.org/swi\_prolog/lcs.pl](http://hakank.org/swi_prolog/lcs.pl)

- matrix.pl  
`:- table sc(+,min,-,-).`  
[http://hakank.org/swi\_prolog/matrix.pl](http://hakank.org/swi_prolog/matrix.pl)

- obst.pl  
`:- table obst(+, min, -).`  
[http://hakank.org/swi\_prolog/obst.pl](http://hakank.org/swi_prolog/obst.pl)

```prolog
  SWI-Prolog [thread 1 (main) at Sat Sep 7 08:05:01 2019]: received fatal signal 11 (segv)
  C-stack trace labeled 'crash':
  [0] PL_strtod() at ??:? [0x7f4a276a388b]
  [1] bstore_print_backtrace_named() at ??:? [0x7f4a276a3a4e]
  [2] bstore_print_backtrace_named() at ??:? [0x7f4a276a3b41]
  [3] PL_get_signum_ex() at ??:? [0x7f4a276374da]
  [4] killpg() at ??:? [0x7f4a271e6f20]
  [5] add_choice() at ??:? [0x7f4a27670723]
  [6] add_choice() at ??:? [0x7f4a27670e05]
  [7] add_choice() at ??:? [0x7f4a276710fd]
  [8] PL_next_solution() at ??:? [0x7f4a275d4a19]
  [9] pl_skip_list3_va() at ??:? [0x7f4a2761d4b0]
  [10] pl_skip_list3_va() at ??:? [0x7f4a2761dd5b]
  [11] PL_toplevel() at ??:? [0x7f4a275cd8dd]
  [12] swipl(+0x735) [0x55ded34de735]
  [13] __libc_start_main() at /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344 [0x7f4a271c9b97]
  [14] swipl(+0x77a) [0x55ded34de77a]
  Running on_halt hooks with status 13.

```

Expected output:

```prolog
Optimal value is 4379

```

- sg.pl  
`:-table sg/2.`  
[http://hakank.org/swi\_prolog/sg.pl](http://hakank.org/swi_prolog/sg.pl)  
Works as expected.

- transitiveLeft.pl  
`:-table reach/2.`  
[http://hakank.org/swi\_prolog/transitiveLeft.pl](http://hakank.org/swi_prolog/transitiveLeft.pl)

- transitiveRight.pl  
`:-table reach/2.`  
[http://hakank.org/swi\_prolog/transitiveRight.pl](http://hakank.org/swi_prolog/transitiveRight.pl)

- water.pl  
`:-table plan(+,-,min).`  
[http://hakank.org/swi\_prolog/water2.pl](http://hakank.org/swi_prolog/water2.pl)

When Jan W has fixed the table bug mentioned earlier in this thread, I’ll be happy to re-test these programs.

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [September 7, 2019, 7:36am UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/10 "2019-09-07T07:36:05Z")

</div>

Ah. I just saw that the bug was fixed a “long” time ago. I’ll check it out again as soon as possible.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 7, 2019, 8:21am UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/11 "2019-09-07T08:21:45Z")

</div>

> [@hakank](#):
>
> The second tabling:
> 
> ```prolog
> :- table gen(+,-,-).
> 
> ```
> 
> is just for caching the previous results. Commenting it out give the correct answer but takes a very long time (116s vs 1.5s).

This might be part of the puzzle. According to my docs, `-` says _first answer_. Now, gen/3 is recursive. I cannot tell easily whether it calls a variant of itself, but if it does the tabling suspension mechanism kicks in and the order is pretty much undefined. Tabled execution using using `-` and otherwise ground arguments could use _early completion_ optimization, i.e., stop after the first answer. SWI-Prolog does this for normal tabling of ground sub goals, but not for this case (yet).

Its a nice example illustrating the need for and the opportunities to implement a few optimizations 🙂 Whether or not the program is correct, I cannot tell.

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [September 7, 2019, 11:36am UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/12 "2019-09-07T11:36:57Z")

</div>

Unfortunately, I couldn’t compile the Git version (problem with ODBC), but testing with the Windows nightly build (swipl-w64-2019-09-07.exe) worked quite well.

Summary: All problems with the B-Prolog programs are fixed in the nightly build. For matrix.pl one have to change the tabling to:  
`:- table sc(+,min,+,+).`

Euler problem 18 works as well.

That’s really great!

The only problem left is Euler 14 ([http://hakank.org/swi\_prolog/euler14.pl](http://hakank.org/swi_prolog/euler14.pl) ) which give the same error (`[n=2,len=525]` instead of `[n=837799,len=525]`).  
It seems that the jury is still out if this should work in SWI-Prolog.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 7, 2019, 12:11pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/13 "2019-09-07T12:11:04Z")

</div>

> [@hakank](#):
>
> Unfortunately, I couldn’t compile the Git version (problem with ODBC),

In theory it should drop building the ODBC interface if it cannot configure it. Which platform and which ODBC version is installed? Still, you can use `CMAKE -DSWIPL_PACKAGES_ODBC=OFF` and it should drop trying to build the odbc, even if the requirements seems present.

Interesting list of programs at [http://hakank.org/swi\_prolog/](http://hakank.org/swi_prolog/water2.pl)!

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 7, 2019, 12:17pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/14 "2019-09-07T12:17:03Z")

</div>

> [@hakank](#):
>
> [http://hakank.org/swi\_prolog/ackermann2.pl](http://hakank.org/swi_prolog/ackermann2.pl)

This link is dead ☹

---

<div class="post-metadata">

**Author:** ![swi](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@swi](https://swi-prolog.discourse.group/u/swi)\
**Post date:** [September 7, 2019, 12:39pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/15 "2019-09-07T12:39:04Z")

</div>

For me (on linux,version 8.1.13-21-ga03215660 ), one still has problems:

- matrix.pl:

```prolog
1 ?- go.
% 22 inferences, 0.000 CPU in 0.000 seconds (99% CPU, 764818 Lips)
ERROR: Uninstantiated argument expected, found 50

```

- All the others work fine including `euler14`:

```prolog
3 ?- go.
euler14a: [n=837799,len=525]
% 78,128,905 inferences, 24.553 CPU in 25.455 seconds (96% CPU, 3182057 Lips)

euler14b: [837799,525]
% 78,129,412 inferences, 24.914 CPU in 25.899 seconds (96% CPU, 3135921 Lips)

true.

```

Thanks Jan for such a great work!!

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 7, 2019, 3:13pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/16 "2019-09-07T15:13:38Z")

</div>

> [@swi](#):
>
> 1 ?- go. 22 inferences, 0.000 CPU in 0.000 seconds (99 CPU, 764818 Lips) ERROR: Uninstantiated argument expected, found 50

This has been discussed when answer subsumption was added to SWI. The conclusion was that calling a tabled predicate with an instantiated argument in the location of an argument for which answer subsumption applies should be an error. I don’t have all arguments in my head anymore.

I do get the correct answer for both SWI and XSB using `table sc(_,po((<)/2),_,_).`

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [September 7, 2019, 4:52pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/17 "2019-09-07T16:52:41Z")

</div>

Thanks for the tip about compiling. And your kind words.

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [September 7, 2019, 4:55pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/18 "2019-09-07T16:55:29Z")

</div>

Sorry about the broken link. [http://hakank.org/swi\_prolog/ackermann2.pl](http://hakank.org/swi_prolog/ackermann2.pl) is now fixed.

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [September 7, 2019, 5:03pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/19 "2019-09-07T17:03:08Z")

</div>

> [@swi](#):
>
> - matrix.pl:
> 
> ```prolog
> 1 ?- go.
> % 22 inferences, 0.000 CPU in 0.000 seconds (99% CPU, 764818 Lips)
> ERROR: Uninstantiated argument expected, found 50
> 
> ```
> 
> - All the others work fine including `euler14`:
> 
> ```prolog
> 3 ?- go.
> euler14a: [n=837799,len=525]
> % 78,128,905 inferences, 24.553 CPU in 25.455 seconds (96% CPU, 3182057 Lips)
> 
> euler14b: [837799,525]
> % 78,129,412 inferences, 24.914 CPU in 25.899 seconds (96% CPU, 3135921 Lips)
> 
> true.
> 
> ```

Regarding “matrix.pl”, did you change the tabling to  
`:- table sc(+,min,+,+).`

I’ve updated the program at my webpage with this tabling: [http://hakank.org/swi\_prolog/matrix.pl](http://hakank.org/swi_prolog/matrix.pl)

In “euler14.pl”, the problematic predicate is `euler14xxx`. The other two predicate that you tested use the simple (and unproblematic) tabling `:- table collLength/2.`.

---

<div class="post-metadata">

**Author:** ![swi](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@swi](https://swi-prolog.discourse.group/u/swi)\
**Post date:** [September 7, 2019, 5:37pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/20 "2019-09-07T17:37:24Z")

</div>

> [@jan](#):
>
> The conclusion was that calling a tabled predicate with an instantiated argument in the location of an argument for which answer subsumption applies should be an error.

Great, thanks, that makes sense!

---

<div class="post-metadata">

**Author:** ![swi](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@swi](https://swi-prolog.discourse.group/u/swi)\
**Post date:** [September 7, 2019, 5:45pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/21 "2019-09-07T17:45:01Z")

</div>

Thanks hakank, I get the same results as you do now.

As Jan mentioned, that is quite a nice collection of programs you have there! Thanks for sharing g it!

---

<div class="post-metadata">

**Author:** ![hakank](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/hakank/32/44_2.png) [@hakank](https://swi-prolog.discourse.group/u/hakank)\
**Post date:** [September 7, 2019, 5:55pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/22 "2019-09-07T17:55:06Z")

</div>

@swi Thanks!

As for now I’ve just ported some of my Picat CLPFD programs just to learn SWI-Prolog (especially how to solve the problems without foreach loops/list comprehensions/indexing/re-assignments etc). The real plan is to the more unique/cool stuff in SWI-Prolog. And hopefully to do some GOFAI as well. (Right now, I’m struggling with some Project Euler problems as you might have guessed.)

Note to others: The page we are talking about is “My SWI-Prolog page”: [http://hakank.org/swi\_prolog/](http://hakank.org/swi_prolog/) .

---

<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:** [September 7, 2019, 5:56pm UTC](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180/23 "2019-09-07T17:56:54Z")

</div>

> [@hakank](#):
>
> Note to others: The page we are talking about is “My SWI-Prolog page”: [My SWI-Prolog page](http://hakank.org/swi_prolog/) .

I am adding it to [Useful Prolog references](https://swi-prolog.discourse.group/t/useful-prolog-references/1089). As the page is a wiki you can edit also. 😃

[Next page](https://swi-prolog.discourse.group/t/status-of-mode-directed-tabling-especially-min-max/1180.md?page=2)
