Interac�ve Simplifier Tracing and Debugging in Isabelle Lars Hupel Technische Universität München Chair for Logic and Verifica�on July 8th, 2014
e l e l Agenda b a ∀ s I = α λ β → State of the Art 1 2 Features of the New Simplifier Trace Challenges & Open Problems 3 Evalua�on 4 2 / 24
e l e l Isabelle b a ∀ s I = α λ β → ▶ interac�ve proof assistant ▶ powerful automa�on ▶ classical and equa�onal reasoning ▶ decision procedures (e.g. linear arithme�c) ▶ integra�on with external automated theorem provers ▶ ... ▶ IDE with con�nuous proof checking based on jEdit 3 / 24
e l e l Simplifier b a ∀ s I = α λ β → ▶ one of the core tac�cs in Isabelle ▶ huge: more than 1800 lines of code ▶ applies rewrite rules to terms ▶ rules can be condi�onal: precondi�ons solved recursively ▶ rules can be lazy: “simprocs” can generate rules on the fly ▶ goals can be condi�onal: local assump�ons are used 4 / 24
e l e l Simplifier b a ∀ s I = α λ β → ▶ one of the core tac�cs in Isabelle ▶ huge: more than 1800 lines of code ▶ applies rewrite rules to terms ▶ rules can be condi�onal: precondi�ons solved recursively ▶ rules can be lazy: “simprocs” can generate rules on the fly ▶ goals can be condi�onal: local assump�ons are used 4 / 24
0 x 1 0 x 1 0 x 1 x 1 0 0 x 1 x 1 0 2 x 1 e l e l Simplifier b a ∀ s I = α λ β → Example: Condi�onal rewrite rules x , y ∈ N 2 · x = x + x (1) x < y = ⇒ x − y = 0 (2) 0 < x + 1 (3) 0 < x = ⇒ 0 < y = ⇒ 0 < x + y (4) 5 / 24
0 x 1 0 x 1 0 x 1 x 1 0 0 x 1 x 1 e l e l Simplifier b a ∀ s I = α λ β → Example: Condi�onal rewrite rules x , y ∈ N 2 · x = x + x (1) x < y = ⇒ x − y = 0 (2) 0 < x + 1 (3) 0 < x = ⇒ 0 < y = ⇒ 0 < x + y (4) 0 − 2 · ( x + 1 ) 5 / 24
0 x 1 0 x 1 0 0 x 1 x 1 e l e l Simplifier b a ∀ s I = α λ β → Example: Condi�onal rewrite rules x , y ∈ N 2 · x = x + x (1) x < y = ⇒ x − y = 0 (2) 0 < x + 1 (3) 0 < x = ⇒ 0 < y = ⇒ 0 < x + y (4) 0 − 2 · ( x + 1 ) = 0 − (( x + 1 ) + ( x + 1 )) 5 / 24
0 x 1 0 x 1 0 0 x 1 x 1 e l e l Simplifier b a ∀ s I = α λ β → Example: Condi�onal rewrite rules x , y ∈ N 2 · x = x + x (1) x < y = ⇒ x − y = 0 (2) 0 < x + 1 (3) 0 < x = ⇒ 0 < y = ⇒ 0 < x + y (4) 0 − 2 · ( x + 1 ) = 0 − (( x + 1 ) + ( x + 1 )) 5 / 24
0 x 1 0 x 1 e l e l Simplifier b a ∀ s I = α λ β → Example: Condi�onal rewrite rules x , y ∈ N 2 · x = x + x (1) x < y = ⇒ x − y = 0 (2) 0 < x + 1 (3) 0 < x = ⇒ 0 < y = ⇒ 0 < x + y (4) 0 − 2 · ( x + 1 ) = 0 − (( x + 1 ) + ( x + 1 )) = 0 ▶ 0 < (( x + 1 ) + ( x + 1 )) 5 / 24
e l e l Simplifier b a ∀ s I = α λ β → Example: Condi�onal rewrite rules x , y ∈ N 2 · x = x + x (1) x < y = ⇒ x − y = 0 (2) 0 < x + 1 (3) 0 < x = ⇒ 0 < y = ⇒ 0 < x + y (4) 0 − 2 · ( x + 1 ) = 0 − (( x + 1 ) + ( x + 1 )) = 0 ▶ 0 < (( x + 1 ) + ( x + 1 )) ▶ 0 < x + 1 ▶ 0 < x + 1 5 / 24
e l e l Simplifier b a ∀ s I = α λ β → Example: Condi�onal rewrite rules x , y ∈ N 2 · x = x + x (1) x < y = ⇒ x − y = 0 (2) 0 < x + 1 (3) 0 < x = ⇒ 0 < y = ⇒ 0 < x + y (4) 0 − 2 · ( x + 1 ) = 0 − (( x + 1 ) + ( x + 1 )) = 0 ▶ 0 < (( x + 1 ) + ( x + 1 )) ▶ 0 < x + 1 ▶ 0 < x + 1 5 / 24
e l e l Simplifier b a ∀ s I = α λ β → Example: Condi�onal rewrite rules x , y ∈ N 2 · x = x + x (1) x < y = ⇒ x − y = 0 (2) 0 < x + 1 (3) 0 < x = ⇒ 0 < y = ⇒ 0 < x + y (4) 0 − 2 · ( x + 1 ) = 0 − (( x + 1 ) + ( x + 1 )) = 0 ▶ 0 < (( x + 1 ) + ( x + 1 )) ▶ 0 < x + 1 ▶ 0 < x + 1 5 / 24
tackled by tracing e l e l Simplifier b a ∀ s I = α λ β → Simplifica�on might go wrong: ▶ no result at all ▶ unexpected result ▶ non-termina�on 6 / 24
e l e l Simplifier b a ∀ s I = α λ β → Simplifica�on might go wrong: ▶ no result at all ▶ unexpected result ▶ non-termina�on tackled by tracing 6 / 24
e l e l Simplifier Trace b a ∀ s I = α λ β → Lists all rewri�ng steps, but: ▶ poten�ally huge ▶ can’t be filtered (e.g. “trace only applica�ons of X and Y”) ▶ offers no hierachical structure ▶ problema�c with non-termina�on 7 / 24
e l e l b a ∀ s I = α λ β → 8 / 24
e l e l Agenda b a ∀ s I = α λ β → State of the Art 1 2 Features of the New Simplifier Trace Challenges & Open Problems 3 Evalua�on 4 9 / 24
e l e l Overview b a ∀ s I = α λ β → ▶ interac�ve ▶ breakpoints on terms and theorems ▶ configurable verbosity ▶ integrated into Isabelle/jEdit 10 / 24
e l e l b a ∀ s I = α λ β → Demonstra�on
In Isabelle: difficult because of proof kernel e l e l Related Work b a ∀ s I = α λ β → SWI-Prolog ▶ offers interac�ve tracing ▶ supports breakpoints ▶ speciality: marking goals as success 12 / 24
e l e l Related Work b a ∀ s I = α λ β → SWI-Prolog ▶ offers interac�ve tracing ▶ supports breakpoints ▶ speciality: marking goals as success ▶ In Isabelle: difficult because of proof kernel 12 / 24
In Isabelle: rarely needed because of parallel processing e l e l Related Work b a ∀ s I = α λ β → Maude ▶ offers interac�ve tracing ▶ supports breakpoints ▶ speciality: during rewri�ng, issue new goal 13 / 24
e l e l Related Work b a ∀ s I = α λ β → Maude ▶ offers interac�ve tracing ▶ supports breakpoints ▶ speciality: during rewri�ng, issue new goal ▶ In Isabelle: rarely needed because of parallel processing 13 / 24
e l e l Agenda b a ∀ s I = α λ β → State of the Art 1 2 Features of the New Simplifier Trace Challenges & Open Problems 3 Evalua�on 4 14 / 24
e l e l Challenges b a ∀ s I = α λ β → Selec�ve Memory Clearing Scenario 1. rewrite step fails 2. user chooses to redo the step 3. simplifica�on starts anew 4. memoiza�on kicks in, step fails again 15 / 24
e l e l Challenges b a ∀ s I = α λ β → Selec�ve Memory Clearing Scenario 1. rewrite step fails 2. user chooses to redo the step 3. simplifica�on starts anew 4. memoiza�on kicks in, step fails again 15 / 24
e l e l Challenges b a ∀ s I = α λ β → Context Handling ▶ simplifica�on result depends on local assump�ons ▶ memoiza�on might not make sense across different contexts ( P = ⇒ P ) = ⇒ ( Q = ⇒ P ) = ⇒ R 16 / 24
e l e l Challenges b a ∀ s I = α λ β → User Experience ▶ user feedback is generally posi�ve ▶ used for detec�ng erra�c rules, analyzing simplifier run�me, ... ▶ very flexible, but: every addi�onal op�on generates confusion 17 / 24
e l e l Agenda b a ∀ s I = α λ β → State of the Art 1 2 Features of the New Simplifier Trace Challenges & Open Problems 3 Evalua�on 4 18 / 24
e l e l Performance b a ∀ s I = α λ β → Simplifying 10 x · 10 y Test machine: Core i7, 3.7 GHz 19 / 24
e l e l A Parallelized Simplifier? b a ∀ s I = α λ β → ▶ tracing is completely asynchronous ▶ supports mul�ple ques�ons at the same �me ▶ but: unused by the simplifier ▶ proof of concept: development of a �ny, parallel simplifier 20 / 24
Disadvantages poten�ally confusing for users lots of spurious messages be�er filtering required? holding back messages required? e l e l A Parallelized Simplifier? b a ∀ s I = α λ β → Lessons Learned Advantages ▶ almost trivial to implement for a toy simplifier ▶ GUI part works out of the box 21 / 24
e l e l A Parallelized Simplifier? b a ∀ s I = α λ β → Lessons Learned Advantages ▶ almost trivial to implement for a toy simplifier ▶ GUI part works out of the box Disadvantages ▶ poten�ally confusing for users ▶ lots of spurious messages ▶ be�er filtering required? ▶ holding back messages required? 21 / 24
e l e l Outcomes b a ∀ s I = α λ β → ▶ a generic tracing facility ▶ using its interface requires li�le changes to a tac�c ▶ paralleliza�on-ready ▶ but not 100% there yet ▶ first steps towards instrumen�ng the simplifier ▶ Should all tac�cs be wri�en in con�nua�on-passing style? 22 / 24
e l e l Future Work b a ∀ s I = α λ β → ▶ support for more tac�cs ▶ support for other traces (unifier, simp debug, ...) ▶ memoiza�on: fuzzy matching ▶ term provenance (“Where does that ‘5’ come from?”) ▶ �ghter integra�on into Isabelle/jEdit 23 / 24
e l e l b a ∀ s I = α λ β → Q & A
Recommend
More recommend