How prediction markets work: AMM vs CLOB comparison, LMSR pricing formula, betting fairness problem, and Sybil arbitrage.