Skip to content

Instantly share code, notes, and snippets.

@nkaretnikov
Last active August 28, 2020 16:04
Show Gist options
  • Save nkaretnikov/0627697c7e2e6ad401c6 to your computer and use it in GitHub Desktop.
Save nkaretnikov/0627697c7e2e6ad401c6 to your computer and use it in GitHub Desktop.
plus_lt
Theorem Sx_le_Sx_y : forall x y, S x <= S (x + y).
Proof.
induction y as [|y'].
Case "y' = 0".
rewrite <- plus_n_O.
apply le_n.
Case "y' = S y".
apply le_S.
rewrite <- plus_n_Sm.
apply IHy'.
Qed.
Theorem plus_lt : forall n1 n2 m,
n1 + n2 < m ->
n1 < m /\ n2 < m.
Proof.
intros.
unfold "<" in H.
unfold "<".
induction H.
Case "S (n1 + n2) = m".
split.
SCase "S n1 <= S (n1 + n2)".
apply Sx_le_Sx_y.
SCase "S n2 <= S (n1 + n2)".
rewrite plus_comm.
apply Sx_le_Sx_y.
Case "S (n1 + n2) < m".
split.
SCase "S n1 <= S m".
apply le_S.
(* inversion IHle as [F G]. *)
apply IHle.
SCase "S n2 <= S m".
apply le_S.
apply IHle.
Qed.
@nkaretnikov
Copy link
Author

/\ means that both hypotheses hold. A more explicit way is to use inversion IHle as [F G] first to split them apart.

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