coq中的铸造类型
我有定义coq中的铸造类型,coq,coq-tactic,compcert,Coq,Coq Tactic,Compcert,我有定义my_def1: Require Import compcert.common.Memory. Require Import compcert.common.Values. Require Import compcert.lib.Integers. Definition my_def1 (vl: list memval) : val := match proj_bytes vl with | Some bl => Vint(Int.sign_ext 16 (Int.
my_def1
:
Require Import compcert.common.Memory.
Require Import compcert.common.Values.
Require Import compcert.lib.Integers.
Definition my_def1 (vl: list memval) : val :=
match proj_bytes vl with
| Some bl => Vint(Int.sign_ext 16 (Int.repr (decode_int bl)))
| None => Vundef
end.
我想写另一个定义my_def2
,类似于下面的my_def1
,并添加一个公理,即proj_bytes vl
始终返回一些bl
,因此:
Definition my_def2 (vl: list memval) : val :=
Vint(Int.sign_ext 16 (Int.repr (decode_int ((*?*)) )))
end.
我的问题是如何完成My_def2
并编写关于proj_bytes vl
的相关axiom
或者问题是如何从类型list memval
转换为list byte
[decode\u int
接受list byte
]
下面是memval
的定义:
Inductive memval : Type :=
Undef : memval
| Byte : byte -> memval
| Fragment : val -> quantity -> nat -> memval
您有两种方法,让我们先做一些初步准备:
Variable (memval byte : Type).
Variable (proj_bytes : list memval -> option byte).
Inductive val := Vundef | VInt : byte -> val.
Definition my_def1 (vl: list memval) : val :=
match proj_bytes vl with
| Some bl => VInt bl
| None => Vundef
end.
然后,您可以将您的公理定义为:
Axiom pb1 : forall vl , { v | proj_bytes vl = Some v }.
你们破坏了这条公理,用内在的等式重写。然而,正如您所猜测的,这种方法有点不方便
最好假装有一个默认值来销毁proj_字节:
Variable (byte_def : byte).
Definition bsel vl :=
match proj_bytes vl with
| Some bl => bl
| None => byte_def
end.
Definition my_def2 (vl: list memval) : val := VInt (bsel vl).
Lemma my_defP vl : my_def1 vl = my_def2 vl.
Proof.
now destruct (pb1 vl) as [b H]; unfold my_def1, my_def2, bsel; rewrite H.
Qed.
然而,上述方法都不能在证明方面给你带来巨大的进步,因此真正的问题是你最初的目的是什么。谢谢。关于axiom,我试着像axiom pb1那样编写它:对于所有vl,proj_bytes vl=Some v.,它不识别v。你能解释一下它的逻辑吗?我指的是你写的那一个的逻辑。
{v|P}
意味着存在一些v
,这样P
就成立了。您还可以更精细,指定一些公理not_undefined vl
,排除不需要的情况,然后进行案例分析。