Can Generative AI Solve Your In-Context Learning Problem? A Martingale Perspective