Created
May 18, 2017 22:09
-
-
Save MikeMKH/c2af0af4f8919c687ceaa1e96139b899 to your computer and use it in GitHub Desktop.
Proof that subtraction is not commutative using Coq.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
See also the talk I made out of this https://github.com/MikeMKH/talks/tree/master/on-the-commutability-of-subtraction
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to Anton Trunov on StackOverflow! http://stackoverflow.com/a/44039996/2370606