Skip to content

on lib-2.2-rc1 #2542

Closed
Closed
@mechvel

Description

@mechvel

I have tested it under
Agda 2.7.0.1 built with flags (cabal -f optimise-heavily)
ghc-9.0.2. Debian Linux 12
on my large library of computer algebra.

It works all right.
Please, find my remarks below.

  • Algebra.Definitions.RawMagma defines
x ∤∤ y = ¬ x ∣∣ y                                                               

I doubt, may be it is better to denote this ¬∣∣.
Because seeing x ∤∤ y the reader could think of "neither x ∣ y nor y ∣ x".


Data.List.Base:

deduplicate : ∀ {R : Rel A p} → B.Decidable R → List A → List A                 

The names take, drop, span, takeWhile, filter ... come from the Haskell library.
And deduplicate corresponds to nub of Haskell library.
Right?
So, I wonder of whether deduplicate needs to be renamed to nub
(also I do not know the mnemonic of the name nub).

It is also needed a proof for the main properties of deduplicate, the ones that explain why this function is needed:
(a) ys = (deduplicate xs) and xs need to be equal as sets (to be subsets of each other),
(b) ys must not have repetitions.

For example, I have in my library

  data AnyRelates (_~_ : Rel A β) :  Pred (List A) (α ⊔ β)                      
       where                                                                    
       here  :  ∀ {x xs} → Any (x ~_) xs → AnyRelates _~_ (x ∷ xs)              
       there :  ∀ {x xs} → AnyRelates _~_ xs → AnyRelates _~_ (x ∷ xs)          
                                                                                                               
AnyRepeats : Pred (List C) (α ⊔ α≈)     -- over a Setoid                          
AnyRepeats = AnyRelates _≈_                                                     
                                                                                
Over DecSetoid:                                                                 
nub :  (xs : List C) → Σ (List C) (\ys → (xs =ₛ ys) × ¬ AnyRepeats ys)          

Why is it introduced ∃[ x ] (P x)
while it is provided ∃ (\x → P x) ?
Is the former simpler? It looks like multiplying entities.


Data.List.Properties:

product≢0 : All NonZero ns → NonZero (product ns)                               

It is better to treat the thing in a general way.
To introduce IntegralSemiring (a semiring without zero divisor). It is Semiring with the axiom

∀ {x y} → x * y ≈ 0# → x ≈ 0# ⊎ y ≈ 0#   -- (I)                                 

For example, and ℤ/(3) (integers modulo 3) are integral semirings,
while ℕ × ℕ and ℤ/(4) are not.

Then, and have the IntegralSemiring instance proved in a simple way.
And
product≢0 : All NonZero xs → NonZero (product xs)
is proved for any IntegralSemiring also in a simple way.

The notion (I) is as important and as simply expressed and as widely used in algebra as, for example, the notion of
Commutative.
In classical algebra the notion IntegralDomain means CommutativeRing with the property (I).
Also it has sense to introduce is the property

LeftZeroDivisor x =  x ≉ 0# × ∃ (\y → y ≉ 0# × x * y ≈ 0#)                      

And the property (I) itself is called "a semiring without zero divisor".
So,

  • the term IntegralDomain is occupied in algebra (as mentioned above),
  • the Agda library can intoduce IntegralSemiring
    (I do not know of whether this term is occupied)
    or
    SemiringWithoutZeroDivisor
    (which surely does not break anything in classical terminology).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions