Ex Post Facto

Literally, "after the fact." This refers to laws or rules that prohibit and attempt to punish behavior engaged in legally before the enactment of the law.