# HG changeset patch # User haftmann # Date 1744751084 -7200 # Node ID 88f101c3cfe2558115bd3bfdf5d90a29dbcc4029 # Parent 03d019ee7d022ab99a0a9f154df48bff22266852 official theory for using bit shift operations for ordinary arithmetic if feasible diff -r 03d019ee7d02 -r 88f101c3cfe2 src/HOL/Codegenerator_Test/Basic_Setup.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Codegenerator_Test/Basic_Setup.thy Tue Apr 15 23:04:44 2025 +0200 @@ -0,0 +1,33 @@ +(* Author: Florian Haftmann, TU Muenchen *) + +section \Basic setup\ + +theory Basic_Setup +imports + Complex_Main +begin + +text \Drop technical stuff from \<^theory>\HOL.Quickcheck_Narrowing\ which is tailored towards Haskell\ + +ML \ +structure Codegenerator_Test = +struct + +fun drop_partial_term_of thy = + let + val tycos = Sign.logical_types thy; + val consts = map_filter (try (curry (Axclass.param_of_inst thy) + \<^const_name>\Quickcheck_Narrowing.partial_term_of\)) tycos; + in + thy + |> fold Code.declare_unimplemented_global consts + end; + +end; +\ + +text \Avoid popular infix.\ + +code_reserved (SML) upto + +end diff -r 03d019ee7d02 -r 88f101c3cfe2 src/HOL/Codegenerator_Test/Candidates.thy --- a/src/HOL/Codegenerator_Test/Candidates.thy Tue Apr 15 19:40:42 2025 +0200 +++ b/src/HOL/Codegenerator_Test/Candidates.thy Tue Apr 15 23:04:44 2025 +0200 @@ -5,7 +5,7 @@ theory Candidates imports - Complex_Main + Basic_Setup "HOL-Library.Library" "HOL-Library.Sorting_Algorithms" "HOL-Library.Subseq_Order" @@ -19,16 +19,7 @@ "HOL-Examples.Gauss_Numbers" begin -text \Drop technical stuff from \<^theory>\HOL.Quickcheck_Narrowing\ which is tailored towards Haskell\ - -setup \ -fn thy => -let - val tycos = Sign.logical_types thy; - val consts = map_filter (try (curry (Axclass.param_of_inst thy) - \<^const_name>\Quickcheck_Narrowing.partial_term_of\)) tycos; -in fold Code.declare_unimplemented_global consts thy end -\ +setup \Codegenerator_Test.drop_partial_term_of\ text \Simple example for the predicate compiler.\ @@ -40,10 +31,6 @@ code_pred sublist . -text \Avoid popular infix.\ - -code_reserved (SML) upto - text \Explicit check in \OCaml\ for correct precedence of let expressions in list expressions\ definition funny_list :: "bool list" diff -r 03d019ee7d02 -r 88f101c3cfe2 src/HOL/Codegenerator_Test/Generate_Target_Rewrites_To_Bit_Operations.thy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/HOL/Codegenerator_Test/Generate_Target_Rewrites_To_Bit_Operations.thy Tue Apr 15 23:04:44 2025 +0200 @@ -0,0 +1,21 @@ +(* Author: Florian Haftmann, TU Muenchen *) + +section \Test of arithmetic using target-language bit operations\ + +theory Generate_Target_Rewrites_To_Bit_Operations +imports + Basic_Setup + "HOL-Library.Code_Bit_Shifts_for_Arithmetic" + "HOL-Library.Code_Test" +begin + +setup \Codegenerator_Test.drop_partial_term_of\ + +text \ + If any of the checks fails, inspect the code generated + by a corresponding \export_code\ command. +\ + +export_code _ checking SML OCaml? Haskell? Scala + +end