trealla-prolog / trealla

A compact, efficient Prolog interpreter written in plain-old C.
MIT License
252 stars 11 forks source link

does this terminate, i.e. model finder #533

Open Jean-Luc-Picard-2021 opened 2 months ago

Jean-Luc-Picard-2021 commented 2 months ago

Was trying this query:

?- counter(3).

Does it terminate? Was waiting more than 20 minutes, SWI-Prolog does it in 12 minutes. But can Trealla Prolog also do it?

Source code:

mace4.p.log

infradig commented 2 months ago

$ swipl -q mace4.pl ?- time(counter(3)). 00-0 01-1 02-2 03-3 04-4 05-5 10-1 11-5 12-3 13-4 14-2 15-0 20-2 21-4 22-0 23-5 24-1 25-3 30-3 31-2 32-1 33-0 34-5 35-4 40-4 41-3 42-5 43-1 44-0 45-2 50-5 51-0 52-4 53-2 54-3 55-1 a-1 b-2 i(0)-0 i(1)-5 i(2)-2 i(3)-3 i(4)-4 i(5)-1 % 10,981,885,000 inferences, 1070.676 CPU in 1072.190 seconds (100% CPU, 10256962 Lips) true

$ tpl mace4.pl ?- time(counter(3)). 00-0 01-1 02-2 03-3 04-4 05-5 10-1 11-5 12-3 13-4 14-2 15-0 20-2 21-4 22-0 23-5 24-1 25-3 30-3 31-2 32-1 33-0 34-5 35-4 40-4 41-3 42-5 43-1 44-0 45-2 50-5 51-0 52-4 53-2 54-3 55-1 a-1 b-2 i(0)-0 i(1)-5 i(2)-2 i(3)-3 i(4)-4 i(5)-1 % Time elapsed 4894.729s, 13584971414 Inferences, 2.775 MLips true ;

$ scryer-prolog mace4.pl ?- time(counter(3)). 00-0 01-1 02-2 03-3 04-4 05-5 10-1 11-5 12-3 13-4 14-2 15-0 20-2 21-4 22-0 23-5 24-1 25-3 30-3 31-2 32-1 33-0 34-5 35-4 40-4 41-3 42-5 43-1 44-0 45-2 50-5 51-0 52-4 53-2 54-3 55-1 a-1 b-2 i(0)-0 i(1)-5 i(2)-2 i(3)-3 i(4)-4 i(5)-1 % CPU time: 7646.607s, 19_937_875_400 inferences true

Jean-Luc-Picard-2021 commented 2 months ago

Ok, I wasn't expecting a factor 4-5. Maybe should also check Scryer Prolog. For example Dogelog Player for Java does it in, on a machine where SWI-Prolog takes 12 minutes:

/* Dogelog Player 1.2.0 */
?- time(counter(3)).
% Zeit 1497742 ms, GC 61 ms, Lips 8560942, Uhr 02.05.2024 12:06
true

Ciao Prolog beats SWI-Prolog by a factor 2-3:

/* Ciao Prolog 1.22.0 */
?- time(counter(3)).
% 295.658424 seconds
yes

What keeps Trealla that busy? Also Trealla LIPS going down? (LIPS going down could indicate some pressure on built-ins, or maybe something else, some pressure on garbage collection?)

infradig commented 2 months ago

Hard to say. If if compile with profiling I could run it overnight.

infradig commented 2 months ago

Uses a lot of (=..)/2, which can be expensive, something i've been meaning to revisit.

Jean-Luc-Picard-2021 commented 2 months ago

After some wait, Scryer Prolog gives me:

/* Scryer Prolog 0.9.4 */
?- time(counter(3)).
   % CPU time: 2721.739s, 19_937_875_400 inferences
   true
infradig commented 1 month ago

It's now about 20% faster, not much more I can do.

Jean-Luc-Picard-2021 commented 1 month ago

So close it?

infradig commented 1 month ago

No, don't. I have a speedy solution but don't know if it will anything else yet.

On Wed, 8 May 2024, 21:03 Jean-Luc-Picard-2021, @.***> wrote:

So close it?

— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/533#issuecomment-2100321841, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSERHURV7DOV36QODFLLZBIBABAVCNFSM6AAAAABHESMDZ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBQGMZDCOBUGE . You are receiving this because you commented.Message ID: @.***>