debugging maude programs
play

Debugging Maude Programs Demis Ballis n e U d i f y o i t - PowerPoint PPT Presentation

Debugging Maude Programs Demis Ballis n e U d i f y o i t e r s i v U n - M I F D t d . i n i u @ u s a l l i b m i s . e : d a i l m e Debugging Maude Programs Demis Ballis n e U d i f y


  1. Debugging Maude Programs Demis Ballis n e U d i f y o i t e r s i v U n - M I F D t d . i n i u @ u s a l l i b m i s . e : d a i l m e

  2. Debugging Maude Programs Demis Ballis n e U d i f y o i t e r s i v U n - M I F D t d . i n i u @ u s a l l i b m i s . e : d a i l m e

  3. Towards the Automated Debugging of Maude Programs Demis Ballis n e U d i f y o i t e r s i v U n - M I F D t d . i n i u @ u s a l l i b m i s . e : d a i l m e

  4. About this talk Techniques for debugging Maude programs with an increasing level of automation Joint work with great people at UPV María Alpuente Francisco Frechina Daniel Romero Julia Sapiña

  5. Talk plan Rewriting logic and Maude (quick and dirty intro) Exploring Maude computations Debugging via backward trace slicing Debugging via automatic, assertion-based trace slicing Conclusion

  6. Rewriting Logic Rewriting Logic (RWL) is a logical and semantic framework, which is particularly suitable for implementing and analyzing highly concurrent, complex systems network protocols biological systems web apps RWL has been efficiently implemented in the programming language Maude.

  7. RWL specifications Σ A signature (i.e. set of operators) � Equational ∆ A set of equations Theory A set of algebraic axioms B (e.g. comm , assoc , unity ) R A set of rewrite rules A RWL specification ( Σ , ∆ ∪ B, R ) is a rewrite theory (i.e., a Maude program )

  8. A banking system Bank Account Operation credit ID : Id debit BAL : Int STATUS : 
 transfer active | blocked System State (Account | Msg)* < Alice | 50 | active > ; < Bob | 40 | active > ; debit(Alice, 60)

  9. A banking system mod BANK is inc BANK-EQ . vars ID ID1 ID2 : Id . vars BAL BAL1 BAL2 M : Int . op empty-state : -> State [ctor] . op _;_ : State State -> State [ctor assoc comm id: empty-state] . ops credit debit : Id Int -> Msg [ctor] . op transfer : Id Id Int -> Msg [ctor] . rl [credit] : credit(ID,M) ; < ID | BAL | active > => updSt(< ID | BAL + M | active >) . rl [debit] : debit(ID,M) ; < ID | BAL | active > => updSt(< ID | BAL - M | active >) . rl [transfer] : transfer(ID1,ID2,M) ; < ID1 | BAL1 | active > ; < ID2 | BAL2 | active > => updSt(< ID1 | BAL1 - M | active >) ; updSt(< ID2 | BAL2 + M | active >) . endm

  10. A banking system fmod BANK-EQ is inc BANK-INT+ID . pr SET{Id} . sorts Status Account PremiumAccount Msg State . subsort PremiumAccount < Account . subsorts Account Msg < State . var ID : Id . op <_|_|_> : Id Int Status -> Account [ctor] . var BAL : Int . op active : -> Status [ctor] . var STS : Status . op blocked : -> Status [ctor] . op Alice : -> Id [ctor] . op Bob : -> Id [ctor] . An active account op PreferredClients : -> Set{Id} . is blocked 
 eq PreferredClients = Bob . 
 if it is in the red cmb < ID | BAL | STS > : PremiumAccount if ID in PreferredClients . op secure : Account -> Account . ceq updSt(< ID | BAL | active >) = < ID | BAL | blocked > if BAL < 0 . eq updSt(< ID | BAL | STS >) = < ID | BAL | STS > [owise] . endfm

  11. A banking system fmod BANK-EQ is inc BANK-INT+ID . pr SET{Id} . sorts Status Account PremiumAccount Msg State . subsort PremiumAccount < Account . subsorts Account Msg < State . var ID : Id . op <_|_|_> : Id Int Status -> Account [ctor] . var BAL : Int . op active : -> Status [ctor] . var STS : Status . op blocked : -> Status [ctor] . op Alice : -> Id [ctor] . op Bob : -> Id [ctor] . op PreferredClients : -> Set{Id} . eq PreferredClients = Bob . 
 cmb < ID | BAL | STS > : PremiumAccount if ID in PreferredClients . op secure : Account -> Account . 
 ceq secure(< ID | BAL | active >) = < ID | BAL | blocked > if BAL < 0 . PreferredClients eq secure(< ID | BAL | STS >) = < ID | BAL | STS > [owise] . own endfm PremiumAccounts (allowed to be in the red)

  12. Rewriting modulo equational theories The evaluation mechanism is rewriting modulo equational theory ( ) → R/ ∆ ∪ B Lifting the usual rewrite relation over terms to the congruence classes induced by the equational theory ( Σ , ∆ ∪ B ) Unfortunately, is in general → R/ ∆ ∪ B undecidable since a rewrite step t → R/ ∆ [ B t 0 involves searching through the possibly infinite equivalence classes of and t 0 t

  13. Rewriting modulo equational theories Maude implements using two much → R/ ∆ ∪ B simpler rewrite relations and that → ∆ ,B → R,B use an algorithm of matching modulo B rewrites terms using equations/axioms as → ∆ ,B simplification rules For any term , by repeatedly applying the equations/ t axioms, we eventually reach a canonical form to t ↓ ∆ which no further equations can be applied must be Church-Rosser and terminating!

  14. Rewriting modulo equations and axioms Maude implements using two much → R/ ∆ ∪ B simpler rewrite relations and that → ∆ ,B → R,B use an algorithm of matching modulo B rewrites terms using equations in as ∆ → ∆ ,B simplification rules rewrites terms using rewrite rules in → R,B R

  15. Rewrite steps a rewrite step modulo on a term can be ∆ ∪ B t implemented by applying the following rewrite strategy: 1. reduce w.r.t. until the canonical form t ↓ ∆ t → ∆ ,B is reached; 2. rewrite w.r.t. to . t 0 t ↓ ∆ → R,B t → ⇤ ∆ ,B t ↓ ∆ → R,B t 0

  16. RWL traces A trace (computation) in the rewrite theory ( Σ , ∆ ∪ B, R ) is a (possibly infinite) rewrite sequence of the form: s 0 → ∗ ∆ ,B s 0 ↓ ∆ → R,B s 1 → ∗ ∆ ,B s 1 ↓ ∆ . . . that interleaves rewrite steps with equations and rules following the reduction strategy previously mentioned. the terms that appear in a computation are also called states.

  17. RWL traces: example < Alice | 50 | active > ; < Bob | 40 | active > ; debit(Alice, 30) rl [debit] : debit(ID,M) ; < ID | BAL | active > => updSt(< ID | BAL - M | active >) .

  18. RWL traces: example < Alice | 50 | active > ; < Bob | 40 | active > ; debit(Alice, 30) eq. simplification debit(Alice, 30) ; < Alice | 50 | active > ; < Bob | 40 | active > ; rl [debit] : debit(ID,M) ; < ID | BAL | active > => updSt(< ID | BAL - M | active >) .

  19. RWL traces: example < Alice | 50 | active > ; < Bob | 40 | active > ; debit(Alice, 30) eq. simplification debit(Alice, 30) ; < Alice | 50 | active > ; < Bob | 40 | active > ; debit application UpdSt(< Alice | 50 - 30 | active >) ; < Bob | 40 | active > rl [debit] : debit(ID,M) ; < ID | BAL | active > => updSt(< ID | BAL - M | active >) .

  20. RWL traces: example < Alice | 50 | active > ; < Bob | 40 | active > ; debit(Alice, 30) eq. simplification debit(Alice, 30) ; < Alice | 50 | active > ; < Bob | 40 | active > ; debit application UpdSt(< Alice | 50 - 30 | active >) ; < Bob | 40 | active > eq. simplification * < Alice | 20 | active > ; < Bob | 40 | active >

  21. Computation trees Given a rewrite theory , a R = ( Σ , ∆ ∪ B, R ) computation tree for a term is a tree-like T R ( s ) s representation of all the possible computations that originate from S0 s [Srv-A] & [Cli-A,Srv-A,7,na] & [Cli-B,Srv-A,17,na] S1 S2 req req [Srv-A] & Srv-A <- {Cli-A,7} & [Srv-A] & Srv-A <- {Cli-B,17} [Cli-A,Srv-A,7,na] & [Cli-B, & [Cli-A,Srv-A,7,na] & [Cli-B, Srv-A,17,na] Srv-A,17,na] S6 S3 S4 S5 reply req/dupl req loss ・・・ [Srv-A] & [Srv-A] & Cli-A <- [Srv-A] & Srv-A <- [Srv-A] & Srv-A <- {Cli-A,7} & Srv-A <- {Cli-A,7} & Srv-A <- [Cli-A,Srv-A, {Srv-A,f(Serv-A,Cli-A, 7,na] & [Cli- 7)} & [Cli-A,Srv-A,7, {Cli-A,7} & [Cli-A, {Cli-B,17} & [Cli-A, Srv-A,7,na] & [Cli-B Srv-A,7,na] & [Cli-B B,Srv-A,17, na] & [Cli-B,Srv-A,17, na] na] ,Srv-A,17,na] ,Srv-A,17,na] S7 succ ・・・ ・・・ ・・・ [Srv-A] & Cli-A <- {Srv-A,8} & [Cli-A ,Srv-A,7,na] & [Cli-B,Srv-A,17,na] ・・・

  22. Observation Computation trees are typically large (possibly infinite) and complex objects to deal with because of the highly-concurrent, non-deterministic nature of Rewriting Logic theories. Inspecting computation trees using the Maude built-in program tracer could be painful textual output implicit axiom applications

  23. Observation where is the bug?

  24. Exploring computations Computations can be manually explored to detect program misbehaviours To facilitate exploration… use a graphical representation of the computation tree define a stepwise, user-driven, computation exploration technique

  25. Exploring computations Computations can be manually explored to detect program misbehaviours To facilitate exploration… use a graphical representation of the computation tree define a stepwise, user-driven, computation exploration technique the ANIMA tool

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend