Coeffs
as a wrapper for IntList
#
Currently omega
uses a dense representation for coefficients.
However, we can swap this out for a sparse representation.
This file sets up Coeffs
as a type synonym for IntList
,
and abbreviations for the functions in the IntList
namespace which we need to use in the
omega
algorithm.
There is an equivalent file setting up Coeffs
as a type synonym for AssocList Nat Int
,
currently in a private branch.
Not all the theorems about the algebraic operations on that representation have been proved yet.
When they are ready, we can replace the implementation in omega
simply by importing
Init.Omega.IntDict
instead of Init.Omega.IntList
.
For small problems, the sparse representation is actually slightly slower, so it is not urgent to make this replacement.
Identity, turning List Int
into Coeffs
.
Equations
- Lean.Omega.Coeffs.ofList xs = xs
Instances For
Are the coefficients all zero?
Instances For
Shim for IntList.set
.
Equations
- xs.set i y = Lean.Omega.IntList.set xs i y
Instances For
Shim for IntList.get
.
Equations
- xs.get i = Lean.Omega.IntList.get xs i
Instances For
Shim for IntList.smul
.
Equations
- xs.smul g = Lean.Omega.IntList.smul xs g
Instances For
Shim for IntList.sdiv
.
Equations
- xs.sdiv g = Lean.Omega.IntList.sdiv xs g
Instances For
Shim for IntList.dot
.
Equations
- xs.dot ys = Lean.Omega.IntList.dot xs ys
Instances For
Shim for IntList.add
.
Equations
- xs.add ys = Lean.Omega.IntList.add xs ys
Instances For
Shim for IntList.sub
.
Equations
- xs.sub ys = Lean.Omega.IntList.sub xs ys
Instances For
Shim for IntList.combo
.
Equations
- Lean.Omega.Coeffs.combo a xs b ys = Lean.Omega.IntList.combo a xs b ys
Instances For
Shim for IntList.leading
.
Equations
- xs.leading = Lean.Omega.IntList.leading xs
Instances For
Shim for List.map
.
Equations
- Lean.Omega.Coeffs.map f xs = List.map f xs
Instances For
Shim for .enum.find?
.
Equations
- Lean.Omega.Coeffs.findIdx? f xs = Option.map (fun (x : Nat × Int) => x.fst) (List.find? (fun (x : Nat × Int) => f x.snd) (List.enum xs))
Instances For
Shim for IntList.bmod
.
Equations
- x.bmod m = Lean.Omega.IntList.bmod x m