Decision testing with MS Copilot
Task 1 (student 1)
Using MS Copilot identify statements for the RegulaFalsi function. Assign a tag to for each identified statement. Present the list of statements with tags. Write the prompt and the chatbot answer. Discuss the result.
Does it properly recognized that the FOR instruction consists of 3 statements? Did it handle properly nested IFs?
Function Declaration-Tag: DefinitionVariable Initialization-Tag: InitializationFOR Loop Components:Loop Initialization-Tag: Loop SetupLoop Condition-Tag: Loop ConditionLoop Update-Tag: Loop Update
Nested IF Statements:Outer IF Condition-Tag: Decision MakingInner IF Condition-Tag: Decision MakingInner ELSE Block-Tag: Alternative PathOuter ELSE Block-Tag: Alternative Path
Mathematical Computation-Tag: CalculationReturn Statement-Tag: OutputTheFOR loopcorrectly consists of three statements: initialization, condition, and update. If the AI properly recognizes this, it demonstrates an understanding of structured loops.Nested IFsare tricky because they involve conditional branching within another condition. Proper handling requires ensuring the logical flow of execution remains intact, and the AI must not misinterpret the nested structure.
Task 2 (student 2)
Using MS Copilot generate the Control Flow Graph in the DOT language for the RegulaFalsi function. Write the prompt and the chatbot answer. Discuss the result.
Does the CFG has the same structure as the CFG created by a human in the previous section of the book?
When the Task 1 is finished, use the generated instruction list with tags as the hint for Copilot. Did it help them co correct the CFG (now the CFG should be correct)? Discuss the result.
digraph RegulaFalsi_CFG {
node [shape=rectangle];
start;
readInputs [label="Read inputs: a, b, tol, max_iter"];
computeFaFb [label="Compute fa = f(a), fb = f(b)"];
checkRootInterval [label="if (fa * fb >= 0)"];
returnNoRoot [label="return -1"];
loopInit [label="for (int i = 0; i < max_iter; ++i)"];
computeC [label="Compute c = (a * fb - b * fa) / (fb - fa)"];
computeFc [label="Compute fc = f(c)"];
checkTolerance [label="if (fabs(fc) < tol)"];
returnRoot [label="return c"];
checkSign [label="if (fa * fc < 0)"];
updateB [label="b = c; fb = fc"];
updateA [label="a = c; fa = fc"];
returnMaxIter [label="return -1"];
start -> readInputs;
readInputs -> computeFaFb;
computeFaFb -> checkRootInterval;
checkRootInterval -> returnNoRoot [label="True"];
checkRootInterval -> loopInit [label="False"];
loopInit -> computeC [label="True"];
computeC -> computeFc;
computeFc -> checkTolerance;
checkTolerance -> returnRoot [label="True"];
checkTolerance -> checkSign [label="False"];
checkSign -> updateB [label="True"];
checkSign -> updateA [label="False"];
updateB -> loopInit;
updateA -> loopInit;
loopInit -> returnMaxIter [label="False"];
}
Task 3. (student 3)
Convince Copilot to write a decision test for the function RegulaFalsi in the C language (I think you need to explain to the chatbot what a decision test is). Write the prompt and the chatbot answer. Discuss the result, compare it with the code written by a human in the previous section of the book.