Define relation [<=] on natural numbers by saying that [m <= n] holds if there is a number [k] such that [m = k + n].
Reflexive and transitive have been proved.
reflexive: ref: forall n:nat, n <= n.
transitive: trans: forall l m n:nat, l <= m -> m <= n -> l <= n
Now, how to prove forall lm : nat, l <= m -> m <= l -> m = l
?
I think you meant " m <= n
holds if there is k
such that n = m + k
".
The only additional lemma I needed to prove antisymmetry is:
Lemma le_S_n : forall m n, le (S m) (S n) -> le m n.
Then my proof of antisymmetry goes by induction. Here is the full script:
Require Import Arith.
Definition le (m n :nat) := exists k, n = m + k.
Lemma le_refl : forall m, le m m.
Proof.
intro m; exists 0.
now rewrite <- plus_n_O.
Qed.
Lemma le_trans: forall m n p, le m n -> le n p -> le m p.
Proof.
intros m n p [k1 hk1] [k2 hk2]; exists (k1 + k2).
now rewrite plus_assoc, <- hk1.
Qed.
Lemma le_S_n : forall m n, le (S m) (S n) -> le m n.
Proof.
intros m n [k hk]; exists k.
simpl in hk.
now injection hk; intros.
Qed.
Lemma le_antisym: forall m n, le m n -> le n m -> m = n.
Proof.
induction m as [ | m hi]; destruct n as [ | n ]; simpl in *; intros h1 h2.
- reflexivity.
- destruct h2 as [k hk].
simpl in hk; discriminate hk.
- destruct h1 as [k hk].
simpl in hk; discriminate hk.
- now rewrite (hi n); [ reflexivity | apply le_S_n | apply le_S_n ].
Qed.
Here is a short solution:
Require Omega.
Definition le (n m:nat) := exists k, n + k = m.
Theorem le_nm_mn_eq: forall n m, le n m -> le m n -> n = m.
Proof.
intros n m Hnm Hmn.
inversion Hnm; inversion Hmn.
omega.
Qed.
It uses omega so that I don't have to do all the fiddling with nat
equalities.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.