Coinductive Foundations of Infinitary Rewriting and Infinitary Equational Logic