# A Model with Iterative Trials for Correcting Logic Errors in Source Code
## 5 Experimental Results and Discussion
### Use-Cases  
Figure 4 shows an example of logic error correction using the proposed model for a sample programming task. The selected programming task is to find and output the cube of a given integer. An example of incorrect code shown in the upper left of the figure outputs the square of the given integer. The logic error in this source code is \"x\"x\" on the fifth line. Therefore, if \"x\" is inserted in the source code, the source code will become correct. The table on the upper right in Figure 4 lists the prediction results for one application of the proposed model to the incorrect code. The candidate with the lowest probability of occurrence for the next word is the position of \")\", and the proposed revision is \"*\". This demonstrates that the model can correctly predict this logic error. In addition, the proposed model predicts \"insert * between x and \")\" from this information. The table at the bottom right of the figure shows the correction candidates when the proposed model is applied a second time to the source code that has already been corrected once. The candidate with the lowest probability of appearance is the position of \")\", and the proposed amendment is \"x\". From the obtained information, the overall prediction by the proposed model is thus \"insert x between * and\". Therefore, it is possible to correct all logic errors in this source code by applying the proposed model. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multicolumn{2}{c}{**Datasets**} & \multicolumn{4}{c}{**Top-\(k\) (\%)**} \\ \hline
**Task ID** & **Targets** & \(k=\infty\) & \(k=1\) & \(k=2\) & \(k=3\) \\ \hline ITP1\_1\_A & 1524 & 99.34 & 50.72 & 46.85 & 38.32 \\ ITP1\_1\_B & 630 & 99.84 & 90.79 & 85.08 & 43.17 \\ ITP1\_1\_C & 694 & 98.27 & 55.04 & 41.35 & 26.22 \\ ITP1\_1\_D & 500 & 99.60 & 47.00 & 28.40 & 8.20 \\ ITP1\_2\_A & 494 & 100.00 & 34.62 & 23.08 & 9.92 \\ ITP1\_2\_B & 727 & 100.00 & 54.61 & 44.70 & 30.12 \\ ITP1\_2\_C & 308 & 98.38 & 35.39 & 25.00 & 12.99 \\ ITP1\_2\_D & 350 & 98.57 & 24.00 & 9.43 & 2.57 \\ ITP1\_3\_A & 558 & 99.82 & 74.91 & 65.41 & 40.32 \\ ITP1\_3\_B & 336 & 98.51 & 45.54 & 22.92 & 7.44 \\ ITP1\_3\_C & 255 & 96.08 & 40.39 & 21.96 & 8.24 \\ ITP1\_3\_D & 379 & 100.00 & 57.26 & 33.77 & 14.78 \\ ITP1\_4\_A & 56 & 100.00 & 57.14 & 41.07 & 21.43 \\ ITP1\_4\_B & 42 & 92.86 & 19.05 & 11.90 & 2.38 \\ ITP1\_4\_C & 85 & 97.65 & 40.00 & 20.00 & 5.88 \\ ITP1\_4\_D & 63 & 98.41 & 12.70 & 3.17 & 0.00 \\ ITP1\_5\_A & 59 & 96.61 & 37.29 & 23.73 & 8.47 \\ ITP1\_5\_B & 132 & 96.21 & 19.70 & 9.09 & 1.52 \\ ITP1\_5\_C & 81 & 93.83 & 25.93 & 16.05 & 4.94 \\ ITP1\_5\_D & 50 & 100.00 & 14.00 & 6.00 & 2.00 \\ ITP1\_6\_A & 83 & 100.00 & 22.89 & 9.64 & 4.82 \\ ITP1\_6\_B & 70 & 90.00 & 7.14 & 2.86 & 1.43 \\ ITP1\_6\_C & 142 & 100.00 & 28.17 & 10.56 & 3.52 \\ ITP1\_6\_D & 89 & 96.63 & 10.11 & 3.37 & 1.12 \\ ITP1\_7\_A & 123 & 98.37 & 17.89 & 8.13 & 3.25 \\ ITP1\_7\_B & 183 & 98.91 & 17.49 & 14.21 & 7.10 \\ ITP1\_7\_C & 89 & 95.51 & 26.97 & 21.35 & 11.24 \\ ITP1\_7\_D & 23 & 100.00 & 4.35 & 0.00 & 0.00 \\ ITP1\_8\_A & 66 & 87.88 & 22.73 & 12.12 & 3.03 \\ ITP1\_8\_B & 46 & 95.65 & 26.09 & 21.74 & 13.04 \\ ITP1\_8\_C & 51 & 100.00 & 5.88 & 0.00 & 0.00 \\ ITP1\_8\_D & 5 & 100.00 & 0.00 & 0.00 & 0.00 \\ \hline Average & 95.54 & 33.85 & 22.70 & 11.12 \\ \hline \hline \end{tabular}
\end{table} 
Table 8: Detection performance. In contrast, for the conventional model without iterative trials, the source code is modified using only the correction candidates obtained from the first trial. In the first trial, \"insert *\" between \"x\" and \")\" is performed, as in the case of the proposed model. However, since \"x\" is not present in the correction candidates in this first trial, not all logic errors in the source code can be corrected. Therefore, the conventional model can only correct some and not all of the logic errors in the incorrect code. The aim of debugging support in programming education is to provide learners with hints for correcting their source codes.