Why would you conclude that the liar is telling the truth that they have any hats at all?
"for each hat in the set of hats I know. the statement 'the hat is green' is true"; the previous statement would be true if the set of hats I know is empty.
Incidentally, if you are a programmer it should be obvious that folding 'and' on an empty set must return True.
This is the contentious, formal-logicy part of the puzzle. "All my hats are green" as a logical statement, in most formal logic systems, would be true if I didn't own any hats (a so-called vacuous truth, because it doesn't mean anything, for similar reasons any statement conditioned on a false statement is true, e.g. "if 2+2=5, then I am god" is similarly vacuously true). So if I'm a liar and that statement is false, it must be false by me owning a non-green hat. But colloquially, people will usually break it down into the logical statement: "I own at least one hat and all my hats are green" (because most people don't consider vacuous truths to be relevant in most contexts), in which case it will be false if I own no hats
(other systems of logic exist which will attempt to resolve this. Forcing such statements to be false makes things much trickier formally, as does e.g. three-valued logic to try to avoid assigning truth or falsity to such statements)