Coq 简化假设
我想证明以下术语:Coq 简化假设,coq,Coq,我想证明以下术语: Goal forall x y, andb x y = true -> x = true. 这相当于 Goal forall x y, ((andb x y) = true) -> (x = true). 因此,我在纸上的方法是检查x和y的所有选项,并表明只要左手边为真(真=真),右手边也为真(真=真),这将满足蕴涵的要求 Proof. intros x y A. destruct x. - destruct y. + reflexivity.
Goal forall x y, andb x y = true -> x = true.
这相当于
Goal forall x y, ((andb x y) = true) -> (x = true).
因此,我在纸上的方法是检查x和y的所有选项,并表明只要左手边为真(真=真),右手边也为真(真=真),这将满足蕴涵的要求
Proof.
intros x y A. destruct x.
- destruct y.
+ reflexivity.
+ reflexivity. (*I am not certain why this works but I assume due to the implication*)
- destruct y.
(* here I am lost*)
Qed.
我需要简化假设,因为当前存在A:(false&&true)%bool=true
和对&
的评估,并将产生false
,因此,A:false=true
,我可以重写目标以显示false=false
,这将通过自反性解决。但是使用simple A.
会产生错误:无法将A强制为可评估的引用。
和直接重写A会产生错误:在当前目标中找不到子项匹配“(false&&true)%bool)。
如何将我的假设A从(false&&true)%bool=true
简化为false=true
,以重写我的目标?回答您的直接问题:
如何将我的假设A从(false&&true)%bool=true
简化为false=true
,以重写我的目标
(1)只需在A中使用siml即可。
(在siml
之后的“中有关键字)
(2)另一种变体是
rewrite <- A. (* notice the arrow which shows rewriting direction *)
reflexivity. (* this will also perform simplification *)
一旦你转向更大的Coq开发,你可能会临时使用一种简洁的风格。这将是我的证明现在销毁0,0。
@ejgallego非常好,谢谢!然而,我试图使用OP熟悉的策略:)@Sim请参阅ejgallego的上述评论。另一个变体是destructx;自动。
(但是auto
比easy
更复杂,now
是基于的)我喜欢向初学者展示一个更紧凑的东西,即使它对教学不是很好。他们经常抱怨琐碎的证明在Coq中非常冗长或复杂,事实上,大多数教材并不鼓励“有效”的证明风格。@ejgallego同意。我想A.Chlipala的CPDT是一个显著的例外,但我不确定它是否适合初学者。你有没有碰巧知道任何演示“高效证明风格”的教程?[甚至在某些高级水平上]。谷歌没有帮助:)
intros x y A.
destruct x.
- reflexivity. (* x = true *)
- simpl in A. rewrite A. reflexivity. (* x = false *)