Brzozowski introduced the notion of derivatives for regular expressions. They can be used for a very simple regular expression matching algorithm. Sulzmann and Lu cleverly extended this algorithm in order to deal with POSIX matching, which is the underlying disambiguation strategy for regular expressions needed in lexers. Sulzmann and Lu have made available on-line what they call a “rigorous proof” of the correctness of their algorithm w.r.t. their specification; regrettably, it appears to us to have unfillable gaps. In the first part of this paper we give our inductive definition of what a POSIX value is and show (i) that such a value is unique (for given regular expression and string being matched) and (ii) that Sulzmann and Lu’s algorithm always generates such a value (provided that the regular expression matches the string). We also prove the correctness of an optimised version of the POSIX matching algorithm. Our definitions and proof are much simpler than those by Sulzmann and Lu and can be easily formalised in Isabelle/HOL. In the second part we analyse the correctness argument by Sulzmann and Lu and explain why the gaps in this argument cannot be filled easily.
[1]
Stijn Vansummeren,et al.
Type inference for unique pattern matching
,
2006,
TOPL.
[2]
Luca Cardelli,et al.
Greedy Regular Expression Matching
,
2004,
ICALP.
[3]
Christian Urban,et al.
POSIX Lexing with Derivatives of Regular Expressions
,
2016,
Arch. Formal Proofs.
[4]
Thierry Coquand,et al.
A Decision Procedure for Regular Expression Equivalence in Type Theory
,
2011,
CPP.
[5]
Tobias Nipkow,et al.
Proof Pearl: Regular Expression Equivalence and Relation Algebra
,
2011,
Journal of Automated Reasoning.
[6]
Martin Sulzmann,et al.
POSIX Regular Expression Parsing with Derivatives
,
2014,
FLOPS.
[7]
Konrad Slind,et al.
Adapting functional programs to higher order logic
,
2008,
High. Order Symb. Comput..
[8]
Janusz A. Brzozowski,et al.
Derivatives of Regular Expressions
,
1964,
JACM.
[9]
Martin Sulzmann,et al.
A Flexible and Efficient ML Lexer Tool Based on Extended Regular Expression Submatching
,
2014,
CC.
[10]
Tobias Nipkow,et al.
Verified Lexical Analysis
,
1998,
TPHOLs.