Serg wrote:Hi, Denis!
Could you post an example of spotting some whip/braid? I'd like to see not final result (which can be found in "Puzzles" division of this Forum), but steps of finding some whip/braid. It looks like you know magic way of intellectual search of a pattern w/o some BFS, DFS etc.
Serg
Hi Serg,
There's nothing magic here and nothing new either. It's the very classical technology of inference engines (dating back to the 1970s, with improvements since them). The rules are the code. The main function of the inference engine is pattern-matching, i.e. finding the combinations of facts that match the rules. There's no way I could post an example of finding a whip/braid, as this is precisely what pattern-matching does automatically.
If you want details, check any of the files in "CSP-Rules-Generic/CHAIN-RULES-SPEED/WHIPS". For instance, here is the "code" for a whip[3] - pure logic definition (in a syntax very close to FOL):
- Code: Select all
(defrule whip[3]
(declare (salience ?*whip[3]-salience*))
(chain
(type partial-whip)
(context ?cont)
(length 2)
(target ?zzz)
(llcs $?llcs)
(rlcs $?rlcs)
(csp-vars $?csp-vars)
(last-rlc ?last-rlc)
)
;;; ?new-llc
(exists-link ?cont ?new-llc&~?zzz&:(not (member$ ?new-llc $?llcs))&:(not (member$ ?new-llc $?rlcs)) ?last-rlc)
;;; ?new-csp
(is-csp-variable-for-label (csp-var ?new-csp&:(not (member$ ?new-csp $?csp-vars))) (label ?new-llc))
(forall (csp-linked ?cont ?new-llc ?xxx ?new-csp)
(exists (exists-link ?cont ?xxx ?vvv&:(or (eq ?vvv ?zzz) (member$ ?vvv $?rlcs))))
)
?cand <- (candidate (context ?cont) (status cand) (label ?zzz))
=>
(retract ?cand)
(if (eq ?cont 0) then (bind ?*nb-candidates* (- ?*nb-candidates* 1)))
(if (or ?*print-actions* ?*print-L3* ?*print-whip* ?*print-whip-3*) then
(print-whip 3 ?zzz $?llcs $?rlcs $?csp-vars ?new-llc . ?new-csp)
)
)