artificial intelligence homework 4
code here uses working with graphs in common lisp.
assume you have the following knowledge

create a decision tree based on the knowledge base above (ignore direction).
the graph with the electric layout algorithm:
the same graph with the layered layout algorithm:

(defparameter *homework4-knowledge-base*
'((implies (and a b ) e )
(implies (and a c ) k )
(implies (and a c d) f )
(implies (and c d ) g )
(implies (and e f ) h )
(implies (and f g ) i )
(implies (and f e g) j )
(implies (and k l ) (and m n))
(implies (and f d ) l )
a b c))
(graph-generate-tikz
(generate-graph-from-knowledge-base *homework4-knowledge-base*)
:directed t
:node-distance 60)
(graph-generate-tikz
(generate-graph-from-knowledge-base *homework4-knowledge-base*)
:directed t
:tikz-params "layered layout, grow=up, edges={-{Stealth[]}}, edges=rounded corners, level sep=40px")
using backward chaining, try to prove
using
,
and
as the data.
with common lisp logic programming:
the algorithm stopped at
, this makes sense, to prove
we need to use the formula
, so we need to prove the premises
, to prove
we use the formula
,
and
we already know are true, but
we have no way of proving is true, so thats where we fail to continue.
(let ((kb (copy-tree *homework4-knowledge-base*)))
(backward-chaining kb 'j))
J <- F <- A <- C <- D <-
use forward chaining and the data
,
, and
to fire as many rules as possible. what kind of rules did you fire? how would you explain your decision?
rules 9, 8, thats all, theres nothing more to do, lol
(let ((kb (copy-tree *homework4-knowledge-base*)))
(multiple-value-bind (substitution inference-alist-list)
(forward-chaining kb nil)
(forward-chaining-generate-tikz-graph inference-alist-list)))