我无法理解为什么我的 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.
这虽然有效:
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
,我的目标如下所示:
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
使用分号后“管道”它不起作用。
我希望这个问题至少有意义。谢谢!
完整代码:
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.