;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;; Knowledge Representation and Reasoning CSC 486/2506, Fall 2006 ;; ;; Sample file for exercise 4, assignment 1 (Scheme implementation) ;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;; (solve_tab_sat C): C is a list of clauses where each clause is a ;; list of literals. ;; ;; for instance this is possible clause where literals are ;; represented with integers: ;; ;; ((1 -2) (2 -8) (-5 -4 3) (5) (4 -2 -6)) ;; ;; YOU SHOULD IMPLEMENT THIS FUNCTION. THE PREDICATE SHOULD PRINT ;; "YES" IF C IS SATISFIABLE AND "NO" OTHERWISE ;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;; this implementation only prints the set of clauses, you should ;; implement your program here. ;; (define (solve_horn_sat c) (display c) ) ;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;; OBS: You should not modify anything below ;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;; (hornsat File): takes a file name, reads its clauses and calls ;; solve_horn_sat/1 with such set of clauses ;; ;; ;; This should work under MIT Scheme (tested) ;; ;; DO NOT CHANGE ;;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% (define (hornSat filename) (let ((idfile (open-input-file filename))) (solve_horn_sat (read-list idfile)))) (define (read-list idfile) (let ((p (read idfile))) (if (equal? p '(end)) '() (cons p (read-list idfile)))))