1
我在理解为什么我的Coq代码没有按照我期望的代码执行下面的代码时遇到问题。Coq中分号的奇怪行为
- 我试着让示例尽可能简化,但是当我使它变得更简单时,问题再也没有出现。
- 它使用CompCert 1.8文件。
- 这发生在Coq 8.2-pl2下。
下面是代码:
Require Import Axioms.
Require Import Coqlib.
Require Import Integers.
Require Import Values.
Require Import Asm.
Definition foo (ofs: int) (c: code) : Prop :=
c <> nil /\ ofs <> Int.zero.
Inductive some_prop: nat -> Prop :=
| some_prop_ctor :
forall n other_n ofs c lo hi ofs_ra ofs_link,
some_prop n ->
foo ofs c ->
find_instr (Int.unsigned ofs) c <> Some (Pallocframe lo hi ofs_ra ofs_link) ->
find_instr (Int.unsigned ofs) c <> Some (Pfreeframe lo hi ofs_ra ofs_link) ->
some_prop other_n
.
Lemma simplified:
forall n other_n ofs c,
some_prop n ->
foo ofs c ->
find_instr (Int.unsigned ofs) c = Some Pret ->
some_prop other_n.
Proof.
intros.
这不起作用:
eapply some_prop_ctor
with (lo:=0) (hi:=0) (ofs_ra:=Int.zero) (ofs_link:=Int.zero);
eauto; rewrite H1; discriminate.
上rewrite H1
与失败:
Error:
Found no subterm matching "find_instr (Int.unsigned ofs) c" in the current goal.
这工作虽然:
使用分号不起作用2 subgoals
n : nat
other_n : nat
ofs : int
c : code
H : some_prop n
H0 : foo ofs c
H1 : find_instr (Int.unsigned ofs) c = Some Pret
______________________________________(1/2)
find_instr (Int.unsigned ofs) c <> Some (Pallocframe 0 0 Int.zero Int.zero)
______________________________________(2/2)
find_instr (Int.unsigned ofs) c <> Some (Pfreeframe 0 0 Int.zero Int.zero)
所以,rewrite H1; discriminate
两次工作,但“管”它eauto
后:
eapply some_prop_ctor
with (lo:=0) (hi:=0) (ofs_ra:=Int.zero) (ofs_link:=Int.zero);
eauto.
rewrite H1; discriminate.
rewrite H1; discriminate.
Qed.
而且,就在eauto
后,我的目标是这样的。
我希望这个问题至少有意义。谢谢!
全码:
Require Import Axioms.
Require Import Coqlib.
Require Import Integers.
Require Import Values.
Require Import Asm.
Definition foo (ofs: int) (c: code) : Prop :=
c <> nil /\ ofs <> Int.zero.
Inductive some_prop: nat -> Prop :=
| some_prop_ctor :
forall n other_n ofs c lo hi ofs_ra ofs_link,
some_prop n ->
foo ofs c ->
find_instr (Int.unsigned ofs) c <> Some (Pallocframe lo hi ofs_ra ofs_link) ->
find_instr (Int.unsigned ofs) c <> Some (Pfreeframe lo hi ofs_ra ofs_link) ->
some_prop other_n
.
Lemma simplified:
forall n other_n ofs c,
some_prop n ->
foo ofs c ->
find_instr (Int.unsigned ofs) c = Some Pret ->
some_prop other_n.
Proof.
intros.
(*** This does not work:
eapply some_prop_ctor
with (lo:=0) (hi:=0) (ofs_ra:=Int.zero) (ofs_link:=Int.zero);
eauto; rewrite H1; discriminate.
***)
eapply some_prop_ctor
with (lo:=0) (hi:=0) (ofs_ra:=Int.zero) (ofs_link:=Int.zero);
eauto.
rewrite H1; discriminate.
rewrite H1; discriminate.
Qed.