| 1 |
------------------------------------------------------------------------ |
| 2 |
-- The Agda standard library |
| 3 |
-- |
| 4 |
-- Homomorphism proofs for negation over polynomials |
| 5 |
------------------------------------------------------------------------ |
| 6 |
|
| 7 |
{-# OPTIONS --cubical-compatible --safe #-} |
| 8 |
|
| 9 |
open import Tactic.RingSolver.Core.Polynomial.Parameters |
| 10 |
|
| 11 |
module Tactic.RingSolver.Core.Polynomial.Homomorphism.Negation |
| 12 |
{r₁ r₂ r₃ r₄} |
| 13 |
(homo : Homomorphism r₁ r₂ r₃ r₄) |
| 14 |
where |
| 15 |
|
| 16 |
open import Data.Vec.Base using (Vec) |
| 17 |
open import Data.Product.Base using (_,_) |
| 18 |
open import Data.Nat.Base using (_<′_) |
| 19 |
open import Data.Nat.Induction |
| 20 |
|
| 21 |
open import Function.Base using (_⟨_⟩_; flip) |
| 22 |
|
| 23 |
open Homomorphism homo |
| 24 |
open import Tactic.RingSolver.Core.Polynomial.Homomorphism.Lemmas homo |
| 25 |
open import Tactic.RingSolver.Core.Polynomial.Reasoning to |
| 26 |
open import Tactic.RingSolver.Core.Polynomial.Base from |
| 27 |
open import Tactic.RingSolver.Core.Polynomial.Semantics homo |
| 28 |
|
| 29 |
⊟-step-hom : ∀ {n} (a : Acc _<′_ n) → (xs : Poly n) → ∀ ρ → ⟦ ⊟-step a xs ⟧ ρ ≈ - (⟦ xs ⟧ ρ) |
| 30 |
⊟-step-hom (acc _ ) (Κ x ⊐ i≤n) ρ = -‿homo x |
| 31 |
⊟-step-hom (acc wf) (⅀ xs ⊐ i≤n) ρ′ = |
| 32 |
let (ρ , ρs) = drop-1 i≤n ρ′ |
| 33 |
neg-zero = |
| 34 |
begin |
| 35 |
0# |
| 36 |
≈⟨ sym (zeroʳ _) ⟩ |
| 37 |
- 0# * 0# |
| 38 |
≈⟨ -‿*-distribˡ 0# 0# ⟩ |
| 39 |
- (0# * 0#) |
| 40 |
≈⟨ -‿cong (zeroˡ 0#) ⟩ |
| 41 |
- 0# |
| 42 |
∎ |
| 43 |
in |
| 44 |
begin |
| 45 |
⟦ poly-map (⊟-step (wf i≤n)) xs ⊐↓ i≤n ⟧ ρ′ |
| 46 |
≈⟨ ⊐↓-hom (poly-map (⊟-step (wf i≤n)) xs) i≤n ρ′ ⟩ |
| 47 |
⅀?⟦ poly-map (⊟-step (wf i≤n)) xs ⟧ (ρ , ρs) |
| 48 |
≈⟨ poly-mapR ρ ρs (⊟-step (wf i≤n)) -_ (-‿cong) (λ x y → *-comm x (- y) ⟨ trans ⟩ -‿*-distribˡ y x ⟨ trans ⟩ -‿cong (*-comm _ _)) (λ x y → sym (-‿+-comm x y)) (flip (⊟-step-hom (wf i≤n)) ρs) (sym neg-zero ) xs ⟩ |
| 49 |
- ⅀⟦ xs ⟧ (ρ , ρs) |
| 50 |
∎ |
| 51 |
|
| 52 |
⊟-hom : ∀ {n} |
| 53 |
→ (xs : Poly n) |
| 54 |
→ (Ρ : Vec Carrier n) |
| 55 |
→ ⟦ ⊟ xs ⟧ Ρ ≈ - ⟦ xs ⟧ Ρ |
| 56 |
⊟-hom = ⊟-step-hom (<′-wellFounded _) |