Int.effective
import Natural (+, plusComm, plusCancel, plusCongL, plusCongR, swapMid)
import Int (Int, IntR)
import Core.equality (trans)
import Core.quotEffective (effectiveAtEquiv)
cancelStep : {a b c d e f : ℕ}
→ (a + d ≡ b + c) → (c + f ≡ d + e) → a + f + (c + d) ≡ b + e + (c + d)
using (Natural.plusAssoc)
cancelStep =
λa b c d e f h1 h2. trans
_
_
_
swapMid
trans
_
_
_
plusCongL (c + f) h1
trans
_
_
_
plusCongR (b + c) h2
trans (b + c + (d + e)) _ _ swapMid (plusCongR (b + e) (plusComm c d))
cancelTrans : {a b : ℕ} (c d : ℕ) {e f : ℕ} → (a + d ≡ b + c) → (c + f ≡ d + e) → a + f ≡ b + e
using (Natural.plusAssoc)
cancelTrans = λa b c d e f h1 h2. plusCancel _ _ _ (cancelStep h1 h2)
intRRefl : {p : ℕ × ℕ} → IntR p p using (Int.IntR.unfold, plusComm)
intRRefl = λp. ⋆
intRSymm : {p q : ℕ × ℕ} → IntR p q → IntR q p using (Int.IntR.eq, Int.IntR.unfold, plusComm)
intRSymm =
λp q h. q .π₁ + p .π₂
≡⟨ plusComm (p .π₂) (q .π₁) ⟩ p .π₂ + q .π₁
≡⟨ h ⟩ p .π₁ + q .π₂
≡⟨ plusComm (q .π₂) (p .π₁) ⟩ q .π₂ + p .π₁
intRTrans : {p q s : ℕ × ℕ} → IntR p q → IntR q s → IntR p s using (Int.IntR.eq, Int.IntR.unfold)
intRTrans = λp q s h1 h2. cancelTrans _ _ h1 h2
intEffective : {p q : ℕ × ℕ} → (class p ≡ class q ∈ Int) → IntR p q
using (Int.Int.unfold, Int.IntR.unfold)
intEffective = effectiveAtEquiv IntR (intRRefl {}) (intRTrans {}) (intRSymm {})
zeroRel : IntR (Z, Z) (S Z, S Z) using (Int.Int.unfold, Int.IntR.unfold, Int.zeroEq)
zeroRel = intEffective ⋆