It's been a loooong time since I wrote any longhand Relational Algebra, so I'll cheat and use SQL. All of this can be done pretty easily with relational algebra primitives.
And we can make up any operator we want as long as it uses a primitive, so (to save typing I created a view, but you could copy-pasta). I added a "Title" to post because otherwise you could skip it entirely and just use the comment table twice, but where's the fun in that?
<pre>
CREATE VIEW counts AS
( select count() AS comment_count, post_id
from comment
group by post_id )
SELECT id, title, comment_count
FROM post p
INNER JOIN counts AS c1
ON p.id = c1.post_id
WHERE NOT EXISTS( SELECT
FROM counts AS c2
WHERE c2.post_id != p.id
AND c2.comment_count > c1.comment_count )
</pre>
And we can make up any operator we want as long as it uses a primitive, so (to save typing I created a view, but you could copy-pasta). I added a "Title" to post because otherwise you could skip it entirely and just use the comment table twice, but where's the fun in that?
<pre> CREATE VIEW counts AS ( select count() AS comment_count, post_id from comment group by post_id )
SELECT id, title, comment_count FROM post p INNER JOIN counts AS c1 ON p.id = c1.post_id WHERE NOT EXISTS( SELECT FROM counts AS c2 WHERE c2.post_id != p.id AND c2.comment_count > c1.comment_count ) </pre>