Occurs Check

5 views
Skip to first unread message

Jared Forsyth

unread,
Dec 6, 2012, 1:11:53 PM12/6/12
to byu-cs-330...@googlegroups.com
Why would we need an occurs check for ==? I don't understand how you could get recursive variables...

Jay McCarthy

unread,
Dec 6, 2012, 1:18:24 PM12/6/12
to BYU CS 330 Fall 2012
It's hard to answer this without giving a test case.

Remember when talking about the occurs check in type inference, we were worried about constraints like:

List(X) = List(List(X))            (pg. 282)

i.e. A variable (X) being equated with a container (List) that contains the variable.

Given that Prolog has variables and containers (cons and logic variables), why would you think this is not possible?

Jay




On Thu, Dec 6, 2012 at 11:11 AM, Jared Forsyth <jaba...@gmail.com> wrote:
Why would we need an occurs check for ==? I don't understand how you could get recursive variables...

--
 
 



--
Jay McCarthy <j...@cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay

"The glory of God is Intelligence" - D&C 93

Jared Forsyth

unread,
Dec 6, 2012, 1:22:18 PM12/6/12
to byu-cs-330...@googlegroups.com
This is probably due to my very limited understanding of prolog. In the assignment description, there aren't any examples using cons at all. Could you give me one?


--
 
 



--
Jared



Jay McCarthy

unread,
Dec 6, 2012, 1:25:41 PM12/6/12
to BYU CS 330 Fall 2012
Sure.

(=find-all (x y) (== (cons x y) (cons 1 2))) should return (list (list (list 'x 1) (list 'y 2)))

Jay

Jared Forsyth

unread,
Dec 6, 2012, 1:33:27 PM12/6/12
to byu-cs-330...@googlegroups.com
Ok awesome thanks.


--
 
 



--
Jared



Reply all
Reply to author
Forward
0 new messages