Todd Waugh Ambridge, January 2024 # Verification of signed-digit operations \begin{code} {-# OPTIONS --without-K --safe #-} open import MLTT.Spartan open import UF.FunExt open import TWA.Thesis.Chapter2.Sequences open import TWA.Thesis.Chapter5.SignedDigit open import TWA.Thesis.Chapter5.IntervalObject hiding (β¨_β©) module TWA.Thesis.Chapter5.SignedDigitIntervalObject {π¦ : Universe} (fe : FunExt) (io : Interval-object fe π¦) where open import TWA.Thesis.Chapter5.IntervalObjectApproximation fe io open basic-interval-object-development fe io hiding (β1 ; O ; +1) \end{code} ## Representation map \begin{code} β¨_β© : π β π β¨ β1 β© = u β¨ O β© = u β v β¨ +1 β© = v βͺ_β« : πα΄Ί β π βͺ Ξ± β« = M (map β¨_β© Ξ±) _realisesΒΉ_ : (πα΄Ί β πα΄Ί) β (π β π) β π¦ Μ f realisesΒΉ f' = (Ξ± : πα΄Ί) β f' βͺ Ξ± β« οΌ βͺ f Ξ± β« _realisesΒ²_ : (πα΄Ί β πα΄Ί β πα΄Ί) β (π β π β π) β π¦ Μ f realisesΒ² f' = (Ξ± Ξ² : πα΄Ί) β βͺ f Ξ± Ξ² β« οΌ f' βͺ Ξ± β« βͺ Ξ² β« _pw-realisesΒΉ_ : (π β π) β (π β π) β π¦ Μ f pw-realisesΒΉ f' = (a : π) β f' β¨ a β© οΌ β¨ f a β© _pw-realisesΒ²_ : (π β π β π) β (π β π β π) β π¦ Μ f pw-realisesΒ² f' = (a b : π) β f' β¨ a β© β¨ b β© οΌ β¨ f a b β© _realises'_ : (π β πα΄Ί β πα΄Ί) β (π β π β π) β π¦ Μ f realises' f' = (a : π) (Ξ² : πα΄Ί) β βͺ f a Ξ² β« οΌ f' β¨ a β© βͺ Ξ² β« id-realiser : id realisesΒΉ id id-realiser Ξ± = refl β-realiser : {f g : πα΄Ί β πα΄Ί} {f' g' : π β π} β f realisesΒΉ f' β g realisesΒΉ g' β (f β g) realisesΒΉ (f' β g') β-realiser {f} {g} {f'} {g'} fβ gβ Ξ± = ap f' (gβ Ξ±) β fβ (g Ξ±) map-realiser : (f : π β π) (f' : π β π) β f pw-realisesΒΉ f' β is-β-homomorphism fe π π f' β (map f) realisesΒΉ f' map-realiser f f' fβ fβ Ξ± = β-homs-are-M-homs f' fβ (map β¨_β© Ξ±) β ap M (dfunext (fe π€β π¦) (Ξ» i β fβ (Ξ± i))) map-realiserΒ² : (f : π β πα΄Ί β πα΄Ί) (f' : π β π β π) β f realises' f' β ((a : π) β is-β-homomorphism fe π π (f' β¨ a β©)) β (Ξ± Ξ² : πα΄Ί) β M (map βͺ_β« (zipWith f Ξ± (repeat Ξ²))) οΌ M (Ξ» n β f' β¨ Ξ± n β© βͺ Ξ² β«) map-realiserΒ² f f' fβ fβ Ξ± Ξ² = ap M (dfunext (fe π€β π¦) (Ξ» i β fβ (Ξ± i) Ξ²)) \end{code} ## Negation \begin{code} flip-realiser : flip pw-realisesΒΉ β_ flip-realiser β1 = β1-inverse flip-realiser O = O-inverse flip-realiser +1 = +1-inverse neg-realiser : neg realisesΒΉ β_ neg-realiser = map-realiser flip β_ flip-realiser β-is-β-homomorphism \end{code} ## Binary midpoint \begin{code} half : π β π half β2 = u half β1 = u /2 half O = u β v half +1 = v /2 half +2 = v β-hom-l : {a b c : π} β a β (b β c) οΌ (a β b) β (a β c) β-hom-l {a} {b} {c} = β-is-β-homomorphism-r fe π a b c β-idem' = Ξ» {a} β β-idem a β-comm' = Ξ» {a} {b} β β-comm a b β-tran' = Ξ» {a} {b} {c} {d} β β-tran a b c d β-canc' = Ξ» {a} {b} {c} β β-canc a b c div2-aux-οΌ : (x y : π) (z : π) β let (a , b) = div2-aux x y in β¨ a β© β (half b β z) οΌ (half x β (half y β z)) div2-aux-οΌ β2 y z = refl div2-aux-οΌ β1 β2 z = ap (_β ((u β v) β z)) β-idem' β»ΒΉ β β-tran' div2-aux-οΌ β1 β1 z = ap (_β ((v β (u β v)) β z)) (β-idem' β»ΒΉ β β-idem' β»ΒΉ) β β-tran' β ap (_β ((u β u) β z)) β-tran' β β-tran' β ap (_β ((u β (u β v)) β z)) (β-comm' β ap (_β (u β v)) β-idem') div2-aux-οΌ β1 O z = ap (_β (u β z)) β-idem' β»ΒΉ β β-tran' β ap (_β ((u β v) β z)) β-comm' div2-aux-οΌ β1 +1 z = ap (_β ((u β (u β v)) β z)) (β-comm' β ap (_β u) β-idem' β»ΒΉ) β β-tran' β ap (_β (u β z)) β-tran' β β-tran' β ap (_β ((v β (u β v)) β z)) (β-comm' β ap (u β_) β-comm') div2-aux-οΌ β1 +2 z = β-tran' div2-aux-οΌ O y z = refl div2-aux-οΌ +1 β2 z = ap (_β ((u β v) β z)) β-comm' β β-tran' div2-aux-οΌ +1 β1 z = ap (Ξ» - β ((- β v) β ((v β (u β v)) β z))) β-idem' β»ΒΉ β β-tran' β ap (_β (v β z)) β-tran' β β-tran' β ap (_β ((u β (u β v)) β z)) β-comm' div2-aux-οΌ +1 O z = ap (_β (v β z)) β-idem' β»ΒΉ β β-tran' β ap (_β ((u β v) β z)) β-comm' div2-aux-οΌ +1 +1 z = ap (_β ((u β (u β v)) β z)) (β-idem' β»ΒΉ β β-idem' β»ΒΉ) β β-tran' β ap (_β ((v β v) β z)) β-tran' β β-tran' β ap (_β ((v β (u β v)) β z)) (β-comm' β ap (_β (v β u)) β-idem' β ap (v β_) β-comm') div2-aux-οΌ +1 +2 z = ap (_β ((u β v) β z)) β-idem' β»ΒΉ β β-tran' div2-aux-οΌ +2 y z = refl div2-approx' : Ξ (fg-n-approx' (map β¨_β© β div2) (map half)) div2-approx' n f Ξ± = (z , w) , (ap ((map β¨_β© β div2) Ξ± 0 β_) (prβ IH) β div2-aux-οΌ (Ξ± 0) (Ξ± 1) (m (append-one w ((first- n) (tail (map half (b β· x))))))) where b = prβ (div2-aux (Ξ± 0) (Ξ± 1)) x = tail (tail Ξ±) IH = f (b β· x) z w : π z = prβ (prβ IH) w = prβ (prβ IH) div2-realiser : (Ξ± : πα΄Ί) β βͺ div2 Ξ± β« οΌ M (map half Ξ±) div2-realiser = fg-approx-holds (map β¨_β© β div2) (map half) div2-approx' half-add-realiser : (Ξ± Ξ² : πα΄Ί) β M (map half (add2 Ξ± Ξ²)) οΌ (βͺ Ξ± β« β βͺ Ξ² β«) half-add-realiser Ξ± Ξ² = ap M (dfunext (fe π€β π¦) (Ξ» i β Ξ³ (Ξ± i) (Ξ² i))) β M-hom (map β¨_β© Ξ±) (map β¨_β© Ξ²) β»ΒΉ where Ξ³ : (a b : π) β half (a +π b) οΌ (β¨ a β© β β¨ b β©) Ξ³ β1 β1 = β-idem' β»ΒΉ Ξ³ β1 O = refl Ξ³ β1 +1 = refl Ξ³ O β1 = β-comm' Ξ³ O O = β-idem' β»ΒΉ Ξ³ O +1 = β-comm' Ξ³ +1 β1 = β-comm' Ξ³ +1 O = refl Ξ³ +1 +1 = β-idem' β»ΒΉ mid-realiser : mid realisesΒ² _β_ mid-realiser Ξ± Ξ² = div2-realiser (add2 Ξ± Ξ²) β half-add-realiser Ξ± Ξ² \end{code} ## Infinitary midpoint \begin{code} quarter : π‘ β π quarter β4 = u quarter β3 = u β (u β (u β v)) quarter β2 = u β (u β v) quarter β1 = u β (v β (u β v)) quarter O = u β v quarter +1 = v β (u β (u β v)) quarter +2 = v β (u β v) quarter +3 = v β (v β (u β v)) quarter +4 = v l : {a b c : π} β a οΌ b β (a β c) οΌ (b β c) l refl = refl r : {a b c : π} β b οΌ c β (a β b) οΌ (a β c) r refl = refl div4-aux-οΌ : (x y : π‘) (z : π) β let (a , b) = div4-aux x y in β¨ a β© β (quarter b β z) οΌ (quarter x β (quarter y β z)) div4-aux-οΌ β4 y z = refl div4-aux-οΌ β3 β4 z = l (β-idem' β»ΒΉ) β β-tran' div4-aux-οΌ β3 β3 z = l (β-idem' β»ΒΉ) β β-tran' β l (r (l (β-idem' β»ΒΉ β β-comm') β β-tran') β l (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β3 β2 z = l (β-idem' β»ΒΉ) β β-tran' β l (β-idem' β»ΒΉ) β β-tran' β l β-comm' div4-aux-οΌ β3 β1 z = l (β-idem' β»ΒΉ) β β-tran' β l (l (β-idem' β»ΒΉ) β r (l (β-idem' β»ΒΉ) β β-tran' β l β-comm') β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β3 O z = l (β-idem' β»ΒΉ) β β-tran' β l (r β-comm' β l (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β3 +1 z = l (β-idem' β»ΒΉ) β β-tran' β l (l (β-idem' β»ΒΉ) β β-tran' β r (l (β-idem' β»ΒΉ) β β-tran') β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β3 +2 z = l (β-idem' β»ΒΉ β r (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β3 +3 z = l (β-idem' β»ΒΉ β r (β-idem' β»ΒΉ β r (β-idem' β»ΒΉ)) β r β-tran' β β-tran') β β-tran' β l β-idem' div4-aux-οΌ β3 +4 z = β-tran' div4-aux-οΌ β2 β4 z = div2-aux-οΌ β1 β2 z div4-aux-οΌ β2 β3 z = l (β-idem' β»ΒΉ) β β-tran' β l (l (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β2 β2 z = div2-aux-οΌ β1 β1 z div4-aux-οΌ β2 β1 z = l (β-idem' β»ΒΉ) β β-tran' β l (l (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β2 O z = div2-aux-οΌ β1 O z div4-aux-οΌ β2 +1 z = r β-comm' β β-tran' β r (l (β-idem' β»ΒΉ) β β-tran' β l β-comm') β β-tran' β r β-comm' div4-aux-οΌ β2 +2 z = div2-aux-οΌ β1 +1 z div4-aux-οΌ β2 +3 z = l (β-idem' β»ΒΉ) β β-tran' β l (β-tran' β l β-idem') β β-tran' div4-aux-οΌ β2 +4 z = div2-aux-οΌ β1 +2 z div4-aux-οΌ β1 β4 z = l (β-idem' β»ΒΉ) β β-tran' div4-aux-οΌ β1 β3 z = l (β-idem' β»ΒΉ) β β-tran' β l (l (β-idem' β»ΒΉ) β β-tran' β l β-comm' β r (l (β-idem' β»ΒΉ) β β-tran') β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β1 β2 z = l (β-idem' β»ΒΉ β l β-comm' β r (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β1 β1 z = l β-comm' β β-tran' β l (l (β-idem' β»ΒΉ) β β-tran' β r (l (β-idem' β»ΒΉ) β β-tran' β l β-comm') β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β1 O z = l β-comm' β β-tran' β l (l (β-idem' β»ΒΉ) β r β-comm' β β-tran' β r β-comm') β β-tran' β l β-comm' div4-aux-οΌ β1 +1 z = l β-comm' β β-tran' β l (r (l (β-idem' β»ΒΉ) β β-tran') β l (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β1 +2 z = r β-comm' β β-tran' β r (β-idem' β»ΒΉ) β β-tran' β r β-comm' div4-aux-οΌ β1 +3 z = l β-comm' β β-tran' β l (r (l (β-idem' β»ΒΉ β β-comm') β β-tran' β l β-comm' β β-tran') β l (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ β1 +4 z = β-tran' div4-aux-οΌ O y z = refl div4-aux-οΌ +1 β4 z = l β-comm' β β-tran' div4-aux-οΌ +1 β3 z = β-tran' β l (l (β-idem' β»ΒΉ) β β-tran' β l β-comm' β r (l (β-idem' β»ΒΉ) β β-tran') β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +1 β2 z = β-tran' β l (β-idem' β»ΒΉ) β β-tran' β l β-comm' div4-aux-οΌ +1 β1 z = β-tran' β l (r (l (β-idem' β»ΒΉ) β β-tran' β l β-comm') β l (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +1 O z = β-tran' β l (r β-comm' β l (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +1 +1 z = β-tran' β l (l (β-idem' β»ΒΉ) β β-tran' β r (l (β-idem' β»ΒΉ) β β-tran') β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +1 +2 z = β-tran' β l (β-idem' β»ΒΉ β r (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +1 +3 z = l (β-idem' β»ΒΉ) β β-tran' β l (l (β-idem' β»ΒΉ) β β-tran' β l β-comm' β r (l (β-idem' β»ΒΉ) β β-tran' β l β-comm') β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +1 +4 z = l (β-idem' β»ΒΉ) β β-tran' div4-aux-οΌ +2 β4 z = div2-aux-οΌ +1 β2 z div4-aux-οΌ +2 β3 z = l (β-idem' β»ΒΉ) β β-tran' β l (l β-comm' β β-tran' β l β-idem') β β-tran' div4-aux-οΌ +2 β2 z = div2-aux-οΌ +1 β1 z div4-aux-οΌ +2 β1 z = l (β-idem' β»ΒΉ) β β-tran' β l (l β-comm' β β-tran' β l β-idem') β β-tran' div4-aux-οΌ +2 O z = div2-aux-οΌ +1 O z div4-aux-οΌ +2 +1 z = l (β-idem' β»ΒΉ) β β-tran' β l (l (β-idem' β»ΒΉ) β β-tran' β l β-comm' β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +2 +2 z = div2-aux-οΌ +1 +1 z div4-aux-οΌ +2 +3 z = l (β-idem' β»ΒΉ) β β-tran' β l (l (β-idem' β»ΒΉ) β β-tran' β l β-comm' β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +2 +4 z = div2-aux-οΌ +1 +2 z div4-aux-οΌ +3 β4 z = l β-comm' β β-tran' div4-aux-οΌ +3 β3 z = l (β-idem' β»ΒΉ β l β-comm' β r (β-idem' β»ΒΉ β l β-comm' β r (β-idem' β»ΒΉ) β β-tran') β β-tran') β β-tran' β l β-idem' div4-aux-οΌ +3 β2 z = l (β-idem' β»ΒΉ β l β-comm' β r (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +3 β1 z = l (β-idem' β»ΒΉ) β β-tran' β l (l (β-idem' β»ΒΉ) β β-tran' β r (l (β-idem' β»ΒΉ) β β-tran' β l β-comm') β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +3 O z = l (β-idem' β»ΒΉ) β β-tran' β l (l (β-idem' β»ΒΉ) β r β-comm' β β-tran' β r β-comm') β β-tran' β l β-comm' div4-aux-οΌ +3 +1 z = l (β-idem' β»ΒΉ) β β-tran' β l (r (l (β-idem' β»ΒΉ) β β-tran') β l (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +3 +2 z = l (β-idem' β»ΒΉ) β β-tran' β l (β-idem' β»ΒΉ) β β-tran' β l β-comm' div4-aux-οΌ +3 +3 z = l (β-idem' β»ΒΉ) β β-tran' β l (r (l (β-idem' β»ΒΉ) β β-tran' β l β-comm') β l (β-idem' β»ΒΉ) β β-tran') β β-tran' β l β-comm' div4-aux-οΌ +3 +4 z = l (β-idem' β»ΒΉ) β β-tran' div4-aux-οΌ +4 y z = refl div4-approx' : Ξ (fg-n-approx' (map β¨_β© β div4) (map quarter)) div4-approx' n f Ξ± = (z , w) , (ap ((map β¨_β© β div4) Ξ± 0 β_) (prβ IH) β div4-aux-οΌ (Ξ± 0) (Ξ± 1) (m (append-one w ((first- n) (tail (map quarter (b β· x))))))) where b = prβ (div4-aux (Ξ± 0) (Ξ± 1)) x = tail (tail Ξ±) IH = f (b β· x) z w : π z = prβ (prβ IH) w = prβ (prβ IH) quarter-realiser : (Ξ± : π‘α΄Ί) β βͺ div4 Ξ± β« οΌ M (map quarter Ξ±) quarter-realiser = fg-approx-holds (map β¨_β© β div4) (map quarter) div4-approx' βͺβͺ_β«β« : π‘α΄Ί β π βͺβͺ x β«β« = M (map quarter x) _realisesα΄Ί_ : ((β β πα΄Ί) β πα΄Ί) β ((β β π) β π) β π¦ Μ f realisesα΄Ί f' = (Ξ΄s : β β πα΄Ί) β f' (map βͺ_β« Ξ΄s) οΌ βͺ f Ξ΄s β« π‘s-conv-οΌ : (a b c : π) β (β¨ a β© β (β¨ b β© β β¨ c β©)) οΌ quarter ((a +π a) +π (b +π c)) π‘s-conv-οΌ β1 β1 β1 = ap (u β_) β-idem' β β-idem' π‘s-conv-οΌ β1 β1 O = refl π‘s-conv-οΌ β1 β1 +1 = refl π‘s-conv-οΌ β1 O β1 = ap (u β_) β-comm' π‘s-conv-οΌ β1 O O = ap (u β_) β-idem' π‘s-conv-οΌ β1 O +1 = ap (u β_) β-comm' π‘s-conv-οΌ β1 +1 β1 = ap (u β_) β-comm' π‘s-conv-οΌ β1 +1 O = refl π‘s-conv-οΌ β1 +1 +1 = ap (u β_) β-idem' π‘s-conv-οΌ O β1 β1 = β-comm' β ap (_β (u β v)) β-idem' π‘s-conv-οΌ O β1 O = β-tran' β ap (_β (v β (u β v))) β-idem' π‘s-conv-οΌ O β1 +1 = β-idem' π‘s-conv-οΌ O O β1 = ap ((u β v) β_) β-comm' β β-tran' β ap (_β (v β (u β v))) β-idem' π‘s-conv-οΌ O O O = ap ((u β v) β_) β-idem' β β-idem' π‘s-conv-οΌ O O +1 = β-tran' β ap ((u β (u β v)) β_) β-idem' β β-comm' π‘s-conv-οΌ O +1 β1 = ap ((u β v) β_) β-comm' β β-idem' π‘s-conv-οΌ O +1 O = ap (_β (v β (u β v))) β-comm' β β-tran' β ap (_β (u β (u β v))) β-idem' π‘s-conv-οΌ O +1 +1 = β-comm' β ap (_β (u β v)) β-idem' π‘s-conv-οΌ +1 β1 β1 = ap (v β_) β-idem' β β-comm' π‘s-conv-οΌ +1 β1 O = refl π‘s-conv-οΌ +1 β1 +1 = refl π‘s-conv-οΌ +1 O β1 = ap (v β_) β-comm' π‘s-conv-οΌ +1 O O = ap (v β_) β-idem' π‘s-conv-οΌ +1 O +1 = ap (v β_) β-comm' π‘s-conv-οΌ +1 +1 β1 = ap (v β_) β-comm' π‘s-conv-οΌ +1 +1 O = refl π‘s-conv-οΌ +1 +1 +1 = ap (v β_) β-idem' β β-idem' M-bigMid'-οΌ : (x y : πα΄Ί) (z : π) β (βͺ x β« β (βͺ y β« β z)) οΌ (β¨ x 0 β© β (β¨ x 1 β© β β¨ y 0 β©)) β ((βͺ mid (tail (tail x)) (tail y) β«) β z) M-bigMid'-οΌ x y z = ap (_β (βͺ y β« β z)) (M-propβ (map β¨_β© x) β ap (β¨ x 0 β© β_) (M-propβ (map β¨_β© (tail x)))) β ap ((β¨ x 0 β© β (β¨ x 1 β© β βͺ tail (tail x) β«)) β_) (ap (_β z) (M-propβ (map β¨_β© y))) β ap (_β ((β¨ y 0 β© β βͺ tail y β«) β z)) (β-comm') β β-tran' β ap (_β (β¨ x 0 β© β z)) β-tran' β β-tran' β ap (_β ((βͺ tail (tail x) β« β βͺ tail y β«) β z)) β-comm' β ap (Ξ» - β (β¨ x 0 β© β (β¨ x 1 β© β β¨ y 0 β©)) β (- β z)) (mid-realiser (tail (tail x)) (tail y) β»ΒΉ) bigMid'-approx : Ξ (fg-n-approx' (map βͺ_β«) (map quarter β bigMid')) bigMid'-approx n f Ξ±s = (z , w) , (M-bigMid'-οΌ (Ξ±s 0) (Ξ±s 1) (m (append-one z ((first- n) (map βͺ_β« zs)))) β ap (_β ((βͺ mid x y β«) β m (append-one z ((first- n) (map βͺ_β« zs))))) (π‘s-conv-οΌ a b c') β ap (quarter ((a +π a) +π (b +π c')) β_) (prβ IH)) where x = tail (tail (Ξ±s 0)) y = tail (Ξ±s 1) a = Ξ±s 0 0 b = Ξ±s 0 1 c' = Ξ±s 1 0 zs = tail (tail Ξ±s) IH = f (mid x y β· zs) z w : π z = prβ (prβ IH) w = prβ (prβ IH) M-realiser : bigMid realisesα΄Ί M M-realiser Ξ΄s = fg-approx-holds (map βͺ_β«) (map quarter β bigMid') bigMid'-approx Ξ΄s β quarter-realiser (bigMid' Ξ΄s) β»ΒΉ \end{code} ## Multiplication \begin{code} digitMul-realiser : digitMul realises' _*_ digitMul-realiser β1 Ξ± = neg-realiser Ξ± β»ΒΉ β *-gives-negation-r βͺ Ξ± β« β»ΒΉ digitMul-realiser O Ξ± = M-idem (u β v) β *-gives-zero-r βͺ Ξ± β« β»ΒΉ digitMul-realiser +1 Ξ± = id-realiser Ξ± β»ΒΉ β *-gives-id-r βͺ Ξ± β« β»ΒΉ mul-realiser : mul realisesΒ² _*_ mul-realiser Ξ± Ξ² = M-realiser (zipWith digitMul Ξ± (Ξ» _ β Ξ²)) β»ΒΉ β map-realiserΒ² digitMul _*_ digitMul-realiser (Ξ» a β *-is-β-homomorphism-l β¨ a β©) Ξ± Ξ² β β-homs-are-M-homs (_* βͺ Ξ² β«) (*-is-β-homomorphism-r βͺ Ξ² β«) (map β¨_β© Ξ±) β»ΒΉ \end{code}