Three different ways to rewrite the rule:
(defrule brothers
(father-son ?father ?son)
(father-son ?father2 ?son2)
(mother-son ?mother ?son)
(mother-son ?mother2 ?son2)
(test (neq ?son ?son2))
(test (eq ?father ?father2))
(test (eq ?mother ?mother2))
=>
(assert (brothers ?son ?son2))
(printout t "new fact: " ?son " and " ?son2 " are brothers."
crlf))
(defrule brothers
(father-son ?father ?son)
(father-son ?father2 ?son2)
(mother-son ?mother ?son)
(mother-son ?mother2 ?son2)
(test (and (neq ?son ?son2)
(eq ?father ?father2)
(eq ?mother ?mother2)))
=>
(assert (brothers ?son ?son2))
(printout t "new fact: " ?son " and " ?son2 " are brothers."
crlf))
(defrule brothers
(father-son ?father ?son)
(father-son ?father ?son2&~?son)
(mother-son ?mother ?son)
(mother-son ?mother ?son2)
=>
(assert (brothers ?son ?son2))
(printout t "new fact: " ?son " and " ?son2 " are brothers."
crlf))