Hi all,
Been a while since I've posted, with school starting and all, but I
have been working on the forward-chaining algorithm after getting back
into First Order Predicate Calculus. I have a few questions, but
first, here is what I have so far (after about two hours):
(in-package :cl-user)
;;; The Forward Chaining Algorithm
;;; Philip Haddad 9\12\04
;; Function: Foward-chain
(defun forward-chain (knowledge-base sentences)
(cond ((rename sentence) sentences)
(t (add-renamed-sentence knowledge-base)))
(do (each-sentence-that-implies-result knowledge-base)
(unify (lambda (i)
(append (i sentences)))
subsitutions)
(match (subsitutions sentences))
(cond ((match-success sentence) sentences)
(t (add-subsitutions sentences)))
(do (find-and-infer (knowledge-base sentences
subsitutions result)))))
(defun find-and-infer (knowledge-base premises results subsitutions)
(cond ((null premises) nil)
((forward-chain (knowledge-base (subsitute (subsitutions results)))))
(t (unify given-sentences
(subsitute (subsitutions (car premises)))
subsitutions-two)
(find-and-infer (knowledge-base
(rest (premises results))
(compose (subsitutions subsitutions-two)))))))
I am using the puesdocode in AIAMA on pg. 173 as a guide. Here are my
questions:
1) What should be macros, and what should be other functions?
For example, should "rest" be a macro or a function?
2) Is this good so far, any suggestions on making it better?
I have yet to add the format statements in the functions to make the
algorithm show what it is doing. I am continully working on this until
school starts tomorrow ;-), so expect some updates soon.
One last thing, this algorithm uses genralized Modus Ponens, am I
coding it well in there? Any suggestions are more than welcome.
--
May the Source be with you.
neo88 (Philip Haddad)
> I am using the puesdocode in AIAMA on pg. 173 as a guide. Here are my
This is proof that I can not multitask at all. The page is 273.
> 1) What should be macros, and what should be other functions?
> For example, should "rest" be a macro or a function?
> 2) Is this good so far, any suggestions on making it better?
I now relieze how stupid it is to be asking this. Sorry. I am working
on the other functions now, more later. BTW, I also use google groups,
so I could not change my errors for a while, once again I apologize.
> I have yet to add the format statements in the functions to make the
> algorithm show what it is doing. I am continully working on this until
> school starts tomorrow ;-), so expect some updates soon.
>
> One last thing, this algorithm uses genralized Modus Ponens, am I
> coding it well in there? Any suggestions are more than welcome.
I am now doing that part differently. Sorry for the errors, and stupid
question about rest :-(
--
May the Source be with you.
neo88 (Philip Haddad)