(*  NOT TRUE, because readable doesn't constraint NoneP ... Lemma readable_VAL: forall w l, readable l (w_m w) <-> exists sh, (VALspec sh l * TT) w.  *)

(* Specifications: *)
Lemma VALspec1: VALspec_range 1 = VALspec.
Lemma VALspec_range_exp_address_mapsto:
forall ch sh l,
(align_chunk ch | snd l) ->
VALspec_range (size_chunk ch) sh l |-- EX v: val, address_mapsto ch v sh l.
Lemma address_mapsto_VALspec_range:
forall ch v sh l,
address_mapsto ch v sh l |-- VALspec_range (size_chunk ch) sh l.
Lemma approx_eq_i:
forall (P Q: pred rmap) (w: rmap),
(|> ! (P <=> Q)) w -> approx (level w) P = approx (level w) Q.
Lemma level_later {A} `{H : ageable A}: forall {w: A} {n': nat},
laterR (level w) n' ->
exists w', laterR w w' /\ n' = level w'.
(* TODO: resume this lemma. *)
(* Lemma fun_assert_contractive: forall fml cc (A: TypeTree) (P Q: pred rmap -> forall ts, dependent_type_functor_rec ts (AssertTT A) (pred rmap)) v, (forall ts x rho, nonexpansive (fun R => P R ts x rho)) -> (forall ts x rho, nonexpansive (fun R => Q R ts x rho)) -> contractive (fun R : pred rmap => fun_assert fml cc A (P R) (Q R) v). *)
Lemma VALspec_range_bytes_readable:
forall n sh loc m, VALspec_range n sh loc m -> bytes_readable loc n m.
Lemma VALspec_range_bytes_writable:
forall n sh loc m, writable_share sh -> VALspec_range n sh loc m -> bytes_writable loc n m.
Lemma yesat_join_sub:
forall pp k l sh m m',
join_sub m m' ->
yesat pp k sh l m ->
exists sh', yesat pp k sh' l m'.
Lemma VALspec_range_precise: forall n sh l,  precise (VALspec_range n sh l).
Lemma nonlock_permission_bytes_precise: forall sh p n,
precise (nonlock_permission_bytes sh p n).
Lemma address_mapsto_precise: forall ch v sh l, precise (address_mapsto ch v sh l).
Lemma LKspec_precise lock_size: forall R sh l, precise (LKspec lock_size R sh l).
Program Definition core_load (ch: memory_chunk) (l: address) (v: val): pred rmap :=
EX bl: list memval,
!!(length bl = size_chunk_nat ch /\ decode_val ch bl = v /\ (align_chunk ch | snd l)) &&
allp (jam (adr_range_dec l (size_chunk ch))
(fun l' phi => exists sh, exists rsh, phi @ l'
= YES sh rsh (VAL (nth (nat_of_Z (snd l' - snd l)) bl Undef)) NoneP)
(fun _ _ => True)).