Abstract Algebra
in F*
Alex Rozanov
Why would we need this in F*
i.e. once you have shown that your objects form a ring, you get all the ring lemmas defined in the algebra framework for free. As simple as System.Collections.Generic.List<T> in .NET is, but {|ring t|} offers way more flexibility than <T>.
Prerequisites & prelims
I. Equivalence Relations
Pretty much obvious to any good first-year.
Any equivalence relation can be used to construct sets of equivalence classes.
(a `eq` b) is the most typical goal in abstract algebra – but currently F* does not treat custom equivalence relations as anything special.
In my current implementation, equivalence relations are all t → t → bool (not prop!)
Prerequisites & prelims
II. Single Operation Algebraic Structures (S, · )
We separately define typeclasses for (*) and (+), as (+) tends to be commutative almost always.�The only exception I know of is cardinal addition, and I doubt we’ll ever need that in F* anyway.
Prerequisites & prelims
III. Ringlikes (R, · , +)
The Lean Way to do it
Now onto F*
Approach I. Records (F* demo is shown in parallel)
Downsides
Upsides
Key definitions in AlgebraTypes.fst
Typeclass-based implementation
(F* demo is shown in parallel)
Notable results so far
Good practices
Good practices
What to be aware of
What often goes wrong
What F* currently lacks
Points of interest
My own motivation and roadmap
Links