Coq 不使用';似乎它不应该统一是允许的
我在Coq 8.4pl5中遇到了一个我认为可能是错误的东西。鉴于这一证明状态:Coq 不使用';似乎它不应该统一是允许的,coq,unification,Coq,Unification,我在Coq 8.4pl5中遇到了一个我认为可能是错误的东西。鉴于这一证明状态: 1 subgoal st : state a : sinstr a0 : list sinstr b : list sinstr IHa : forall stack : list nat, s_execute st stack (a0 ++ b) = s_execute st (s_execute st stack a0) b stack : list nat ===================
1 subgoal
st : state
a : sinstr
a0 : list sinstr
b : list sinstr
IHa : forall stack : list nat,
s_execute st stack (a0 ++ b) = s_execute st (s_execute st stack a0) b
stack : list nat
======================== ( 1 / 1 )
s_execute st stack ((a :: a0) ++ b) =
s_execute st (s_execute st stack (a :: a0)) b
Coq允许我应用IHa
。当我这样做的时候,它完成了目标并证明了定理
这是一个不正确的统一(我认为是),如果是的话,这个问题已经被报道了吗
如果没有,我将如何进行报告?我知道Coq用于高保证软件,我相信,即使这不是最新版本,也不是特别旧的版本。因此,即使它在以后的版本中已经修复,确保人们意识到这个问题确实存在于这个版本的Coq中也是很好的
作为参考,我已经将代码缩小到了这个范围(我没有尝试进一步缩小范围,因为我不完全理解是什么导致了这个问题)。有问题的apply
位于倒数第二行(注释中有所有星号):
(**aexp**)
需要进口辅币。
感应id:类型:=
|Id:nat->Id。
定理eq_id_dec:对于所有AB:id,
{a=b}+{ab}。
证明。
介绍。
案例(等式a)。
案例_等式b。
介绍。
自毁(相等于自然数)。
左边自动的。
正确的。不要展开。介绍。反转H1。矛盾
Qed。
定义状态:类型:=id->nat。
定义空_状态:状态:=
乐趣=>0。
定义更新(st:state)(i:id)(v:nat):状态:=
fun j=>如果eq\u id\u dec j i
然后v
埃尔斯圣j。
感应式aexp:类型:=
|帮助:id->aexp
|ANum:nat->aexp
|APlus:aexp->aexp->aexp
|阿米努斯:aexp->aexp->aexp
|AMult:aexp->aexp->aexp。
固定点aeval(a:aexp)(st:state):nat:=
匹配
|援助i=>st i
|ANum n=>n
|APlus x y=>aeval x st+aeval y st
|阿米努斯x y=>aeval x st-aeval y st
|AMult x y=>aeval x st*aeval y st
结束。
(**堆栈编译器**)
需要导入列表。
导入列表符号。
感应式sinstr:类型:=
|SPush:nat->sinstr
|SLoad:id->sinstr
|SPlus:sinstr
|斯米努斯:辛斯特
|斯马特:辛斯特。
定点s_执行(st:状态)(堆栈:列表nat)(程序:列表sinstr)
:列表nat:=
匹配程序
|nil=>堆栈
|cons x xs=>
让堆栈“:=将x与
|SPush a=>cons a堆栈
|SLoad v=>cons(st v)堆栈
|SPlus=>将堆栈与
|cons a(cons b rest)=>cons(b+a)rest
| _ => [27]
结束
|SMinus=>将堆栈与
|cons a(cons b rest)=>cons(b-a)rest
| _ => [27]
结束
|SMult=>将堆栈与
|cons a(cons b rest)=>cons(b*a)rest
| _ => [27]
结束
结束
在里面
s_执行st堆栈'xs
结束。
定点s_编译(e:aexp):列表sinstr:=
匹配
|援助i=>[SLoad i]
|ANum n=>[SPush n]
|APlus a b=>(s_编译a)++(s_编译b)+[SPlus]
|阿米努斯AB=>(s_编译a)++(s_编译b)++[SMinus]
|AMult a b=>(s_编译a)++(s_编译b)+[SMult]
结束。
引理s_执行应用程序:对于所有st堆栈a和b,
s_执行st堆栈(a++b)=s_执行st(s_执行st堆栈a)b。
证明。
介绍。
泛化依赖堆栈。
诱导a;试试自反性。
介绍。
应用IHa。(***********************)
Qed。
如果你在介绍后做了siml
,你会发现假设和目标可以统一:
如果你在介绍后做了
siml
,你会发现假设和目标可以统一:
虽然您可能不想报告这个特定的问题,但感谢Arthur的分析,如果您想联系Coq开发人员,他们会在Coq俱乐部和Coq开发人员的邮件列表上闲逛。看 有关档案和更多信息。
还有一个bug跟踪系统,Coq bugs,您可以使用。尽管您可能不想报告这个特定问题,但感谢Arthur的分析,如果您想联系Coq开发者,他们可以在Coq俱乐部和Coq开发者的邮件列表上闲逛。看 有关档案和更多信息。 还有一个bug跟踪系统,coqbug,你可以使用它
(** aexp **)
Require Import Coq.Arith.Peano_dec.
Inductive id : Type :=
| Id : nat -> id.
Theorem eq_id_dec : forall a b : id,
{a = b} + {a <> b}.
Proof.
intros.
case_eq a.
case_eq b.
intros.
destruct (eq_nat_dec n0 n).
left. auto.
right. unfold not. intros. inversion H1. contradiction.
Qed.
Definition state : Type := id -> nat.
Definition empty_state : state :=
fun _ => 0.
Definition update (st : state) (i : id) (v : nat) : state :=
fun j => if eq_id_dec j i
then v
else st j.
Inductive aexp : Type :=
| AId : id -> aexp
| ANum : nat -> aexp
| APlus : aexp -> aexp -> aexp
| AMinus : aexp -> aexp -> aexp
| AMult : aexp -> aexp -> aexp.
Fixpoint aeval (a : aexp) (st : state) : nat :=
match a with
| AId i => st i
| ANum n => n
| APlus x y => aeval x st + aeval y st
| AMinus x y => aeval x st - aeval y st
| AMult x y => aeval x st * aeval y st
end.
(** Stack compiler **)
Require Import List.
Import ListNotations.
Inductive sinstr : Type :=
| SPush : nat -> sinstr
| SLoad : id -> sinstr
| SPlus : sinstr
| SMinus : sinstr
| SMult : sinstr.
Fixpoint s_execute (st : state) (stack : list nat) (prog : list sinstr)
: list nat :=
match prog with
| nil => stack
| cons x xs =>
let stack' := match x with
| SPush a => cons a stack
| SLoad v => cons (st v) stack
| SPlus => match stack with
| cons a (cons b rest) => cons (b + a) rest
| _ => [27]
end
| SMinus => match stack with
| cons a (cons b rest) => cons (b - a) rest
| _ => [27]
end
| SMult => match stack with
| cons a (cons b rest) => cons (b * a) rest
| _ => [27]
end
end
in
s_execute st stack' xs
end.
Fixpoint s_compile (e : aexp) : list sinstr :=
match e with
| AId i => [ SLoad i ]
| ANum n => [ SPush n ]
| APlus a b => (s_compile a) ++ (s_compile b) ++ [ SPlus ]
| AMinus a b => (s_compile a) ++ (s_compile b) ++ [ SMinus ]
| AMult a b => (s_compile a) ++ (s_compile b) ++ [ SMult ]
end.
Lemma s_execute_app : forall st stack a b,
s_execute st stack (a ++ b) = s_execute st (s_execute st stack a) b.
Proof.
intros.
generalize dependent stack.
induction a ; try reflexivity.
intros.
apply IHa. (***********************)
Qed.
s_execute st
match a with
| SPush a1 => a1 :: stack
| SLoad v => st v :: stack
| SPlus =>
match stack with
| [] => [27]
| [a1] => [27]
| a1 :: b0 :: rest => b0 + a1 :: rest
end
| SMinus =>
match stack with
| [] => [27]
| [a1] => [27]
| a1 :: b0 :: rest => b0 - a1 :: rest
end
| SMult =>
match stack with
| [] => [27]
| [a1] => [27]
| a1 :: b0 :: rest => b0 * a1 :: rest
end
end (a0 ++ b) =
s_execute st
(s_execute st
match a with
| SPush a1 => a1 :: stack
| SLoad v => st v :: stack
| SPlus =>
match stack with
| [] => [27]
| [a1] => [27]
| a1 :: b0 :: rest => b0 + a1 :: rest
end
| SMinus =>
match stack with
| [] => [27]
| [a1] => [27]
| a1 :: b0 :: rest => b0 - a1 :: rest
end
| SMult =>
match stack with
| [] => [27]
| [a1] => [27]
| a1 :: b0 :: rest => b0 * a1 :: rest
end
end a0) b