Skip to content

Instantly share code, notes, and snippets.

@Lysxia
Last active March 12, 2021 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lysxia/c541ee3621df70b655f4b74517a226ee to your computer and use it in GitHub Desktop.
Save Lysxia/c541ee3621df70b655f4b74517a226ee to your computer and use it in GitHub Desktop.
From Coq Require Import NArith.
Lemma lem1 p : (Pos.succ p) = (p + 1)%positive.
Proof.
induction p; cbn; auto.
Qed.
Lemma lem2 p p0 :
(Pos.succ (p + p0)) = (p + Pos.succ p0)%positive /\ Pos.add_carry p p0 = (p + Pos.succ p0)%positive.
Proof.
revert p0; induction p; cbn; intros []; cbn; split; auto.
all: f_equal.
all: try solve [apply IHp | apply lem1].
etransitivity; [ eapply IHp | symmetry; eapply IHp].
Qed.
Goal
forall n m,
N.succ (N.add n m) = N.add n (N.succ m).
Proof.
intros [] []; cbn; f_equal; apply lem1 + apply lem2.
Qed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment