2
試圖證明元素插入bst的正確性我被卡住試圖證明一個看似微不足道的引理。 到目前爲止,我嘗試:使用coq,試圖證明樹上的簡單引理
Inductive tree : Set :=
| leaf : tree
| node : tree -> nat -> tree -> tree.
Fixpoint In (n : nat) (T : tree) {struct T} : Prop :=
match T with
| leaf => False
| node l v r => In n l \/ v = n \/ In n r
end.
(* all_lte is the proposition that all nodes in tree t
have value at most n *)
Definition all_lte (n : nat) (t : tree) : Prop :=
forall x, In x t -> (x <= n).
Lemma all_lte_trans: forall n m t, n <= m /\ all_lte n t -> all_lte m t.
Proof.
intros.
destruct H.
unfold all_lte in H0.
unfold all_lte.
intros.
顯然,如果一切都在樹小於n
和n <= m
一切比m
小,但我似乎無法使COQ相信我。我該如何繼續?
謝謝,eapply幫助確實。 –