Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polynomials over rings with decidable equality #1169

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions Cubical/Algebra/Polynomials/UnivariateList/Decidable.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{-# OPTIONS --safe #-}
module Cubical.Algebra.Polynomials.UnivariateList.Decidable where

{-
Polynomials over commutative rings with decidable equality
==========================================================
-}


open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels

open import Cubical.Relation.Nullary.Base using (decRec; ¬_)
open import Cubical.Relation.Nullary.DecidablePropositions

open import Cubical.Data.Sigma
open import Cubical.Data.Nat renaming (_+_ to _Nat+_; _·_ to _Nat·_) hiding (·-comm)
open import Cubical.Data.Nat.Order
open import Cubical.Data.Sum as Sum
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Bool hiding (_≤_)
open import Cubical.HITs.PropositionalTruncation as PT

open import Cubical.Algebra.Group
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRing

open import Cubical.Algebra.Polynomials.UnivariateList.Base

private variable
ℓ : Level

{-
if a eventually true sequence of decidable propositions starts with a false propostion,
then there is a highest natural number for which it is false
-}
lemma : (s : ℕ → DecProp ℓ)
→ ¬ (s zero .fst .fst)
→ ∃[ k ∈ ℕ ] ((l : ℕ) → k ≤ l → (s l) .fst .fst)
→ Σ[ n ∈ ℕ ] ((¬ ((s n) .fst .fst)) × ((l : ℕ) → suc n ≤ l → (s l) .fst .fst))
lemma s s-zero eventuallyHolds =
PT.rec isPropLatestCounterexamples
(λ {(k , p) → byInduction k p})
eventuallyHolds
where isPropLatestCounterexamples : isProp (Σ[ n ∈ ℕ ] ((¬ ((s n) .fst .fst)) × ((l : ℕ) → suc n ≤ l → (s l) .fst .fst)))
isPropLatestCounterexamples (n , p) (n' , p') =
Σ≡Prop (λ x → isProp× (isPropΠ (λ _ → isProp⊥)) (isPropΠ λ _ → isPropΠ λ _ → s _ .fst .snd))
(≤CaseInduction {P = _≡_}
(λ n≤n' → Sum.rec (λ suc-n≤n' → ⊥.rec ((p' .fst) (p .snd n' suc-n≤n') )) (λ n≡n' → n≡n') (≤-split n≤n'))
(λ n'≤n → Sum.rec (λ suc-n'≤n → ⊥.rec ((p .fst) (p' .snd n suc-n'≤n))) sym (≤-split n'≤n)))

byInduction : (k' : ℕ) → ((l : ℕ) → k' ≤ l → (s l) .fst .fst)
→ Σ[ n ∈ ℕ ] ((¬ ((s n) .fst .fst)) × ((l : ℕ) → suc n ≤ l → (s l) .fst .fst))
byInduction zero eventuallyHolds = zero , s-zero , λ l → λ 1≤l → eventuallyHolds l (≤-trans zero-≤ 1≤l)
byInduction (suc k) eventuallyHolds =
decRec (λ p →
byInduction k
(λ l k≤l → Sum.rec (λ k<l → eventuallyHolds l k<l)
(λ k≡l → subst (λ l → s l .fst .fst) k≡l p)
(≤-split k≤l)))
(λ ¬p → k , ¬p , (λ l k+1≤l → eventuallyHolds l k+1≤l))
(s k .snd)
Loading