Error: Cannot coerce to an evaluable reference in coq
Error: Cannot coerce to an evaluable reference in coq
我正在尝试展开 Mem.load,但出现错误:
Error: Cannot coerce Mem.load
to an evaluable reference.
我写的 Mem.load
的 Definition
与 load1
完全相同,并且可以展开。
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.
compcert.common.Memory
模块定义了几个名称,包括 Mem.load
是不透明的:
Global Opaque Mem.alloc Mem.free Mem.store Mem.load Mem.storebytes Mem.loadbytes.
这意味着它不能 unfold
编辑。
在尝试 unfold Mem.load
之前只需说它是 Transparent
,之后一切正常:
Transparent Mem.load.
unfold Mem.load.
我正在尝试展开 Mem.load,但出现错误:
Error: Cannot coerce
Mem.load
to an evaluable reference.
我写的 Mem.load
的 Definition
与 load1
完全相同,并且可以展开。
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.
compcert.common.Memory
模块定义了几个名称,包括 Mem.load
是不透明的:
Global Opaque Mem.alloc Mem.free Mem.store Mem.load Mem.storebytes Mem.loadbytes.
这意味着它不能 unfold
编辑。
在尝试 unfold Mem.load
之前只需说它是 Transparent
,之后一切正常:
Transparent Mem.load.
unfold Mem.load.