【发布时间】:2016-06-06 16:33:25
【问题描述】:
我很难理解如何在证明中使用我在 Coq 中定义的一些东西。我有这个定义和功能片段:
Inductive string : Set :=
| E : string
| s : nat -> string -> string.
Inductive deduce : Set :=
|de : string -> string -> deduce.
Infix "|=" := de.
Inductive Rules : deduce -> Prop :=
| compress : forall (n : nat) (A : string), rule (( s n ( s n A)) |= ( s n A))
| transitive : forall A B C : string, rule (A |= B) -> rule (B |= C) -> rule (A |= C).
Fixpoint RepString (n m : nat): string:=
match n with
|0 => E
|S n => s m ( RepString n m)
end.
我需要证明一些看似简单的事情,但我遇到了两个问题:
Lemma LongCompress (C : string)(n : nat): n >=1 -> Rules
((RepString n 0 ) |= (s 0 E) ).
Proof.
intros.
induction n.
inversion H.
simpl.
apply compress.
所以这里我有一个问题,我得到:
"Unable to unify "Rules (s ?M1805 (s ?M1805 ?M1806) |= s ?M1805 ?M1806)" with
"Rules (s 0 (RepString n 0) |- s 0 E)".'"
现在,我知道为什么会出现错误,虽然从技术上讲 RepString n 0 与 s 0 (s 0 (s 0( ... s 0 E))) 相同,但我根本找不到让 coq 知道的方法,我尝试过与 apply compress with 混淆10 件不同的事情我仍然无法做到。我需要像那样“展开”它(当然unfold 不起作用......)。
我没有想法,非常感谢您对此的任何意见!
从现在开始编辑。
Inductive Rules : deduce -> Prop :=
| compress : forall (n : nat) (A : string), rule (( s n ( s n A)) |= ( s n A))
| transitive : forall A B C : string, rule (A |= B) -> rule (B |= C) -> rule (A |= C)
| inspection : forall (n m : nat) (A : string), m < n -> rule ((s n A) |- (s m A)).
Definition less (n :nat ) (A B : string) := B |= (s n A).
Lemma oneLess (n m : nat): rule (less 0 (RepString n 1) (RepString m 1)) <-> n< m.
我已经概括了 Anton Trunov 帮助我证明的引理,但现在我遇到了另一面墙。我认为问题可能从我编写定理本身的方式开始,我会欣赏任何想法。
【问题讨论】:
标签: coq