Skip to content

Add interfaces to declare generic level polymorphic n-ary functions - #73

Merged
fblanqui merged 7 commits into
Deducteam:masterfrom
NotBad4U:n-ary-fun
Sep 25, 2026
Merged

fblanqui merged 7 commits into
Deducteam:masterfrom
NotBad4U:n-ary-fun

Conversation

@NotBad4U

Copy link
Copy Markdown
Member

Implementation of N-ary functions and relations based on Guillaume Allais, "Generic Level Polymorphic N-ary Functions" (TyDe 2019).

This API provides n-ary functions that automatically reconstruct the representation of their input types through unification.

It helps to define fully level polymorphic n-ary versions of congruence, substitution and the combinators for indexed families,
that are used by programs such as SMT solvers. Lemmas provided in the rest of the library such as Eq.lp are implemented for fixed arities, and the implementation here aims to provide similar lemmas for N-ary Combinators.

This work is based on Guillaume Allais - "Generic Level Polymorphic N-ary Functions" (TyDe 2019)

@fblanqui fblanqui left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Alessio. Here are some remarks:

Comment thread NaryFunctions.lp Outdated
Comment thread NaryFunctions.lp Outdated
Comment thread NaryFunctions.lp Outdated
Comment thread NaryFunctions.lp Outdated
Comment thread NaryFunctions.lp Outdated
Comment thread NaryFunctions.lp Outdated
Comment thread NaryFunctions.lp Outdated
Comment thread NaryFunctions.lp Outdated
Comment thread NaryFunctions.lp Outdated
Comment thread NaryFunctions.lp Outdated
@fblanqui

fblanqui commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Various functions can be declared as injective: arrows, sets_ident, ArrowI.

Please add an example using the unification rules.

Comment thread NaryFunctions.lp Outdated
Comment thread NaryFunctions.lp Outdated
@fblanqui

This comment was marked as resolved.

@NotBad4U

Copy link
Copy Markdown
Member Author

I think we have a better API now.

@NotBad4U

Copy link
Copy Markdown
Member Author

I think we can merge this one

@fblanqui

Copy link
Copy Markdown
Member

Hi Alessio.

Your unification rules are unsound: (fun unit b) can be an arrow type (if b so is).
And Arrow is not injective (nor arrows) since arrows unit (a ~> a) == a ~> a == arrows (a::unit) a.
However (\b,arrows a b) and (\a,arrows a b) are both injective since arrows a b == arrows a b' => b == b' and arrows a b == arrows a' b => a == a'.

I also propose some renamings: Sets -> VSet, sets -> vset, arrows -> fun, Arrow -> Fun, cong_n -> refl_cong, subst_n -> refl_subs, compose_n -> comp.

I already fixed all this. Can I push on your branch?

@NotBad4U

NotBad4U commented Sep 23, 2026 •

Copy link
Copy Markdown
Member Author

unit (a ~> a) == a ~> a == arrows (a::unit) a

good catch

I also propose some renamings: Sets -> VSet, sets -> vset, arrows -> fun, Arrow -> Fun, cong_n -> refl_cong, subst_n -> refl_subs, compose_n -> comp.

No problem changing the name; I just followed the one in the paper when I implemented it during my PhD to make things easier.

Yes feel free to commit on top of mine

@fblanqui

Copy link
Copy Markdown
Member

It is perhaps possible for the user to only give the arity instead of the domain by defining functions on n instead of on ts.

@NotBad4U

Copy link
Copy Markdown
Member Author

It is perhaps possible for the user to only give the arity instead of the domain by defining functions on n instead of on ts.

I've thought about that too, but I haven't found a way to implement it yet.

@fblanqui

Copy link
Copy Markdown
Member

One problem to get this feature is to have Lambdapi infer that any meta ?X:VSet 0 can be instantiated by unit (◃ now).

@fblanqui
fblanqui merged commit d759a55 into Deducteam:master Sep 25, 2026
1 check passed
@fblanqui

fblanqui commented Oct 2, 2026

Copy link
Copy Markdown
Member

Remark: List.Arr n a b is the same as NaryFun.Fun n (vcst a) b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants