Mina mohamadi
Mina mohamadi

Reputation: 33

Error: Cannot coerce to an evaluable reference in coq

I'm trying to unfold Mem.load and I get the error:

Error: Cannot coerce Mem.load to an evaluable reference.

I wrote the exact same Definition of Mem.load as load1 and is unfoldable.

Require Import compcert.common.AST.
Require Import compcert.common.Memory.
Require Import compcert.common.Values.
Require Import compcert.lib.Coqlib.
Require Import compcert.lib.Maps.

Local Notation "a # b" := (PMap.get b a) (at level 1).

Definition load1 (chunk: memory_chunk) (m: mem) (b: block) (ofs: Z): option val :=
  if Mem.valid_access_dec m chunk b ofs Readable
  then Some(decode_val chunk (Mem.getN (size_chunk_nat chunk) ofs (m.(Mem.mem_contents)#b)))
  else None.

Lemma mem_load_eq: forall (c : memory_chunk) (m : mem) (b : block) (ofs : Z),
(load1 c m b ofs) = (Mem.load c m b ofs).
Proof.
  intros.
  unfold load1.
  unfold Mem.load. (*I get error here when unfolding *)
Admitted.

Upvotes: 1

Views: 665

Answers (1)

Anton Trunov
Anton Trunov

Reputation: 15404

The compcert.common.Memory module defines several names including Mem.load to be opaque:

Global Opaque Mem.alloc Mem.free Mem.store Mem.load Mem.storebytes Mem.loadbytes.

This means it cannot be unfolded.

Before trying to unfold Mem.load just say that it is Transparent, after that everything will work:

Transparent Mem.load.
unfold Mem.load.

Upvotes: 2

Related Questions