Abstract
The classical method of proving imperative programs uses Hoor logic, applies Dijks-tra's weakest precondition predicate, and involves specifying the program with first-order predicates as the so-called precondition and postcondition. The classical method of proving functional programs uses the method of mathematical induction and involves specifying the program with recursive functions. This work explores the automated formal verification of imperative programs using recursive specifications. This study appeals to both academics and industry professionals engaged in algorithmic research and software engineering, illuminating the intricate process of formally substantiating the correctness of complex algorithms. The work specifically focuses on developing formal correctness proofs for the Merge Sort algorithm and the Knapsack Problem implementations. By employing contem-porary tools like the Dafny verification system and leveraging the power of recursive speci-fications, the research demonstrates the development of detailed specifications and precise program proofs, successfully verifying an array-based implementation of Merge Sort and requiring the formulation of custom conditions for index handling. The findings of this research hold practical implications, particularly in optimizing software systems where the assurance of algorithmic correctness is paramount and establishes recursive specifications as an effective approach for verifying imperative programs.