How can I prove following lemma in Coq?

社会主义新天地 提交于 2019-12-11 16:02:38

问题


I am trying to write a Coq poof for the following lemma:

Require Export Coq.Structures.OrderedTypeEx.
Require Import FMapAVL.
Module M := FMapAVL.Make(Nat_as_OT).

Fixpoint cc (n: nat) (c: M.t nat):bool :=
match M.find n c with
| None => false
| _ => true
end.

Lemma l: forall (n: nat) (k:nat) (m: M.t nat), cc n m = true  -> cc n (M.add k k m) = true.

I'm unable to simplify (M.add k k m) part.


回答1:


First, there is no recursive call in cc, so you should make this definition a plain definition (using keyword Definition instead of Fixpoint).

Second, if you want to reason about the behavior of M.find and M.add, you should look at the theorems stating things about these functions: theorems M.find_2, M.add_2, M.E.eq_dec, and M.add_1 will be useful (I found these lemmas by using the Search command). So start by unfolding cc, then reason by cases on the value of (M.find n m), then use these theorems to progress logically about the functions occurring in your statements. Please note that function M.MapsTo plays a key role in this problem.

I would rather not give you the solution because it looks like an elementary exercise in reasoning about tables.



来源:https://stackoverflow.com/questions/46368346/how-can-i-prove-following-lemma-in-coq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!