Coq induction start at specific nat

故事扮演 提交于 2019-12-07 09:13:34

问题


I'm trying to learn coq so please assume I know nothing about it.

If I have a lemma in coq that starts

forall n m:nat, n>=1 -> m>=1 ...

And I want to proceed by induction on n. How do I start the induction at 1? Currently when I use the "induction n." tactic it starts at zero and this makes the base statement false which makes it hard to proceed.

Any hints?


回答1:


The following is a proof that every proposition P is true forall n>=1, if P is true for 1 and if P is inductively true.

Require Import Omega.

Parameter P : nat -> Prop.
Parameter p1 : P 1.
Parameter pS : forall n, P n -> P (S n).

Goal forall n, n>=1 -> P n.

We begin the proof by induction.

  induction n; intro.

A false base case is no problem, if you have a false hypothesis laying around. In this case 0>=1.

  - exfalso. omega.

The inductive case is tricky, because to access a proof of P n, we first have to proof that n>=1. The trick is to do a case analysis on n. If n=0, then we can trivially proof the goal P 1. If n>=1, we can access P n, and then proof the rest.

  - destruct n.
    + apply p1.
    + assert (S n >= 1) by omega.
      intuition.
      apply pS.
      trivial.
Qed.


来源:https://stackoverflow.com/questions/27205573/coq-induction-start-at-specific-nat

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