Rename the new provenance type and remove the old version

This commit is contained in:
Danila Fedorin 2023-07-30 16:45:02 -07:00
parent de2f202bdf
commit 70b85c99cc

View File

@ -260,11 +260,6 @@ _∈k_ k (kvs , _) = MemProp._∈_ k (keys kvs)
Map-functional : {k : A} {v v' : B} {m : Map} (k , v) m (k , v') m v v'
Map-functional {m = (l , ul)} k,v∈m k,v'∈m = ListAB-functional ul k,v∈m k,v'∈m
data Provenance (k : A) (m₁ m₂ : Map) : Set (a b) where
both : (v₁ v₂ : B) (k , v₁) m₁ (k , v₂) m₂ Provenance k m₁ m₂
in₁ : (v₁ : B) (k , v₁) m₁ ¬ k ∈k m₂ Provenance k m₁ m₂
in₂ : (v₂ : B) ¬ k ∈k m₁ (k , v₂) m₂ Provenance k m₁ m₂
data Expr : Set (a b) where
`_ : Map Expr
__ : Expr Expr Expr
@ -285,26 +280,26 @@ module _ (f : B → B → B) where
` m = m
e₁ e₂ = union e₁ e₂
data Magic (k : A) : B Expr Set (a b) where
single : {v : B} {m : Map} (k , v) m Magic k v (` m)
in₁ : {v : B} {e₁ e₂ : Expr} Magic k v e₁ ¬ k ∈k e₂ Magic k v (e₁ e₂)
in₂ : {v : B} {e₁ e₂ : Expr} ¬ k ∈k e₁ Magic k v e₂ Magic k v (e₁ e₂)
bothᵘ : {v₁ v₂ : B} {e₁ e₂ : Expr} Magic k v₁ e₁ Magic k v₂ e₂ Magic k (f v₁ v₂) (e₁ e₂)
data Provenance (k : A) : B Expr Set (a b) where
single : {v : B} {m : Map} (k , v) m Provenance k v (` m)
in₁ : {v : B} {e₁ e₂ : Expr} Provenance k v e₁ ¬ k ∈k e₂ Provenance k v (e₁ e₂)
in₂ : {v : B} {e₁ e₂ : Expr} ¬ k ∈k e₁ Provenance k v e₂ Provenance k v (e₁ e₂)
bothᵘ : {v₁ v₂ : B} {e₁ e₂ : Expr} Provenance k v₁ e₁ Provenance k v₂ e₂ Provenance k (f v₁ v₂) (e₁ e₂)
Expr-Magic : (k : A) (e : Expr) k ∈k e Σ B (λ v (Magic k v e × (k , v) e ))
Expr-Magic k (` m) k∈km = let (v , k,v∈m) = locate k∈km in (v , (single k,v∈m , k,v∈m))
Expr-Magic k (e₁ e₂) k∈ke₁e₂
Expr-Provenance : (k : A) (e : Expr) k ∈k e Σ B (λ v (Provenance k v e × (k , v) e ))
Expr-Provenance k (` m) k∈km = let (v , k,v∈m) = locate k∈km in (v , (single k,v∈m , k,v∈m))
Expr-Provenance k (e₁ e₂) k∈ke₁e₂
with ∈k-dec k (proj₁ e₁ ) | ∈k-dec k (proj₁ e₂ )
... | yes k∈ke₁ | yes k∈ke₂ =
let (v₁ , (g₁ , k,v₁∈e₁)) = Expr-Magic k e₁ k∈ke₁
(v₂ , (g₂ , k,v₂∈e₂)) = Expr-Magic k e₂ k∈ke₂
let (v₁ , (g₁ , k,v₁∈e₁)) = Expr-Provenance k e₁ k∈ke₁
(v₂ , (g₂ , k,v₂∈e₂)) = Expr-Provenance k e₂ k∈ke₂
in (f v₁ v₂ , (bothᵘ g₁ g₂ , union-combines (proj₂ e₁ ) (proj₂ e₂ ) k,v₁∈e₁ k,v₂∈e₂))
... | yes k∈ke₁ | no k∉ke₂ =
let (v₁ , (g₁ , k,v₁∈e₁)) = Expr-Magic k e₁ k∈ke₁
in (v₁ , (in g₁ k∉ke₂ , union-preserves-∈₂ (proj₂ e₁ ) k,v₁∈e₁ k∉ke₂))
let (v₁ , (g₁ , k,v₁∈e₁)) = Expr-Provenance k e₁ k∈ke₁
in (v₁ , (in g₁ k∉ke₂ , union-preserves-∈₂ (proj₂ e₁ ) k,v₁∈e₁ k∉ke₂))
... | no k∉ke₁ | yes k∈ke₂ =
let (v₂ , (g₂ , k,v₂∈e₂)) = Expr-Magic k e₂ k∈ke₂
in (v₂ , (in k∉ke₁ g₂ , union-preserves-∈₁ k∉ke₁ k,v₂∈e₂))
let (v₂ , (g₂ , k,v₂∈e₂)) = Expr-Provenance k e₂ k∈ke₂
in (v₂ , (in k∉ke₁ g₂ , union-preserves-∈₁ k∉ke₁ k,v₂∈e₂))
... | no k∉ke₁ | no k∉ke₂ = absurd (union-preserves-∉ k∉ke₁ k∉ke₂ k∈ke₁e₂)
@ -324,13 +319,13 @@ module _ (f : B → B → B) where
where
union-comm-subset : (m₁ m₂ : Map) subset (_≡_) (union f m₁ m₂) (union f m₂ m₁)
union-comm-subset m₁@(l₁ , u₁) m₂@(l₂ , u₂) k v k,v∈m₁m₂
with Expr-Magic f k ((` m₁) (` m₂)) (∈-cong proj₁ k,v∈m₁m₂)
with Expr-Provenance f k ((` m₁) (` m₂)) (∈-cong proj₁ k,v∈m₁m₂)
... | (_ , (bothᵘ {v₁} {v₂} (single v₁∈m₁) (single v₂∈m₂) , v₁v₂∈m₁m₂))
rewrite Map-functional {m = union f m₁ m₂} k,v∈m₁m₂ v₁v₂∈m₁m₂ =
(f v₂ v₁ , (f-comm v₁ v₂ , ImplInsert.union-combines f u₂ u₁ v₂∈m₂ v₁∈m₁))
... | (_ , (in {v₁} (single v₁∈m₁) k∉km₂ , v₁∈m₁m₂))
... | (_ , (in {v₁} (single v₁∈m₁) k∉km₂ , v₁∈m₁m₂))
rewrite Map-functional {m = union f m₁ m₂} k,v∈m₁m₂ v₁∈m₁m₂ =
(v₁ , (refl , ImplInsert.union-preserves-∈₁ f k∉km₂ v₁∈m₁))
... | (_ , (in {v₂} k∉km₁ (single v₂∈m₂) , v₂∈m₁m₂))
... | (_ , (in {v₂} k∉km₁ (single v₂∈m₂) , v₂∈m₁m₂))
rewrite Map-functional {m = union f m₁ m₂} k,v∈m₁m₂ v₂∈m₁m₂ =
(v₂ , (refl , ImplInsert.union-preserves-∈₂ f u₂ v₂∈m₂ k∉km₁))