Setoid.Functions.Basic¶
Setoid functions¶
This is the Setoid.Functions.Basic module of the Agda Universal Algebra Library.
A setoid function A βΆ B is the standard library's Func: a map
on carriers together with a proof that the map respects the equalities of A and
B. Carrying that proof along with the function is what the whole Setoid/ tree
rests on, but it is worth being precise about what it does.
cong says that one map sends related arguments to related results;
it says nothing about when two maps are the same. Where two functions do have to
be compared, the library never asks for propositional equality of functions, but
instead uses an explicitly pointwise relation: function-equality
of Setoid.Relations.Discrete, and _β_ of
Setoid.Categories.Algebra for homomorphisms. The two devices together are
what keep the development extensionality-free.
This module holds the primitives everything else is built from, and nothing deeper: the identity setoid function, composition, and the universe lifting of a setoid. They are gathered here so that the lifting lemmas in particular exist in one place, rather than being re-derived wherever a level has to change.
Because a setoid function carries its own congruence proof, identity and composition need no side conditions: each simply does to the proofs what it does to the maps.
ππis the identity, whose congruence proof is itself the identity._β_is composition, taking the composite of the two maps and the composite of the two congruence proofs. It is written right to left, sof β gappliesgfirst.
The remaining items lift a setoid to a higher universe level, which Agda's universe non-cumulativity makes necessary.
ππππ‘ βraises the level of the carrier and leaves the equality alone, relating two lifted elements exactly when the elements underneath them were related;liftFuncis the setoid function into the lift;liftβΌlowerandlowerβΌliftsay that lifting and lowering are mutually inverse; both are proved by reflexivity alone, which is the point: the lifted equality is the original equality read throughlower, so there is nothing to transport.
ππ : {A : Setoid Ξ± Οα΅} β A βΆ A ππ {A} = record { to = id ; cong = id } open _βΆ_ renaming ( to to _β¨$β©_ ) _β_ : {A : Setoid Ξ± Οα΅}{B : Setoid Ξ² Οα΅}{C : Setoid Ξ³ ΟαΆ} β B βΆ C β A βΆ B β A βΆ C f β g = record { to = (_β¨$β©_ f) β (_β¨$β©_ g); cong = (cong f) β (cong g) } module _ {π¨ : Setoid Ξ± Οα΅} where open Lift ; open Level ; open Setoid using (_β_) open Setoid π¨ using ( sym ; trans ) renaming (Carrier to A ; _β_ to _ββ_ ; refl to reflβ) ππππ‘ : β β β Setoid (Ξ± β β) Οα΅ ππππ‘ β = record { Carrier = Lift β A ; _β_ = Ξ» x y β (lower x) ββ (lower y) ; isEquivalence = record { refl = reflβ ; sym = sym ; trans = trans } } liftβΌlower : (a : Lift Ξ² A) β (_β_ (ππππ‘ Ξ²)) (lift (lower a)) a liftβΌlower a = reflβ lowerβΌlift : β a β (lower {Ξ±}{Ξ²}) (lift a) ββ a lowerβΌlift _ = reflβ liftFunc : {β : Level} β π¨ βΆ ππππ‘ β liftFunc = record { to = lift ; cong = id }