210 likes | 399 Views
CHROME-REF. CHR v Online Model-driven Engine with Reasoning Explanation Facilities. INRIA / UFPE Rafael Oliveira – Rafael.Oliveira@inria.fr Jacques Robin - robin.jacques@gmail.com Pierre Deransart - Pierre.Deransart@inria.fr Rocquencourt, France October 28, 2009. Agenda.
E N D
CHROME-REF CHRvOnline Model-driven Engine with Reasoning Explanation Facilities INRIA / UFPE Rafael Oliveira – Rafael.Oliveira@inria.fr Jacques Robin - robin.jacques@gmail.com Pierre Deransart - Pierre.Deransart@inria.fr Rocquencourt, France October 28, 2009
Agenda • Separation of concerns (CHROME-REF Project) • Engine, Extraction, Driver and Analyzer • Generic CHRv Trace Schema for Debugging • Trace Driver • Trace Analyzer • Conclusion • Future Works
Separation of Concerns • At present, there exists a number of useful debugging tools for CHR • Tools were designed and implemented in a specific way for each solver • Each implementation results in a set of one-to-one specialized connections between a solver and its tools CHR ECLiPSe Prolog Debugging Tool CHR SWI Prolog Debugging Tool … … CHR SICStus Prolog Debugging Tool
Separation of Concerns • To propose a generic architecture that produces generic debugging information • Flexible • Portable CHR Trace Schema query CHR ECLiPSe Prolog Extraction CHR Trace Driver Analyzer CHR SWI Prolog Extraction … CHR SICStus Prolog Extraction
CHROME-REF Project • Engine • CHROME engine • a compiler that take a CHR base into imperative Java objects • MDE approach during its process of compilation by means of ATL transformations. • Extraction • Theoretical Operational Semantics ωt • Integration (ωt + CHROME) • Generic CHRv Trace Schema for Debugging • Driver • A processor, on the fly, of traces events according to the query requested by the analyzer. • Analyzer • Debugging Tool
CHROME-REF Project • Engine • CHROME engine • a compiler that take a CHR base into imperative Java objects • MDE approach during its process of compilation by means of ATL transformations. • Extraction • Theoretical Operational Semantics ωt • Integration (ωt+ CHROME) • Generic CHRv Trace Schema for Debugging • Driver • A processor, on the fly, of traces events according to the query requested by the analyzer. • Analyzer • Debugging Tool
References • VITORINO, J. Model-Driven Engineering a Versatile, Extensible, Scalable Rule Engine through Component Assembly and Model Transformations. Universidade Federal de Pernambuco. CIn. CiênciadaComputação, 2009. • DUCK, G., STUCKEY, P., DE LA BANDA, M., and HOLZABAUR, C. The refined operational semantics of Constraint Handling Rules. Lecture notes in computer science (2004), 90–104.
ECLiPSe Prolog • add • A new constraint is added to the constraint store. • already_in • A constraint to be added was already present. • try_rule • A rule is tried. • delay_rule • The last tried rule cannot fire because the guard did not succeed. • fire_rule • The last tried rule fires. • try_label • A label_with declaration is checked. • delay_label • The last label_with declaration delays because the guard did not succeed. • fire_label • The last tried label_with declaration succeeds, so the clauses of the associated constraint will be used for built-in labeling.
ECLiPSe Prolog (LEQ example) • leq(A,B), leq(B,C), leq(C,A).ADD (2) leq(B, C)leq(B, C)TRY (2) leq(B, C)withbuilt_inRULE 'built_in' DELAYEDTRY (2) leq(B, C) (1) leq(A, B)withtransitivityRULE 'transitivity' FIREDADD (3) leq(A, C)leq(A, C)TRY (3) leq(A, C)withbuilt_inRULE 'built_in' DELAYEDADD (4) leq(C, A)leq(C, A)TRY (4) leq(C, A)withbuilt_inRULE 'built_in' DELAYEDTRY (4) leq(C, A) (3) leq(A, C)withantisymmetryRULE 'antisymmetry' FIREDleq(A, B)TRY (1) leq(A, B)withbuilt_inRULE 'built_in' DELAYEDTRY (1) leq(A, B) (2) leq(B, A)withantisymmetryRULE 'antisymmetry' FIREDA = BB = BC = B
SWI Prolog • call • A new constraint is called and becomes active. • Exit • An active constraint exits: it has either been inserted in the store after trying all rules or has been removed from the constraint store. • Fail • An active constraint fails. • Redo • An active constraint starts looking for an alternative solution. • Wake • A suspended constraint is woken and becomes active. • Insert • An active constraint has tried all rules and is suspended in the constraint store. • Remove • An active or passive constraint is removed from the constraint store. • Try • An active constraints tries a rule with possibly some passive constraints. • Apply • An active constraints commits to a rule with possibly some passive constraints.
ECLiPSe Prolog (LEQ example) • leq(A,B), leq(B,C), leq(C,A). CHR: (0) Insert: leq(_G21593, _G21594) # <175>CHR: (1) Call: leq(_G21593, _G21594) # <175> ? [creep]CHR: (1) Exit: leq(_G21593, _G21594) # <175> ? [creep]CHR: (0) Insert: leq(_G21594, _G21597) # <176>CHR: (1) Call: leq(_G21594, _G21597) # <176> ? [creep]CHR: (1) Try: leq(_G21593, _G21594) # <175>, leq(_G21594, _G21597) # <176> ==> leq(_G21593, _G21597).CHR: (1) Apply: leq(_G21593, _G21594) # <175>, leq(_G21594, _G21597) # <176> ==> leq(_G21593, _G21597). ? [creep]CHR: (1) Insert: leq(_G21593, _G21597) # <177>CHR: (2) Call: leq(_G21593, _G21597) # <177> ? [creep]CHR: (2) Exit: leq(_G21593, _G21597) # <177> ? [creep]CHR: (1) Exit: leq(_G21594, _G21597) # <176> ? [creep]CHR: (0) Insert: leq(_G21597, _G21593) # <178>CHR: (1) Call: leq(_G21597, _G21593) # <178> ? [creep]CHR: (1) Try: leq(_G21597, _G21593) # <178>, leq(_G21593, _G21597) # <177> <=> _G21597=_G21593.CHR: (1) Apply: leq(_G21597, _G21593) # <178>, leq(_G21593, _G21597) # <177> <=> _G21597=_G21593. ? [creep]CHR: (1) Remove: leq(_G21593, _G21597) # <177>CHR: (1) Remove: leq(_G21597, _G21593) # <178>CHR: (2) Wake: leq(_G21594, _G21593) # <176> ? [creep]CHR: (2) Try: leq(_G21594, _G21593) # <176>, leq(_G21593, _G21594) # <175> <=> _G21594=_G21593.CHR: (2) Apply: leq(_G21594, _G21593) # <176>, leq(_G21593, _G21594) # <175> <=> _G21594=_G21593. ? [creep]CHR: (2) Remove: leq(_G21593, _G21594) # <175>CHR: (2) Remove: leq(_G21594, _G21593) # <176>CHR: (2) Exit: leq(_G21593, _G21593) # <176> ? [creep]CHR: (1) Exit: leq(_G21593, _G21593) # <178> ? [creep]A = C,B = C .
SICStus Prolog • call • Prompt when a constraint is executed for the first time. • Exit • Prompt when the constraint is successfully processed, i.e. the applicable rules have applied. • Fail • Prompt when a constraint fails. • Redo • Prompt at subsequent exits generated by non-deterministic rule bodies. • Wake • Prompt when a constraint from the constraint store is woken and reconsidered because one of its variables has been touched. • try • Prompt just before the guard evaluation of a rule, after constraints matching the heads have been found. • apply • Prompt upon the application of a rule, after the successful guard evaluation, when the rule commits and fires, just before evaluating the body • insert • Prompt when a constraint gets inserted into the constraint store, i.e. after all rules have been tried. • remove • Prompt when a constraint gets removed from the constraint store
Etrace label:String EInitialState EIntroduce ESolve EApply EFail Goal UDC BIC Built-ins Rule * *
contextTraceDriver::registerAnalyzer(a:Analyzer) post: analyzer->includes(d) contextTraceDriver::notifyDriver(eTrace:ETrace) post: analyzers->forAll(a | a^notification(filterTrace(a.request, eTrace))) contextTraceDriver::updateFilter(a:Analyzer, request:Request) post: a.request = request