Theory Memcpy
theory Memcpy
imports
"AutoCorres2_Main.AutoCorres_Main"
begin
abbreviation "ADDR_MAX ≡ UWORD_MAX TYPE(addr_bitsize)"
abbreviation "of_nat_addr ≡ of_nat::(nat ⇒ addr)"
lemma byte_ptr_guarded:
"ptr_val (x::8 word ptr) ≠ 0 ⟹ c_guard x"
unfolding c_guard_def c_null_guard_def ptr_aligned_def
by (clarsimp simp: intvl_Suc)
lemma ptr_add_coerce: "ptr_val (((ptr_coerce x)::('a::{c_type}) ptr) +⇩p a) = (ptr_val x) + (of_int a * of_nat (size_of TYPE('a)))"
apply (case_tac x)
apply (clarsimp simp: CTypesDefs.ptr_add_def)
done
lemma ptr_contained:"⟦ c_guard (x::('a::c_type) ptr); size_of TYPE('a) = sz;
0 ≤ i; i < int sz; (y::8 word ptr) = ptr_coerce x⟧ ⟹ c_guard (y +⇩p i)"
apply (rule byte_ptr_guarded)
unfolding c_guard_def c_null_guard_def ptr_add_def
apply simp
apply (clarsimp simp: CTypesDefs.ptr_add_def intvl_def)
apply (erule allE [where x="nat i"])
apply (clarsimp simp: nat_less_iff of_nat_nat)
done