Automatically proving properties of tail-recursive function definitions by induction is known to be challenging. The difficulty arises due to a property of a tail-recursive function definition typically expressed by instantiating the accumulator argument to be a constant only on one side of the property. The application of the induction hypothesis gets blocked in a proof attempt. Following an approach developed by Kapur and Subramaniam, a transformation heuristic is proposed which hypothesizes the other side of property to also have an occurrence of the same constant. Constraints on the transformation are identified which enable a generalization of the constant on both sides with the hope that the generalized conjecture is easier to prove. Conditions are generated from which intermediate lemmas necessary to make a proof attempt to succeed can be speculated. By considering structural properties of recursive definitions, it is possible to identify properties of the functions used in recursive definitions for the conjecture to be valid. The heuristic is demonstrated on well-known tail-recursive definitions on numbers as well as other recursive data structures, including finite lists, finite sequences, finite trees, where a definition is expressed using one recursive call or multiple recursive calls. In case, a given conjecture is not valid because of a possible bug in an implementation (a tail-recursive definition) or a specification (a recursive definition), the heuristic can be often used to generate a counter-example. Conditions under which the heuristic is applicable can be checked easily. The proposed heuristic is likely to be helpful for automatically generating loop invariants as well as in proofs of correctness of properties of programs with respect to their specifications.
[1]
Jürgen Giesl,et al.
Context-Moving Transformations for Function Verification
,
1999,
LOPSTR.
[2]
Jacqueline Castaing,et al.
How to Facilitate the Proof of Theorems by Using the Induction-matching, and by Generalization
,
1985,
IJCAI.
[3]
Deepak Kapur,et al.
An Overview of Rewrite Rule Laboratory (RRL)
,
1989,
RTA.
[4]
William D. Clinger.
Proper tail recursion and space efficiency
,
1998,
PLDI.
[5]
Alan Bundy,et al.
Automatic verification of functions with accumulating parameters
,
1999,
Journal of Functional Programming.
[6]
Christoph Walther,et al.
Mathematical induction
,
1994,
Handbook of Logic in Artificial Intelligence and Logic Programming.
[7]
Robert S. Boyer,et al.
Computational Logic
,
1990,
ESPRIT Basic Research Series.
[8]
Deepak Kapur,et al.
Lemma Discovery in Automated Induction
,
1996,
CADE.
[9]
Deepak Kapur,et al.
A Mechanizable Induction Principle for Equational Specifications
,
1988,
CADE.
[10]
Raymond Aubin,et al.
Mechanizing Structural Induction Part II: Strategies
,
1979,
Theor. Comput. Sci..
[11]
Alan Bundy,et al.
The Automation of Proof by Mathematical Induction
,
1999,
Handbook of Automated Reasoning.