He can then analyze the testimony, sentence by sentence, and "press" the witness for more information, or present to the court a piece of evidence that proves the witness's claim to be false. As lies and inaccuracies are exposed, the witness typically keeps changing their testimony until finally the truth comes to light.
However, presenting wrong evidence or otherwise making errors will cause the judge to penalize you, and if you've accumulated too many penalties, he will lose his patience and declare a guilty verdict immediately.