Theory Native_Word_Test_Emu

(*  Title:      Native_Word_Test_Emu.thy
    Author:     Andreas Lochbihler, ETH Zurich
*)

theory Native_Word_Test_Emu
  imports
  Native_Word_Test
  Code_Target_Int_Bit
begin

section ‹Test cases for emulation of native words›

subsection ‹Tests for typuint8

text ‹
  Test that typuint8 is emulated for OCaml via typ8 word
  if theoryNative_Word.Code_Target_Int_Bit is imported.
›

definition test_uint8_emulation :: bool
  where test_uint8_emulation  (0xFFF - 0x10 = (0xEF :: uint8))

export_code test_uint8_emulation checking OCaml?
  ― ‹test the other target languages as well› SML Haskell? Scala


subsection ‹Tests for typuint16

text ‹
  Test that typuint16 is emulated for PolyML and OCaml via typ16 word
  if theoryNative_Word.Code_Target_Int_Bit is imported.
›

definition test_uint16_emulation :: bool
  where test_uint16_emulation  (0xFFFFF - 0x1000 = (0xEFFF :: uint16))

export_code test_uint16_emulation checking SML OCaml?
  ― ‹test the other target languages as well› Haskell? Scala

notepad begin
  have test_uint16 by eval
  have test_uint16_emulation by eval
  have test_uint16_emulation by normalization
  have test_uint16_emulation by code_simp
end

ML_val val true = @{code test_uint16};
  val true = @{code test_uint16_emulation};

lemma x AND y = x OR (y :: uint16)
quickcheck [random, expect=counterexample]
quickcheck [exhaustive, expect=counterexample]
oops

end