Artificial Intelligence by Rich and Knight covers these topic well. In particular see the sections on scripts for more detail on more complicated scripts with varying tracks. And also a more comprehensive treatment of CYC.
Knowledge Representation: An AI perspective by H. Reichgelt, Ablex, New York covers all aspects of this topic with good examples.
The Essentials of AI by Ginsberg provides some useful background information
The Handbook of Artificial Intelligence (Vol. 1, Ch 3) provides a good concise treatment of this area. Details of MARGIE, SAM and PAM may also be found in Vol. 1, Ch 4.
Examples of how MARGIE and SAM is coded in LISP is given in AI with Common Lisp by Noyes.