scala - Faster code for 'distinct' on lists -
This question refers to code generation with Isabel / HOL theorem project. I get one of the following: This code has quadratic runtime. Is there a fast version available? At the beginning of my theory, I think about something like import code and code for import and code for Anyway, there is a fast implementation for Next, you need an efficient sorting algorithm. By default, if the Although it can improve efficiency, there is also a problem: after the above announcements, you only This is done by selecting a dictionary order in code> List_lexord in code
DIF member [ A: HOL.Agbabel] (X0: List [A], Y: A): Boolean = (x, y) match {case (blue, y) => False case (x :: x, y) => HOLC [A] (X, Y) || Member [A] (Xs, Y)} DIF specific [A: HOL.Egele] (X: List [A]): Boolean = X Match {Case Neal => True case x :: xs = & gt; ! (Member [A] (xs, x)) & amp; Amp; Specific [a] (xs)} "~~ / src / HOL / Library / Codechar" for the list. Better implementations for specific must be sorted in the O (n log n) list and iterate over the list once. But I think someone can do better? different and possibly available from main ? I do not know about any fast implementation in the Isabell 2013 library, but you can easily do it as follows: different_supported actually implements different different through separate_list and sort, and it also New code for the name declares the form of equation. In essence, it seems:
reference starts the funny lind: "'a list = & gt; bool" where "specific" [] = True "| "Specific_sourceed [x] = true" | "SpecificSorted (X # Y # Xs) = (X ~ = Y & amp; SeparatedSorted (y # xs))" Lemma SeparatedSorted: "Sorted Xs ==> Separated xs = distinct xs" (xs Apply rule: different sorting entry uses the sort If you import multiset from HOL / Library, then apply sort via QuickSort If you import from the collection of formal books, you can get merge sort. different can be executed on lists whose elements are examples of class linorder as if this refinement is only inside the code generator, your definitions and theorems are not affected in Isabel. For example, to apply different to the list of lists in any code equation, you first have to define a linear command on the lists: HOL / Library , but for this it requires a linear command on the elements. If you want to use the string , which condenses four list , char_ord , then on four Defines normal order. If you map the character type of the target language with the Code_Char , then you have to optimize the principle of Code_Char_ord for combining with four_ord Required.
Comments
Post a Comment