[Solved] CSCE625: Assignment 1 : Search, BFS, and Lazy Evaluation

$25

File Name: CSCE625:_Assignment_1_:_Search,_BFS,_and_Lazy_Evaluation.zip
File Size: 527.52 KB

SKU: [Solved] CSCE625: Assignment 1 : Search, BFS, and Lazy Evaluation Category: Tag:
5/5 - (1 vote)

Question

Consider the following puzzle. It is in the vein of Russell and Norvigs toy problem on page 73, that they attribute to Donald Knuth.

You are given a pair of numbers: the first is the seed, x0, and the second the target xf. You are provided, additionally, with two functions f : RR and g : RR.

Puzzle: Write a program to give either the minimal number of function applications (of f and g) needed to reach xf from x0, or state that one cannot reach xf from x0.

Approach

This problem is from https://nmattia.com/posts/2016-07-31-bfs-tree.html

In that blog post Nicolas Mattia considers the two functions f and g defined as follows:

f(x) = 2x + 1 and g(x) = 3x + 1.

The author provides code to solve exactly this problem on that page. Actually, that page is code, written in Haskell. (Look up literate programming if youve never heard

of it.)

Task1

Convert his solution, for those two particular f and g functions, to Scheme. His approach is not quite the same as the straightforward stack-based method given in Russell and Norvig. Instead, it uses Haskells lazy evaluation to provide a sort of infinite data structure. You are to do the same thing: implement the search using lazy evaluation.

1

We have Gambit Scheme installed on the compute.cs.tamu.edu server. The page at http://www.iro.umontreal.ca/gambit/doc/gambit.html provides some information that you might find useful in getting up and running with the interpreter and compiler.

By default Scheme uses eager evaluation. You have to make use of the delay and force keywords. Details on this can be found here: http://www.shido.info/

lisp/scheme_lazy_e.html

(Note that the text in that guide uses Guile, not Gambit Scheme, so the promise? type checking function isnt available for us. The other functionality is supported, however.)

Task2

Reflect on these things:

  • Consider Knuths original problem. That requires more than just an f and g. Can you pose his problem with a modification of your code?
  • What properties are needed to ensure that your program is guaranteed to give a solution to the puzzle?

2

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSCE625: Assignment 1 : Search, BFS, and Lazy Evaluation
$25