Skip to content

Instantly share code, notes, and snippets.

@MikeMKH
Created May 18, 2017 22:09
Show Gist options
  • Save MikeMKH/c2af0af4f8919c687ceaa1e96139b899 to your computer and use it in GitHub Desktop.
Save MikeMKH/c2af0af4f8919c687ceaa1e96139b899 to your computer and use it in GitHub Desktop.
Proof that subtraction is not commutative using Coq.
Require Import Coq.Arith.Arith.
Require Import Omega.
(* from http://stackoverflow.com/a/44039996/2370606 *)
Lemma subtraction_does_not_commute :
forall a b : nat, a <> b -> a - b <> b - a.
Proof.
induction a. intros b.
- now rewrite Nat.sub_0_r.
- destruct b.
+ trivial.
+ repeat rewrite Nat.sub_succ; auto.
Qed.
Lemma subtraction_does_not_commute' :
forall a b : nat, a <> b -> a - b <> b - a.
Proof.
intros; omega.
Qed.
@MikeMKH
Copy link
Author

MikeMKH commented May 18, 2017

Thanks to Anton Trunov on StackOverflow! http://stackoverflow.com/a/44039996/2370606

@MikeMKH
Copy link
Author

MikeMKH commented Nov 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment