Prove idempotence
This commit is contained in:
parent
fceee34cee
commit
a4eaa6269f
22
Map.agda
22
Map.agda
|
@ -343,11 +343,26 @@ module _ (_≈_ : B → B → Set b) where
|
||||||
lift m₁ m₂ = subset m₁ m₂ × subset m₂ m₁
|
lift m₁ m₂ = subset m₁ m₂ × subset m₂ m₁
|
||||||
|
|
||||||
module _ (f : B → B → B) where
|
module _ (f : B → B → B) where
|
||||||
module _ (f-comm : ∀ (b₁ b₂ : B) → f b₁ b₂ ≡ f b₂ b₁)
|
|
||||||
(f-assoc : ∀ (b₁ b₂ b₃ : B) → f (f b₁ b₂) b₃ ≡ f b₁ (f b₂ b₃)) where
|
|
||||||
|
|
||||||
module I = ImplInsert f
|
module I = ImplInsert f
|
||||||
|
|
||||||
|
module _ (f-idemp : ∀ (b : B) → f b b ≡ b) where
|
||||||
|
union-idemp : ∀ (m : Map) → lift (_≡_) (union f m m) m
|
||||||
|
union-idemp m@(l , u) = (mm-m-subset , m-mm-subset)
|
||||||
|
where
|
||||||
|
mm-m-subset : subset (_≡_) (union f m m) m
|
||||||
|
mm-m-subset k v k,v∈mm
|
||||||
|
with Expr-Provenance f k ((` m) ∪ (` m)) (∈-cong proj₁ k,v∈mm)
|
||||||
|
... | (_ , (bothᵘ (single {v'} v'∈m) (single {v''} v''∈m) , v'v''∈mm))
|
||||||
|
rewrite Map-functional {m = m} v'∈m v''∈m
|
||||||
|
rewrite Map-functional {m = union f m m} k,v∈mm v'v''∈mm =
|
||||||
|
(v'' , (f-idemp v'' , v''∈m))
|
||||||
|
... | (_ , (in₁ (single {v'} v'∈m) k∉km , _)) = absurd (k∉km (∈-cong proj₁ v'∈m))
|
||||||
|
... | (_ , (in₂ k∉km (single {v''} v''∈m) , _)) = absurd (k∉km (∈-cong proj₁ v''∈m))
|
||||||
|
|
||||||
|
m-mm-subset : subset (_≡_) m (union f m m)
|
||||||
|
m-mm-subset k v k,v∈m = (f v v , (sym (f-idemp v) , I.union-combines u u k,v∈m k,v∈m))
|
||||||
|
|
||||||
|
module _ (f-comm : ∀ (b₁ b₂ : B) → f b₁ b₂ ≡ f b₂ b₁) where
|
||||||
union-comm : ∀ (m₁ m₂ : Map) → lift (_≡_) (union f m₁ m₂) (union f m₂ m₁)
|
union-comm : ∀ (m₁ m₂ : Map) → lift (_≡_) (union f m₁ m₂) (union f m₂ m₁)
|
||||||
union-comm m₁ m₂ = (union-comm-subset m₁ m₂ , union-comm-subset m₂ m₁)
|
union-comm m₁ m₂ = (union-comm-subset m₁ m₂ , union-comm-subset m₂ m₁)
|
||||||
where
|
where
|
||||||
|
@ -364,6 +379,7 @@ module _ (f : B → B → B) where
|
||||||
rewrite Map-functional {m = union f m₁ m₂} k,v∈m₁m₂ v₂∈m₁m₂ =
|
rewrite Map-functional {m = union f m₁ m₂} k,v∈m₁m₂ v₂∈m₁m₂ =
|
||||||
(v₂ , (refl , I.union-preserves-∈₁ u₂ v₂∈m₂ k∉km₁))
|
(v₂ , (refl , I.union-preserves-∈₁ u₂ v₂∈m₂ k∉km₁))
|
||||||
|
|
||||||
|
module _ (f-assoc : ∀ (b₁ b₂ b₃ : B) → f (f b₁ b₂) b₃ ≡ f b₁ (f b₂ b₃)) where
|
||||||
union-assoc : ∀ (m₁ m₂ m₃ : Map) → lift (_≡_) (union f (union f m₁ m₂) m₃) (union f m₁ (union f m₂ m₃))
|
union-assoc : ∀ (m₁ m₂ m₃ : Map) → lift (_≡_) (union f (union f m₁ m₂) m₃) (union f m₁ (union f m₂ m₃))
|
||||||
union-assoc m₁@(l₁ , u₁) m₂@(l₂ , u₂) m₃@(l₃ , u₃) = (union-assoc₁ , union-assoc₂)
|
union-assoc m₁@(l₁ , u₁) m₂@(l₂ , u₂) m₃@(l₃ , u₃) = (union-assoc₁ , union-assoc₂)
|
||||||
where
|
where
|
||||||
|
|
Loading…
Reference in New Issue
Block a user