![Page 1: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string](https://reader033.vdocuments.site/reader033/viewer/2022060320/5f0d1a2e7e708231d438b08a/html5/thumbnails/1.jpg)
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
![Page 2: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string](https://reader033.vdocuments.site/reader033/viewer/2022060320/5f0d1a2e7e708231d438b08a/html5/thumbnails/2.jpg)
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
![Page 3: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string](https://reader033.vdocuments.site/reader033/viewer/2022060320/5f0d1a2e7e708231d438b08a/html5/thumbnails/3.jpg)
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
![Page 4: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string](https://reader033.vdocuments.site/reader033/viewer/2022060320/5f0d1a2e7e708231d438b08a/html5/thumbnails/4.jpg)
String Theory Used for mathematically modeling a Queue Ø Γ - is the alphabet, e.g., Γ = Z
SIGCSE 2013 Special Session 4 Math Reasoning
![Page 5: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string](https://reader033.vdocuments.site/reader033/viewer/2022060320/5f0d1a2e7e708231d438b08a/html5/thumbnails/5.jpg)
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
![Page 6: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string](https://reader033.vdocuments.site/reader033/viewer/2022060320/5f0d1a2e7e708231d438b08a/html5/thumbnails/6.jpg)
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
![Page 7: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string](https://reader033.vdocuments.site/reader033/viewer/2022060320/5f0d1a2e7e708231d438b08a/html5/thumbnails/7.jpg)
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
![Page 8: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string](https://reader033.vdocuments.site/reader033/viewer/2022060320/5f0d1a2e7e708231d438b08a/html5/thumbnails/8.jpg)
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
![Page 9: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string](https://reader033.vdocuments.site/reader033/viewer/2022060320/5f0d1a2e7e708231d438b08a/html5/thumbnails/9.jpg)
Or Maybe I Should …
Ø Do that proof of correctness thingy that my professor showed us.
SIGCSE 2013 Special Session 9 Math Reasoning
![Page 10: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string](https://reader033.vdocuments.site/reader033/viewer/2022060320/5f0d1a2e7e708231d438b08a/html5/thumbnails/10.jpg)
Accessing the RESOLVE Web Interface
SIGCSE 2013 Special Session 10 Math Reasoning
![Page 11: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string](https://reader033.vdocuments.site/reader033/viewer/2022060320/5f0d1a2e7e708231d438b08a/html5/thumbnails/11.jpg)
Accessing Components
SIGCSE 2013 Special Session 11 Math Reasoning