Skip to content

DepTyCheck derives fuel-consuming generators for provably (mutually) decreasing types. #305

@GlebChili

Description

@GlebChili

Consider the following project: https://github.com/GlebChili/DtcRecursive/tree/bfbe23a4216c11aac9fc6d36ad82ed3309b99aa6

We derive generator for type Literal (https://github.com/GlebChili/DtcRecursive/blob/bfbe23a4216c11aac9fc6d36ad82ed3309b99aa6/src/DtcRecursive/Types.idr#L32) given index Form (https://github.com/GlebChili/DtcRecursive/blob/bfbe23a4216c11aac9fc6d36ad82ed3309b99aa6/src/DtcRecursive/Types.idr#L12)`.

Expected behavior

The derived generator is able to produce a Literal for any Form without consuming any fuel, since Literal and LiteralVec are provably mutually decreasing as shown by hand-written generators genLiteralHW and genLiteralVecHW (https://github.com/GlebChili/DtcRecursive/blob/bfbe23a4216c11aac9fc6d36ad82ed3309b99aa6/src/DtcRecursive/Types.idr#L54-L70).

Actual behavior

DepTyCheck derivator fails to recognize strictly decreasing recursion and resulting generator extensively spend fuel, making it is almost impossible to populate type Literal f for relatively simple f on small amounts of fuel. (See project's module Main for a benchmark between derived and hand-written generator).

Pack collection used

nightly-251214

Metadata

Metadata

Assignees

No one assigned

    Labels

    derive: coreSomething in between single type generator and its constructorsissue: performanceWhen work takes too much resourcespart: derivationRelated to automated derivation of generatorsstatus: feature requestRequest for new functionality or improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions