(defrule nal-1-deduction-jb
?judge <- (object (is-a JUDGEMENT)
(stm ?s1)
(freq ?f1)
(conf ?c1)
(justs $?jsts1)
)
?belief <- (object (is-a BELIEF)
(stm ?s2)
(freq ?f2)
(conf ?c2)
(justs $?jsts2)
)
(object (is-a STATEMENT) (name =(instance-name ?s1))
(copula inherits)
(subj ?a) (pred ?b))
(object (is-a STATEMENT) (name =(instance-name ?s2))
(copula inherits)
(subj ?b) (pred ?c))
=>
(bind ?freq (* ?f1 ?f2))
(bind ?conf (* ?f1 ?c1 ?f2 ?c2))
(bind ?stm (make-instance (gensym*) of STATEMENT
(copula inherits)
(subj ?a) (pred ?c)))
(make-instance (gensym*) of JUDGEMENT
(stm ?stm)
(freq ?freq) (conf ?conf)
(justs ?jsts1 ?jsts2))
)
(defglobal ?*delete-time-delta* = 600.0)
(assert (tick)) ; Tick-tock, keep watching for out-of-date tasks
(deffun non-overlapping (?$x ?$y)
(defclass STATEMENTSORT (is-a USER)
(role abstract)
(slot stm (type INSTANCE-NAME)) )
(defclass BELIEFSORT (is-a USER)
(role abstract)
(slot freq (type FLOAT) (range 0.0 1.0) (default 1.0))
(slot conf (type FLOAT) (range 0.0 1.0) (default 0.9))
(multislot justs (type SYMBOL) (default-dynamic (gensym*)))
)
(defclass TASK (is-a STATEMENTSORT)
(role abstract)
(slot delete-time (type FLOAT) (default-dynamic (+ ?*delete-time-delta* (time))))
)
(defclass TERM (is-a USER)
(role abstract)
)
(defclass BELIEF (is-a BELIEFSORT STATEMENTSORT)
(role concrete)
(pattern-match reactive)
)
(defclass JUDGEMENT (is-a BELIEFSORT TASK)
(role concrete)
(pattern-match reactive)
)
(defclass QUESTION (is-a TASK)
(role concrete)
(pattern-match reactive)
(slot asker (type STRING) (default ""))
(slot best-e (type FLOAT) (range 0.0 1.0) (default 0.0))
)
(defclass STATEMENT (is-a TERM)
(role concrete)
(pattern-match reactive)
(slot copula (type SYMBOL)
(allowed-symbols inherits similar implies equiv)
(default inherits)
)
(slot subj (type INSTANCE-NAME)) (slot pred (type INSTANCE-NAME)) )
(defclass ATOMTERM (is-a TERM)
(role concrete)
(pattern-match reactive)
(slot label (type LEXEME))
)
(definstances SYLLOGISM
(dogterm of ATOMTERM (label dog))
(mammalterm of ATOMTERM (label mammal))
(animalterm of ATOMTERM (label animal))
(dogmammalstm of STATEMENT (copula inherits)
(subj [dogterm])
(pred [mammalterm]))
(mammalanimalstm of STATEMENT (copula inherits)
(subj [mammalterm])
(pred [animalterm]))
(dmjudge of JUDGEMENT
(stm [dogmammalstm])
(freq 0.9) (conf 0.9))
(mabelief of BELIEF
(stm [mammalanimalstm])
(freq 0.9) (conf 0.9))
)
(defrule maint-delete-old-judgement
?tk <- (tick)
?task <- (object (is-a JUDGEMENT)
(delete-time ?t)
(stm ?s)
(freq ?f)
(conf ?c)
(justs $?jsts))
(test (< ?t (time)))
=>
(retract ?tk)
(assert (tick))
(make-instance (gensym*) of BELIEF
(stm ?s)
(freq ?f)
(conf ?c)
(justs ?jsts))
(unmake-instance ?task))
(defrule maint-delete-old-question
?tk <- (tick)
?task <- (object (is-a QUESTION)
(delete-time ?t)
(stm ?s))
(test (< ?t (time)))
=>
(retract ?tk)
(assert (tick))
(unmake-instance ?task))
(defrule revision-jb
?judge <- (object (is-a JUDGEMENT)
(stm ?s1)
(freq ?f1)
(conf ?c1)
(justs $?justs1))
?belief <- (object (is-a BELIEF)
(stm ?s2)
(freq ?f2)
(conf ?c2)
(justs $?justs2))
(test (non-overlap ?justs1 ?justs2))
(object (is-a STATEMENT) (name ?s1)
(subj ?a) (pred ?b) (copula ?cop))
(object (is-a STATEMENT) (name ?s2)
(subj ?a) (pred ?b) (copula ?cop))
=>
(bind ?freq (/ (+ (* ?f1 ?c1 (- 1 ?c2))
(* ?f2 ?c2 (- 1 ?c1)))
(+ (* ?c1 (- 1 ?c2))
(* ?c2 (- 1 ?c1)))))
(bind ?conf (/ (+ (* ?c1 (- 1 ?c2))
(* ?c2 (- 1 ?c1)))
(+ (* ?c1 (- 1 ?c2))
(* ?c2 (- 1 ?c1))
(* (-1 ?c1) (-1 ?c2)))))
(make-instance (gensym*) of JUDGEMENT
(stm ?s1)
(freq ?freq) (conf ?conf)
(justs ?justs1 ?justs2)))
(defrule nal-1-deduction-jb1
?judge <- (object (is-a JUDGEMENT)
(stm ?s1)
(freq ?f1)
(conf ?c1)
(justs $?jsts1)
)
?belief <- (object (is-a BELIEF)
(stm ?s2)
(freq ?f2)
(conf ?c2)
(justs $?jsts2)
)
(object (is-a STATEMENT) (name ?s1)
(copula inherits)
(subj ?a) (pred ?b))
(object (is-a STATEMENT) (name ?s2)
(copula inherits)
(subj ?b) (pred ?c))
=>
(bind ?freq (* ?f1 ?f2))
(bind ?conf (* ?f1 ?c1 ?f2 ?c2))
(bind ?stm (make-instance (gensym*) of STATEMENT
(copula inherits)
(subj ?a) (pred ?c)))
(modify-instance ?judge
(delete-time (+ ?*delete-time-delta* (time))))
(make-instance (gensym*) of JUDGEMENT
(stm (instance-name ?stm))
(freq ?freq) (conf ?conf)
(justs ?jsts1 ?jsts2))
)
(defrule nal-1-deduction-jb2
?judge <- (object (is-a JUDGEMENT)
(stm ?s1)
(freq ?f1)
(conf ?c1)
(justs $?jsts1)
)
?belief <- (object (is-a BELIEF)
(stm ?s2)
(freq ?f2)
(conf ?c2)
(justs $?jsts2)
)
(object (is-a STATEMENT) (name ?s1)
(copula inherits)
(subj ?b) (pred ?c))
(object (is-a STATEMENT) (name ?s2)
(copula inherits)
(subj ?a) (pred ?b))
=>
(bind ?freq (* ?f1 ?f2))
(bind ?conf (* ?f1 ?c1 ?f2 ?c2))
(bind ?stm (make-instance (gensym*) of STATEMENT
(copula inherits)
(subj ?a) (pred ?c)))
(modify-instance ?judge
(delete-time (+ ?*delete-time-delta* (time))))
(make-instance (gensym*) of JUDGEMENT
(stm (instance-name ?stm))
(freq ?freq) (conf ?conf)
(justs ?jsts1 ?jsts2))
)
(defrule nal-1-deduction-qb1
?quest <- (object (is-a QUESTION)
(stm ?s1)
)
?belief <- (object (is-a BELIEF)
(stm ?s2)
)
(object (is-a STATEMENT) (name ?s1)
(copula inherits)
(subj ?a) (pred ?b))
(object (is-a STATEMENT) (name ?s2)
(copula inherits)
(subj ?b) (pred ?c))
=>
(bind ?stm (make-instance (gensym*) of STATEMENT
(copula inherits)
(subj ?a) (pred ?c)))
(modify-instance ?quest
(delete-time (+ ?*delete-time-delta* (time))))
(make-instance (gensym*) of QUESTION
(stm (instance-name ?stm)))
)
(defrule nal-1-deduction-qb2
?quest <- (object (is-a QUESTION)
(stm ?s1)
)
?belief <- (object (is-a BELIEF)
(stm ?s2)
)
(object (is-a STATEMENT) (name ?s1)
(copula inherits)
(subj ?b) (pred ?c))
(object (is-a STATEMENT) (name ?s2)
(copula inherits)
(subj ?a) (pred ?b))
=>
(bind ?stm (make-instance (gensym*) of STATEMENT
(copula inherits)
(subj ?a) (pred ?c)))
(modify-instance ?quest
(delete-time (+ ?*delete-time-delta* (time))))
(make-instance (gensym*) of QUESTION
(stm (instance-name ?stm)))
)
(defglobal ?*delete-time-delta* = 600.0)
(defclass STATEMENTSORT (is-a USER)
(role abstract)
(slot stm (type INSTANCE-NAME)) )
(defclass BELIEFSORT (is-a USER)
(role abstract)
(slot freq (type FLOAT) (range 0.0 1.0) (default 1.0))
(slot conf (type FLOAT) (range 0.0 1.0) (default 0.9))
(multislot justs (type SYMBOL) (default (create$ (gensym*))))
)
(defclass TASK (is-a STATEMENTSORT)
(role abstract)
(slot delete-time (type FLOAT) (default (+ ?*delete-time-delta* (time))))
)
(defclass TERM (is-a USER)
(role abstract)
)
(defclass BELIEF (is-a BELIEFSORT STATEMENTSORT)
(role concrete)
(pattern-match reactive)
)
(defclass JUDGEMENT (is-a BELIEFSORT TASK)
(role concrete)
(pattern-match reactive)
)
(defclass QUESTION (is-a TASK)
(role concrete)
(pattern-match reactive)
(slot asker (type STRING) (default ""))
(slot best-e (type FLOAT) (range 0.0 1.0) (default 0.0))
)
(defclass STATEMENT (is-a TERM)
(role concrete)
(pattern-match reactive)
(slot copula (type SYMBOL)
(allowed-symbols inherits similar implies equiv)
(default inherits)
)
(slot subj (type INSTANCE-NAME)) (slot pred (type INSTANCE-NAME)) )
(defclass ATOMTERM (is-a TERM)
(role concrete)
(pattern-match reactive)
(slot label (type LEXEME))
)
(definstances SYLLOGISM
(dogterm of ATOMTERM (label dog))
(mammalterm of ATOMTERM (label mammal))
(animalterm of ATOMTERM (label animal))
(dogmammalstm of STATEMENT (copula inherits)
(subj [dogterm])
(pred [mammalterm]))
(mammalanimalstm of STATEMENT (copula inherits)
(subj [mammalterm])
(pred [animalterm]))
(dmjudge of JUDGEMENT
(stm [dogmammalstm])
(freq 0.9) (conf 0.9))
(mabelief of BELIEF
(stm [mammalanimalstm])
(freq 0.9) (conf 0.9))
)
(defrule maint-delete-old-judgement
?task <- (object (is-a JUDGEMENT)
(delete-time ?t)
(stm ?s)
(freq ?f)
(conf ?c)
(justs $?jsts))
(test (< ?t (time)))
=>
(make-instance (gensym*) of BELIEF
(stm ?s)
(freq ?f)
(conf ?c)
(justs ?jsts))
(unmake-instance ?task))
(defrule maint-delete-old-task
?task <- (object (is-a QUESTION)
(delete-time ?t)
(stm ?s)
(test (< ?t (time)))
=>
(unmake-instance ?task))
(defrule nal-1-deduction-jb1
?judge <- (object (is-a JUDGEMENT)
(stm ?s1)
(freq ?f1)
(conf ?c1)
(justs $?jsts1)
)
?belief <- (object (is-a BELIEF)
(stm ?s2)
(freq ?f2)
(conf ?c2)
(justs $?jsts2)
)
(object (is-a STATEMENT) (name ?s1)
(copula inherits)
(subj ?a) (pred ?b))
(object (is-a STATEMENT) (name ?s2)
(copula inherits)
(subj ?b) (pred ?c))
=>
(bind ?freq (* ?f1 ?f2))
(bind ?conf (* ?f1 ?c1 ?f2 ?c2))
(bind ?stm (make-instance (gensym*) of STATEMENT
(copula inherits)
(subj ?a) (pred ?c)))
(modify-instance ?judge
(delete-time (+ ?*delete-time-delta* (time))))
(make-instance (gensym*) of JUDGEMENT
(stm (instance-name ?stm))
(freq ?freq) (conf ?conf)
(justs ?jsts1 ?jsts2))
)
(defrule nal-1-deduction-jb2
?judge <- (object (is-a JUDGEMENT)
(stm ?s1)
(freq ?f1)
(conf ?c1)
(justs $?jsts1)
)
?belief <- (object (is-a BELIEF)
(stm ?s2)
(freq ?f2)
(conf ?c2)
(justs $?jsts2)
)
(object (is-a STATEMENT) (name ?s1)
(copula inherits)
(subj ?b) (pred ?c))
(object (is-a STATEMENT) (name ?s2)
(copula inherits)
(subj ?a) (pred ?b))
=>
(bind ?freq (* ?f1 ?f2))
(bind ?conf (* ?f1 ?c1 ?f2 ?c2))
(bind ?stm (make-instance (gensym*) of STATEMENT
(copula inherits)
(subj ?a) (pred ?c)))
(modify-instance ?judge
(delete-time (+ ?*delete-time-delta* (time))))
(make-instance (gensym*) of JUDGEMENT
(stm (instance-name ?stm))
(freq ?freq) (conf ?conf)
(justs ?jsts1 ?jsts2))
)