-
Notifications
You must be signed in to change notification settings - Fork 248
Some lemmata for lists and non-empty lists #2730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c6da092
e5ac9d9
dff840d
ac94640
a4d2bdb
8141130
b92bc58
f308aeb
7870a46
5d295c8
aeaa101
27eb80f
ba58b75
2170c80
71d1c8c
d232bb7
84a8470
5a5219a
ac3603c
6592e8b
3ee0527
3f93c6c
d2fccba
18a4366
20fd595
c868134
4f0a5ea
a9827e6
1274d6a
843eef9
726883b
0a9db06
8669bad
15abb26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,7 +134,6 @@ length-++ (x ∷ xs) = cong suc (length-++ xs) | |
module _ {A : Set a} where | ||
|
||
open AlgebraicDefinitions {A = List A} _≡_ | ||
open AlgebraicStructures {A = List A} _≡_ | ||
|
||
++-assoc : Associative _++_ | ||
++-assoc [] ys zs = refl | ||
|
@@ -190,6 +189,47 @@ module _ {A : Set a} where | |
++-conical : Conical [] _++_ | ||
++-conical = ++-conicalˡ , ++-conicalʳ | ||
|
||
length-++-sucˡ : ∀ (x : A) (xs ys : List A) → | ||
length (x ∷ xs ++ ys) ≡ suc (length (xs ++ ys)) | ||
length-++-sucˡ _ _ _ = refl | ||
|
||
length-++-sucʳ : ∀ (xs : List A) (y : A) (ys : List A) → | ||
length (xs ++ y ∷ ys) ≡ suc (length (xs ++ ys)) | ||
length-++-sucʳ [] _ _ = refl | ||
length-++-sucʳ (_ ∷ xs) y ys = cong suc (length-++-sucʳ xs y ys) | ||
|
||
length-++-comm : ∀ (xs ys : List A) → | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this would be easier to prove as a corollary of length being preserved by permutations? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly, this means to
This should be possible and the theorems 1 and 2 should be useful as well. I am not sure this would be a simpler as a sole means to prove Given that there are multiple definitions of permutations, which one should be used here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know step 1 already exists, I've used it recently. I'm almost sure step 2 does as well. I'd use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd caution against doing this for dependency tree reasons... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So how should we proceed with this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Note that I approved the changes, my suggestion above was for a potential future, not this. Now it's up to someone else to also approve the latest changes. Maybe @MatthewDaggitt can re-review?) |
||
length (xs ++ ys) ≡ length (ys ++ xs) | ||
length-++-comm xs [] = cong length (++-identityʳ xs) | ||
length-++-comm [] (y ∷ ys) = sym (cong length (++-identityʳ (y ∷ ys))) | ||
length-++-comm (x ∷ xs) (y ∷ ys) = | ||
begin | ||
length (x ∷ xs ++ y ∷ ys) | ||
≡⟨⟩ | ||
suc (length (xs ++ y ∷ ys)) | ||
≡⟨ cong suc (length-++-sucʳ xs y ys) ⟩ | ||
suc (suc (length (xs ++ ys))) | ||
≡⟨ cong suc (cong suc (length-++-comm xs ys)) ⟩ | ||
suc (suc (length (ys ++ xs))) | ||
≡⟨ cong suc (length-++-sucʳ ys x xs) ⟨ | ||
suc (length (ys ++ x ∷ xs)) | ||
≡⟨⟩ | ||
length (y ∷ ys ++ x ∷ xs) | ||
∎ | ||
|
||
length-++-≤ˡ : ∀ (xs : List A) {ys} → | ||
length xs ≤ length (xs ++ ys) | ||
length-++-≤ˡ [] = z≤n | ||
length-++-≤ˡ (x ∷ xs) = s≤s (length-++-≤ˡ xs) | ||
|
||
length-++-≤ʳ : ∀ (ys : List A) {xs} → | ||
length ys ≤ length (xs ++ ys) | ||
length-++-≤ʳ ys {xs} = ≤-trans (length-++-≤ˡ ys) (≤-reflexive (length-++-comm ys xs)) | ||
|
||
module _ {A : Set a} where | ||
|
||
open AlgebraicStructures {A = List A} _≡_ | ||
|
||
++-isMagma : IsMagma _++_ | ||
++-isMagma = record | ||
{ isEquivalence = isEquivalence | ||
|
Uh oh!
There was an error while loading. Please reload this page.