Skip to content

Support inductive relations where Nat literals appear in the type of constructors #41

@ngernest

Description

@ngernest

Right now, we expect any Nats that appear in the constructors of inductive relations to be expressed either as .zero or .succ (.succ ...). For example, note how in Test/DeriveArbitrarySuchThat/DeriveBalancedTreeGenerator.lean, we have to write balancedTree (.succ .zero) .Leaf instead of balancedTree 1 .Leaf:

-- `balancedTree n t` describes whether the tree `t` of height `n` is *balanced*, 
-- i.e. every path through the tree has length either `n` or `n-1`. -/
inductive balancedTree : Nat → BinaryTree → Prop where
  | B0 : balancedTree .zero BinaryTree.Leaf
  | B1 : balancedTree (.succ .zero) BinaryTree.Leaf
  | ...

It would be nice if we could allow the user to write Nat literals in the type of constructors, and somehow unfold those Nat literals to a definitionally-equal Nat expression (i.e. 2 gets unfolded to .succ (.succ .zero)) when processing the inductive relation in DeriveConstrainedProducer.lean.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions