{'fraction_non_alphanumeric': 0.019444444444444445, 'fraction_numerical': 0.0, 'mean_word_length': 5.702325581395349, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Study of Isabelle/HOL on Formal Algorithm Analysis and Code Generation

Mechanical theorem proving is especially advantageous on formal verification of algorithms manipulating complicated data structures. Some proof assistants such as Isabelle/HOL also enable users to extract executable code from verified specification, pushing the correctness assurance from algorithm level forward to code level. As a long-standing active research area, file comparison algorithms have extensive applications involving molecular biology, information processing, data retrieval and network security. In this paper, the formalization of fcomp, an efficient line oriented file comparison algorithm suggested by Miller and Myers, is modeled in the interactive theorem prover Isabelle/HOL. A small bug in fcomp’s bound variable iteration is identified and the fixed algorithm’s termination and correctness is established. Formal analysis of time complexity is also performed which coincides with the algorithm designers’ own results. Using Isabelle’s code generation tool a credible OCaml program is extracted further. This program’s efficiency is compared to another hand-written OCaml program as well as to a C program through a set of experiments. Analysis results show that the generated program’s efficiency still needs much improvement to be practically usable. Our work lays foundation for subsequent rigorous check of more file comparison algorithms.