occurs-check

Prolog systems with occurs check aware freeze

风流意气都作罢 提交于 2021-02-11 12:22:39
问题 David Tonhofer posed an interesting problem about occurs check. An occurs check aware coroutine can be realized as follows with a predicate with_occurs_check/2 which can be easily implemented as a refinement of with_occurs_check/1: occurs_check_aware_freeze(X, G) :- current_prolog_flag(F), freeze(X, with_occurs_check(F, G)). Namely by using an with_occurs_check/2 with a further parameter. But the main problem of a realiable with_occurs_check/[1,2] that also works with backtracking remains.

How to enable the occurs check in all unifications in SWI-Prolog?

只愿长相守 提交于 2021-02-09 04:14:37
问题 According to Wikipedia: Implementations offering sound unification for all unifications are Qu-Prolog and Strawberry Prolog and (optionally, via a runtime flag): XSB, SWI-Prolog and Tau Prolog. However, when I do apropos(occur) it only finds unify_with_occurs_check/2 . The man page doesn't mention "occur" either. How can the occurs check be enabled for all unifications in SWI-Prolog? 回答1: In the section on Environment Control, it lists the flags of the system. The occurs_check flag is the one

What occurs-check optimizations is SWI Prolog using?

笑着哭i 提交于 2021-01-27 07:07:40
问题 To quote the SICStus Prolog manual: The usual mathematical theory behind Logic Programming forbids the creation of cyclic terms, dictating that an occurs-check should be done each time a variable is unified with a term. Unfortunately, an occurs-check would be so expensive as to render Prolog impractical as a programming language. However, I ran these benchmarks (The Prolog ones) and saw fairly minor differences (less than 20%) in SWI Prolog between the occurs check (OC) being on and off: OC

Proper unify_with_occurs_check/2 in SWI-Prolog?

余生颓废 提交于 2021-01-16 01:13:52
问题 Got this strange behaviour. I was running these test cases: s1 :- Q=[[lambda,symbol(_3026),[cons,[quote,_3434], [quote,_3514]]],[quote,_3206]], P=[_3434|_3514], freeze(_3434, (write(foo), nl)), unify_with_occurs_check(P, Q). s2 :- Q=[[lambda,symbol(_3026),[cons,[quote,_3434], [quote,_3514]]],[quote,_3206]], P=[_3434|_3514], freeze(_3434, (write(foo), nl)), freeze(_3514, (write(bar), nl)), unify_with_occurs_check(P, Q). Now I get these results, where the outcome of s2 is wrong. The outcome is

Proper unify_with_occurs_check/2 in SWI-Prolog?

北慕城南 提交于 2021-01-16 01:09:28
问题 Got this strange behaviour. I was running these test cases: s1 :- Q=[[lambda,symbol(_3026),[cons,[quote,_3434], [quote,_3514]]],[quote,_3206]], P=[_3434|_3514], freeze(_3434, (write(foo), nl)), unify_with_occurs_check(P, Q). s2 :- Q=[[lambda,symbol(_3026),[cons,[quote,_3434], [quote,_3514]]],[quote,_3206]], P=[_3434|_3514], freeze(_3434, (write(foo), nl)), freeze(_3514, (write(bar), nl)), unify_with_occurs_check(P, Q). Now I get these results, where the outcome of s2 is wrong. The outcome is

Proper unify_with_occurs_check/2 in SWI-Prolog?

好久不见. 提交于 2021-01-16 01:08:47
问题 Got this strange behaviour. I was running these test cases: s1 :- Q=[[lambda,symbol(_3026),[cons,[quote,_3434], [quote,_3514]]],[quote,_3206]], P=[_3434|_3514], freeze(_3434, (write(foo), nl)), unify_with_occurs_check(P, Q). s2 :- Q=[[lambda,symbol(_3026),[cons,[quote,_3434], [quote,_3514]]],[quote,_3206]], P=[_3434|_3514], freeze(_3434, (write(foo), nl)), freeze(_3514, (write(bar), nl)), unify_with_occurs_check(P, Q). Now I get these results, where the outcome of s2 is wrong. The outcome is

Proper unify_with_occurs_check/2 in SWI-Prolog?

戏子无情 提交于 2021-01-16 01:08:46
问题 Got this strange behaviour. I was running these test cases: s1 :- Q=[[lambda,symbol(_3026),[cons,[quote,_3434], [quote,_3514]]],[quote,_3206]], P=[_3434|_3514], freeze(_3434, (write(foo), nl)), unify_with_occurs_check(P, Q). s2 :- Q=[[lambda,symbol(_3026),[cons,[quote,_3434], [quote,_3514]]],[quote,_3206]], P=[_3434|_3514], freeze(_3434, (write(foo), nl)), freeze(_3514, (write(bar), nl)), unify_with_occurs_check(P, Q). Now I get these results, where the outcome of s2 is wrong. The outcome is