dotnet add package Sylvester.Arithmetic --version
NuGet\Install-Package Sylvester.Arithmetic -Version
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sylvester.Arithmetic" Version="" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sylvester.Arithmetic --version
#r "nuget: Sylvester.Arithmetic,"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Sylvester.Arithmetic as a Cake Addin
#addin nuget:?package=Sylvester.Arithmetic&version=

// Install Sylvester.Arithmetic as a Cake Tool
#tool nuget:?package=Sylvester.Arithmetic&version=


This library implements lightweight dependently typed natural number arithmetic and constraints which enable arithmetic operations like bounds checking to be performed at compile-time by the F# type checker as long as the values for the operations are known at compile-time.

open Sylvester.Arithmetic

///Create typed representations of some natural numbers
let a,b,c = new nat<400>(), new nat<231111>(), new nat<6577700>()

a + b + c

These values have types derived from Sylvester.Arithmetic.N10. The type of a is N10<0,0,0,0,0,0,0,4,0,0> and the type of c is N10<0,0,0,6,5,7,7,7,0,0>.


The types of the results of arithmetic operations depend on the values of the operands.

let d = (a + b + c) * four


This enables type-level constraints to be written which run at compile-time

check(d +< ten) /// Type error
Type mismatch. Expecting a
but given a
The type 'Success' does not match the type 'Failure'
a - (two * a) /// A negative number results in a type representing an underflow at compile-time 
let myop a b c d =
    check(a +> b)
    check (b +== zero)
    check (c +== (a + one))
    a + b + c + d
myop four five four ten  ///Type error. Program will not compile
Type mismatch. Expecting a
but given a
The type 'Success' does not match the type 'Failure'
Type mismatch. Expecting a
but given a
The type 'Success' does not match the type 'Failure'
let myop a b c d =
    check(a +> b)
    check (b +== zero)
    check (c +== (a + one))
    a + b + c + d
myop seven zero eight ten  ///Program compiles once the parameters to myop satisfy the arithmetic constraints
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Sylvester.Arithmetic:

Package Downloads

High-level functional and verifiable TensorFlow 2.0 API.


Sylvester number-parameterized collection types. These collection types can perform static verification of lengths and indices as long as some information about these values is available at compile time.


Linear algebra types with type-level numeric dimensions

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated 504 5/11/2021
0.2.8 292 5/11/2021
0.2.7 416 3/8/2021 379 3/7/2021
0.2.6 367 3/7/2021 474 2/6/2020
0.2.5 482 2/6/2020
0.2.4 1,690 1/16/2020
0.2.3 444 1/16/2020 1,885 1/3/2020
0.2.2 443 1/3/2020
0.2.1 584 12/30/2019
0.2.0 468 12/30/2019
0.1.7 521 6/23/2019
0.1.6 626 6/22/2019 764 6/21/2019
0.1.3 506 6/12/2019 508 6/10/2019 545 6/10/2019

Move types and functions to module instead of namespace and remove unneeded code. Add max and min functions.