Classical.Bundles.Magma¶
Bundle bridge for magmas¶
This is the Classical.Bundles.Magma module of the Agda Universal Algebra Library.
This module supplies the bidirectional bridge between the Ξ£-typed core of
Classical.Structures.Magma and the record-typed Algebra.Bundles.Magma
in the Agda standard library. Both representations carry the same mathematical
content; the bridge exists so that downstream code typed against
Algebra.Bundles.Magma is reusable against the canonical agda-algebras
representation without manual record-shuffling.
The round-trip is stated pointwise on the carrier, in the magma's underlying
setoid equivalence, per
ADR-002 v2 Β§6. The Fin 2
Ξ·-failure under --cubical-compatible would obstruct any propositional
_β‘_-on-the-Ξ£-type formulation; the pointwise statement sidesteps it cleanly,
discharged by Setoid.refl because pair a b 0F and pair a b 1F reduce
definitionally to a and b respectively.
Core to stdlib bundle¶
Going from the canonical Ξ£-typed core to the stdlib record reads off the
domain's Carrier and _β_, exposes the operation in curried form via
Classical.Structures.Magma's _β_, and constructs the IsMagma witness
from the algebra's Interp.cong by unpacking the Fin 2 pattern.
β¨_β©α΅α΅ : Magma Ξ± Ο β stdlib-Magma Ξ± Ο β¨ π΄ β©α΅α΅ = record { Carrier = π[ π΄ ] ; _β_ = _β_ ; _β_ = _β_ ; isMagma = record { isEquivalence = isEquivalence ; β-cong = Ξ» xβy uβv β cong (Interp π΄) (β‘.refl , Ξ» { 0F β xβy ; 1F β uβv }) } } where open Magma-Op π΄; open Setoid π»[ π΄ ]
Stdlib bundle to core¶
The reverse direction reassembles the bundle's Carrier, _β_, and _β_ into
an Algebra Sig-Magma. The interpretation of β-Op uncurries the bundle's
_β_ by reading off args 0F and args 1F; the congruence of Interp is
built from the bundle's β-cong applied pointwise to the argument-tuple's
equivalence proof.
βͺ_β«α΅α΅ : stdlib-Magma Ξ± Ο β Magma Ξ± Ο βͺ M β«α΅α΅ = record { Domain = record { Carrier = stdlib-Magma.Carrier M ; _β_ = stdlib-Magma._β_ M ; isEquivalence = stdlib-Magma.isEquivalence M } ; Interp = interp } where interp : Func (β¨ Sig-Magma β© (stdlib-Magma.setoid M)) (stdlib-Magma.setoid M) interp β¨$β© (β-Op , args) = (M stdlib-Magma.β (args 0F)) (args 1F) cong interp { β-Op , _ } { .β-Op , _ } (β‘.refl , argsβ) = stdlib-Magma.β-cong M (argsβ 0F) (argsβ 1F)
Pointwise round-trip¶
Going core β bundle β core preserves the curried operation pointwise. The two
sides reduce to the same (β-Op ^ π΄) (pair a b) definitionally β pair a b 0F
and pair a b 1F reduce by the pattern matching in pair β so Setoid.refl
discharges the obligation.
module _ {π΄ : Magma Ξ± Ο} where open Magma-Op π΄ ; open Setoid π»[ π΄ ] open Magma-Op βͺ β¨ π΄ β©α΅α΅ β«α΅α΅ renaming ( _β_ to _β'_ ) roundtrip-cbc-ma : (a b : π[ π΄ ]) β (a β' b) β (a β b) roundtrip-cbc-ma a b = refl
The reverse direction, bundle β core β bundle, holds pointwise on the bundle's underlying equivalence by the same reduction.
module _ {π΄ : stdlib-Magma Ξ± Ο} where open stdlib-Magma π΄ using (_β_; _β_; refl) renaming (Carrier to M) open stdlib-Magma β¨ βͺ π΄ β«α΅α΅ β©α΅α΅ using () renaming ( _β_ to _β'_ ) roundtrip-bcb-ma : (a b : M) β (a β b) β (a β' b) roundtrip-bcb-ma a b = refl