Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected behavior of frozen/2

I was playing around with the prolog-coroutining predicates freeze/2 and frozen/2:

?- freeze(X,a=a), frozen(X,Goal).
?- freeze(X,a=a), freeze(Y,b=b), X=Y, frozen(X,Goal).

sicstus-prolog (version 4.5.1 for x86_64) gave these answers:

| ?- freeze(X,a=a), frozen(X,Goal).
Goal = prolog:freeze(X,user:(a=a)),
prolog:freeze(X,user:(a=a)) ? ;
no
| ?- freeze(X,a=a), freeze(Y,b=b), X=Y, frozen(X,Goal).
Y = X,
Goal = (user:(a=a),prolog:freeze(X,user:(b=b))),
prolog:freeze(X,user:(a=a)),
prolog:freeze(X,user:(b=b)) ? ;
no

Now Goal = prolog:freeze(X,user:(a=a)) I did not expect!

What I did expect were answers like the ones given by swi-prolog version 8.0.3:

?- freeze(X,a=a), frozen(X,Goal).
Goal = user:(a=a),
freeze(X, a=a).
?- freeze(X,a=a), freeze(Y,b=b), X=Y, frozen(X,Goal).
X = Y,
Goal = (user:(a=a), user:(b=b)),
freeze(Y, a=a),
freeze(Y, b=b).

Arguably, both the SICStus answers and the SWI answers are correct...

But is there a deeper reason for the somewhat peculiar answer(s) given by SICStus?

like image 768
repeat Avatar asked Nov 17 '19 20:11

repeat


People also ask

What was the mystery in Frozen 2?

Taking place three years after the events of the first movie, Anna and Elsa have settled into their new lives and everything seemed to be going well when Elsa suddenly - and accidentally - triggered the magical spirits to the north. As a result, all of the natural elements were stripped from Arendelle.

What mental health issues does Elsa have?

What sets Elsa apart from the mass array of Disney princesses is her inner battle with mental illness, anxiety and depression. In Frozen II, Elsa is the only person who can hear a voice but everyone couldn't.

What is Elsa's behavior?

Elsa, however, is risk-averse, anxious, and self-doubting. This is her biggest test. She must accept her crown and scepter with ungloved hands. Should she slip up or let her emotions overwhelm her, she may let the magic out, revealing who she really is.

What even happened in Frozen 2?

The Ending, ExplainedThanks to Anna, a frozen Elsa (now armed with the truth) is broken free as the dam breaks thanks to Anna rousing Earth to break it. Elsa saves everyone from the ensuing flood, and in a decidedly tragic twist, Elsa and Anna get separated. Off-screen, Elsa abdicates the throne of Arendelle.


1 Answers

I don't know if there is any "deep" reason for the difference. Since frozen/2 is a general interface to attributed variables, it kind of makes sense to not special-case freeze/2 goals.

In fact, up to 4.5.1, SICStus tried, but sometimes failed, to special-case freeze/2 goals. This is why you see user:(a=a) for the first sub-goal. In the next release we have changed this so the result instead will become Goal = (prolog:freeze(X,user:(a=a)),prolog:freeze(X,user:(b=b))) (and we have also made some other improvements to frozen/2).

like image 53
Per Mildner Avatar answered Oct 18 '22 22:10

Per Mildner