Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
algebra/lattice/filter: cleanup move theorems to appropriate places
- Loading branch information
Showing
11 changed files
with
312 additions
and
288 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/- | ||
Copyright (c) 2017 Johannes Hölzl. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Johannes Hölzl | ||
Extends the theory on functors, applicatives and monads. | ||
-/ | ||
|
||
universes u v w x y | ||
variables {α β γ : Type u} | ||
|
||
section applicative | ||
variables {f : Type u → Type v} [applicative f] | ||
|
||
lemma pure_seq_eq_map : ∀ {α β : Type u} (g : α → β) (x : f α), pure g <*> x = g <$> x := | ||
@applicative.pure_seq_eq_map f _ | ||
|
||
end applicative | ||
|
||
section monad | ||
variables {m : Type u → Type v} [monad m] | ||
|
||
lemma map_bind (x : m α) {g : α → m β} {f : β → γ} : f <$> (x >>= g) = (x >>= λa, f <$> g a) := | ||
by simp [monad.bind_assoc, (∘), (monad.bind_pure_comp_eq_map _ _ _).symm] | ||
|
||
lemma seq_bind_eq (x : m α) {g : β → m γ} {f : α → β} : (f <$> x) >>= g = (x >>= g ∘ f) := | ||
show bind (f <$> x) g = bind x (g ∘ f), | ||
by rw [←monad.bind_pure_comp_eq_map, monad.bind_assoc]; simp [monad.pure_bind] | ||
|
||
lemma seq_eq_bind_map {x : m α} {f : m (α → β)} : f <*> x = (f >>= (<$> x)) := | ||
(monad.bind_map_eq_seq m f x).symm | ||
|
||
lemma bind_assoc : ∀ {α β γ : Type u} (x : m α) (f : α → m β) (g : β → m γ), | ||
x >>= f >>= g = x >>= λ x, f x >>= g := | ||
@monad.bind_assoc m _ | ||
|
||
end monad |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/- | ||
Copyright (c) 2017 Johannes Hölzl. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Johannes Hölzl | ||
Extends theory on products | ||
-/ | ||
|
||
universes u v | ||
variables {α : Type u} {β : Type v} | ||
|
||
-- copied from parser | ||
@[simp] lemma prod.mk.eta : ∀{p : α × β}, (p.1, p.2) = p | ||
| (a, b) := rfl | ||
|
||
def prod.swap : (α×β) → (β×α) := λp, (p.2, p.1) | ||
|
||
@[simp] lemma prod.swap_swap : ∀x:α×β, prod.swap (prod.swap x) = x | ||
| ⟨a, b⟩ := rfl | ||
|
||
@[simp] lemma prod.fst_swap {p : α×β} : (prod.swap p).1 = p.2 := rfl | ||
|
||
@[simp] lemma prod.snd_swap {p : α×β} : (prod.swap p).2 = p.1 := rfl | ||
|
||
@[simp] lemma prod.swap_prod_mk {a : α} {b : β} : prod.swap (a, b) = (b, a) := rfl | ||
|
||
@[simp] lemma prod.swap_swap_eq : prod.swap ∘ prod.swap = @id (α × β) := | ||
funext $ prod.swap_swap | ||
|
Oops, something went wrong.