Ex post facto is a Latin term meaning "from a thing done afterward." Ex post facto often refers to a law that applies retroactively, thereby criminalizing conduct that was legal when originally performed. The U.S. Constitution prohibits ex post facto laws. However, the Supreme Court has held that that the prohibition of retroactive laws applies only to criminal, not civil, laws.
A sentencing law violates the ex post facto prohibition if it operates both retrospectively and to the potential disadvantage of the defendant. This is not limited to substantive changes in the content and criteria of legal rules. Restrictions on the extent of favorable discretion that a court can exercise are within the ex post facto prohibition, too.
The ex post facto clause generally prohibits states from enacting any law that “changes the punishment, and inflicts a greater punishment than the law annexed to the crime, when it was committed.” For example, sex offender registration laws have been held not to violate the ex post facto clause on the basis that they are not intended as punishment, but as a deterrent against future offenses.