11
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

Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α = string

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Debugging an Operation - Clemson...String Theory Used for mathematically modeling a Queue ! Γ - is the alphabet, e.g., Γ = Z ! Example strings: • α =  string

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

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

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

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

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

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

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

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

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

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

Accessing Components

SIGCSE 2013 Special Session 11 Math Reasoning