我想证明不包含0的自然数。因此,我对属性P的基本假设是P 1而不是P 0。
我正在考虑使用n> = 0作为目标假设,但是在Coq中还有另一种方法可以做到这一点吗?
答案 0 :(得分:5)
请考虑将属性转变为所有nat
上的属性。
Definition P' (n : nat) := P (S n).
所以forall n, n >= 1 -> P n
等效于forall n, P' n
。
答案 1 :(得分:0)
只需添加n > 0
或n <> 0
作为假设。示例:
Require Import Arith.
Goal forall n, n > 0 -> forall a, a = n - 1 -> a + 1 = n.
induction n; intros H.
- now apply Nat.nlt_0_r in H. (* This case, 0 > 0, is simply impossible *)
- intros a H1.
now rewrite H1; simpl; rewrite Nat.sub_0_r, Nat.add_comm.
Qed.
答案 2 :(得分:0)
一种可能的变体是直接对属性0 <= n
进行归纳证明。
Require Import Arith.
Goal forall n, 1 <= n -> forall a, a = n - 1 -> a + 1 = n.
induction 1.
(* first case being considered is P 1. *)
now intros a a0; rewrite a0.
now simpl; intros a a_m; rewrite a_m, Nat.add_1_r, Nat.sub_0_r.
Qed.
通过将_ <= _
阶实际上定义为归纳关系这一事实,可以得到这种行为。