Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is...

Preview:

Citation preview

Debugging an Operation

Joan Krone – Denison University Joseph Hollingsworth – Indiana University Southeast

Using a Failed Proof of Correctness as a Guide

SIGCSE 2013 Special Session 1 Math Reasoning

What Went Wrong?

Ø  Student implements an operation

Ø  Student creates a testing harness a small client program

Ø  Student runs the testing harness

Ø Receives unexpected output

Ø The operation doesn’t seem to do anything!

SIGCSE 2013 Special Session 2 Math Reasoning

Invert

The outgoing Q equals the reverse of the incoming Q •  #Q – incoming

•  Q – outgoing

P_Queue is a preemptable queue

•  Has one additional operation – Inject

Operation Invert (Q: P_Queue); ensures Q = Reverse(#Q);

SIGCSE 2013 Special Session 3 Math Reasoning

String Theory Used for mathematically modeling a Queue Ø Γ - is the alphabet, e.g., Γ = Z

SIGCSE 2013 Special Session 4 Math Reasoning

String Theory Used for mathematically modeling a Queue Ø Γ - is the alphabet, e.g., Γ = Z

Ø Example strings: •  α = <4,22,3,17> string of 4 integers •  β = < > empty string

SIGCSE 2013 Special Session 5 Math Reasoning

String Theory Used for mathematically modeling a Queue Ø Γ - is the alphabet, e.g., Γ = Z

Ø Example strings: •  α = <4,22,3,17> string of 4 integers •  β = < > empty string

Ø Concatenation, Length, Reverse •  <-5> o α o <101> = <-5,4,22,3,17,101>

•  |α| = 4

•  Reverse(α) = <17,3,22,4>

•  Reverse(α o <101>) = <101,17,3,22,4>

SIGCSE 2013 Special Session 6 Math Reasoning

Testing Harness for Invert Begin

q: P_Queue; Enqueue(3, q); Enqueue(2, q); Enqueue(1, q); Writeln("q before Invert = ", q); Invert(q); Writeln("q after Invert = ", q);

end;

Output: q before Invert = <3,2,1> q after Invert = <3,2,1>

SIGCSE 2013 Special Session 7 Math Reasoning

How to Debug? I Could Try …

Ø Using one of those genetic algorithms to make random mutations to my code …

SIGCSE 2013 Special Session 8 Math Reasoning

Or Maybe I Should …

Ø Do that proof of correctness thingy that my professor showed us.

SIGCSE 2013 Special Session 9 Math Reasoning

Accessing the RESOLVE Web Interface

SIGCSE 2013 Special Session 10 Math Reasoning

Accessing Components

SIGCSE 2013 Special Session 11 Math Reasoning

Recommended