Skip to content

Instantly share code, notes, and snippets.

@oonis
Last active September 23, 2019 13:25
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 oonis/ce6abe60aaeeb938bdc50b9229f2be5a to your computer and use it in GitHub Desktop.
Save oonis/ce6abe60aaeeb938bdc50b9229f2be5a to your computer and use it in GitHub Desktop.
Coq script for the collatz conjecture.
Require Export Coq.PArith.BinPos.
Inductive odd : positive -> Prop :=
| odd_one : odd xH
| odd_xI : forall n : positive, odd (xI (n)).
Inductive even : positive -> Prop :=
| even_xO : forall n : positive, even (xO (n)).
Lemma even_or_odd n : even n \/ odd n.
Proof.
induction n. Focus 3.
right. apply odd_one.
right. apply odd_xI.
left. apply even_xO.
Inductive collatz : positive -> Prop :=
| collatz_one : collatz xH
| collatz_double : forall n : positive, collatz n -> collatz (n + n)
| collatz_divide_three : forall n : positive, ((odd n) /\ (collatz (n + n + n + 1))) -> collatz n.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment