- 
                Notifications
    
You must be signed in to change notification settings  - Fork 260
 
Closed
Labels
Description
Right now, we define function setoids as follows (taken from Function.Equality):
setoid : ∀ {f₁ f₂ t₁ t₂}
         (From : Setoid f₁ f₂) →
         IndexedSetoid (Setoid.Carrier From) t₁ t₂ →
         Setoid _ _
setoid From To = record
  { Carrier       = Π From To
  ; _≈_           = λ f g → ∀ {x y} → x ≈₁ y → f ⟨$⟩ x ≈₂ g ⟨$⟩ y
  ; isEquivalence = record
    { refl  = λ {f} → cong f
    ; sym   = λ f∼g x∼y → To.sym (f∼g (From.sym x∼y))
    ; trans = λ f∼g g∼h x∼y → To.trans (f∼g From.refl) (g∼h x∼y)
    }
  }
  where
  open module From = Setoid From using () renaming (_≈_ to _≈₁_)
  open module To = IndexedSetoid To   using () renaming (_≈_ to _≈₂_)If we look at the definition of _≈_, we can see that it has cong baked into it. This makes working with these equalities awkward, as you essentially perform a proof that f ⟨$⟩ x ≈₂ g ⟨$⟩ x, then perform a cong at the very end to get that g ⟨$⟩ x ≈₂ g ⟨$⟩ y. It seems like the following equivalent definition would be a bit easier to work with:
setoid : ∀ {f₁ f₂ t₁ t₂}
         (From : Setoid f₁ f₂) →
         IndexedSetoid (Setoid.Carrier From) t₁ t₂ →
         Setoid _ _
setoid From To = record
  { Carrier       = Π From To
  ; _≈_           = λ f g → ∀ x → f ⟨$⟩ x ≈₂ g ⟨$⟩ x
  ; isEquivalence = record
    { refl  = λ {f} _ → To.refl
    ; sym   = λ f∼g x → To.sym (f∼g x)
    ; trans = λ f∼g g∼h x → To.trans (f∼g x) (g∼h x)
    }
  }
  where
  open module From = Setoid From using () renaming (_≈_ to _≈₁_)
  open module To = IndexedSetoid To   using () renaming (_≈_ to _≈₂_)Thoughts?