logic: add reduceg pseudo-relation

Add a reduceg psuedo-relation that works similar to reduce and binary
operations with ternary relations.