Hyperedgereplacementjunglerewriting for term-rewriting systems and logic programming