Created
September 2, 2016 04:45
-
-
Save mukeshtiwari/1152a57b4b21ed488bb2daaf81600c85 to your computer and use it in GitHub Desktop.
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
Lemma length_pair : forall {A : Type} (n : nat) (l : list A), | |
length l <= n -> length (all_pairs l) <= n * n. | |
Proof. | |
intros. induction l. | |
auto with arith. | |
simpl. repeat rewrite app_length. | |
repeat rewrite map_length. | |
A : Type | |
n : nat | |
a : A | |
l : list A | |
H : length (a :: l) <= n | |
IHl : length l <= n -> length (all_pairs l) <= n * n | |
============================ | |
S (length (all_pairs l) + (length l + length l)) <= n * n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Definition of all_pair
Fixpoint all_pairs {A: Type} (l: list A): list (A * A) :=
match l with
| [] => []
| c::cs => (c, c) :: (all_pairs cs)
++ (map (fun x => (c, x)) cs)
++ (map (fun x => (x, c)) cs)
end.