System design as derivation via rewriting