(rule) ( head body pos -- )


Vocabulary
logic.private

Inputs
headan object
bodyan object
posan object


Outputs
None

Definition


:: (rule) ( head body pos -- )
reset-anonymouse-var-no head replace-'__' def>goal
:> head-goal body replace-'__' normalize split-body pos
at-the-beginning = [ reverse ] when dup empty? [
head-goal swap 2array 1vector head-goal pred>>
[ pos at-the-end = [ swap ] when append! ] change-defs
drop
] [
f :> negation?! [
[
{
{ ~quotation~ ~quotation~ }
{ ~quotation~ ~quotation~ }
{ ~quotation~ ~quotation~ }
{ ~quotation~ ~quotation~ }
{ ~quotation~ ~quotation~ }
[ drop dummy-item f negation?! ]
} cond
] map dummy-item swap remove :> body-goals
V{ { head-goal body-goals } } head-goal pred>>
[ pos at-the-end = [ swap ] when append! ]
change-defs drop
] each
] if ;