Skip to content

Conversation

@joscoh
Copy link
Contributor

@joscoh joscoh commented Jan 13, 2026

Description of changes:

This PR extends the DDM with a .tvar construct that allows type variables to be used in function declarations. The DDM does not perform typechecking or unification for type variables; it leaves this to the dialect-specific typechecker or type inference algorithm (Lambda in this case). This PR also extends the Boogie DDM with polymorphic definitions and contains Boogie test cases, both for polymorphic functions directly and for polymorphic datatypes which implicitly define functions.

@thanhnguyen-aws

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Josh Cohen and others added 30 commits November 25, 2025 12:19
Add new attribute "inline_if_val" that inlines a function only if all its arguments
are canonical values
Improve type handling in SMTEncoder, need to recursively check
constructor arguments
Test fails for now, need toposort of datatypes
Provides generic function mechanism with datatypes
Base automatically changed from josh/concrete-ast-ddm-2 to main January 13, 2026 22:02
@joscoh joscoh marked this pull request as ready for review January 14, 2026 16:09
@[declareFn(name, b, r)]
op command_fndecl (name : Ident,
typeArgs : Option TypeArgs,
@[scopeTypeVars(typeArgs)] b : Bindings,
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this determine the identifiers that typeArgs introduces? Is every identifier subterm in typeArgs an identifier?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm kind of wondering if we should have declareTypeVars that introduces type variables and then keep the current scope construct for extending the type context. With the current design, it's unclear to me what scopeTypeVars does if typeArgs also declared variables.

| bvar (ann : α) (index : Nat)
/-- A polymorphic type variable (universally quantified).
Used for polymorphic function type parameters -/
| tvar (ann : α) (name : String)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use String for type variable names rather than deBrujin indices as in bvar? It seems like bvar could refer to either a type variable or "expression" variable.

Copy link
Contributor

@joehendrix joehendrix left a comment

Choose a reason for hiding this comment

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

This looks like a good start. I left a few comments; I'd also like to see a few DDM tests that used a simple test dialect rather than Boogie.

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.

3 participants