我试图通过编写Monoid库来学习Agda,但是我在努力证明两个Monoid同构的组成是Monoid同构。
我已经这样定义了Monoids
record Monoid (a : Level) : Set (Level.suc a) where
field
Underlying : Set a
_◓_ : Underlying → Underlying → Underlying
: Underlying
field
◓-assoc : (a b c : Underlying) → ((a ◓ b) ◓ c) ≡ (a ◓ (b ◓ c))
-left-neutral : {a : Underlying} → ◓ a ≡ a
-right-neutral : {a : Underlying} → a ◓ ≡ a
和Monoid同态为
record MonHom {L L'} (M : Monoid L) (M' : Monoid L') : Set ( L ⊔ L') where
open Monoid M
open Monoid M' renaming ( to '; _◓_ to _◓'_ ; Underlying to Underlying')
field
f : Underlying → Underlying'
-preserved : f ≡ '
◓-preserved : (X Y : Underlying) → (f (X ◓ Y)) ≡ (f X ◓' f Y)
要证明Monoid同态构成,需要证明保留了Monoid运算,我在这里尝试这样做:
id-pres-comp : ∀ {a b c} {M : Monoid a} {M' : Monoid b}
{M'' : Monoid c} {f : MonHom M M'} {g : MonHom M' M''}
(X Y : Monoid.Underlying M) →
MonHom.f g (MonHom.f f ((M Monoid.◓ X) Y)) ≡
(M'' Monoid.◓ MonHom.f g (MonHom.f f X))
(MonHom.f g (MonHom.f f Y))
-- (g ∘ f) (X ◓ Y) ≡ ((g ∘ f) X) ◓' ((g ∘ f)
id-pres-comp {a} {b} {c} {M} {M'} {M''}
{record { f = f1 ; -preserved = id-pres1 ; ◓-preserved = comp-pres1 }}
{record { f = g2 ; -preserved = id-pres2 ; ◓-preserved = comp-pres2 }}
X Y with (comp-pres1 X Y)
...| p = {!!}
我的直觉告诉我,使用with
语句对两种同态的保留证明进行模式匹配将使证明变得微不足道,但是由于未知原因我无法与refl
进行匹配,因此我似乎无法取得进展如错误所述:
-- I'm not sure if there should be a case for the constructor refl,
-- because I get stuck when trying to solve the following unification
-- problems (inferred index ≟ expected index):
-- f1 ((M Monoid.◓ X) Y) ≟ (M' Monoid.◓ f1 X) (f1 Y)
-- when checking that the pattern refl has type
-- f1 ((M Monoid.◓ X) Y) ≡ (M' Monoid.◓ f1 X) (f1 Y)
有人可以帮助我理解此错误并帮助我在此证明上取得进步吗?
谢谢!
全要here。