pattern matcher: partial fix for bug #1025

Just because a clause is grounded does not mean that all the variables
in it are grounded.
iaddtiionoal pattern matcher fixes
More fixes for bad matching.
Updated docuumentation
Pattern matcher: simplify logic slightly
Merge pull request #1072 from linas/shufix

bugfix pattern matcher for bug #1025