Skip to content

Metatheory: use Fin instead of nested Maybe for representing variables#7486

Merged
basetunnel merged 3 commits intomasterfrom
basetunnel/metatheory-maybe-to-fin
Jan 30, 2026
Merged

Metatheory: use Fin instead of nested Maybe for representing variables#7486
basetunnel merged 3 commits intomasterfrom
basetunnel/metatheory-maybe-to-fin

Conversation

@basetunnel
Copy link
Collaborator

This changes the representation of variables in Untyped syntax to Fin n (see Untyped.lagda.md). The current AST type is parametrised by X : Set for variables, meant to be instantiated to Maybe (Maybe (... ⊥)), i.e. something isomorphic to Fin n. This underconstrained definition led to several work-arounds when @ramsay-t was working on the certifier.

The original motivation for using Maybe was to accomodate for an early version of agda2hs, but the metatheory is actually compiled using the MAlonzo backend nowadays.

Resulting simplifications:

  • No more need to parametrise definitions by DecEq instances to compare variables in decision procedures (see e.g. UntypedTranslation.lagda.md)
  • Many uses of Set₁ can now simply be Set
  • Terms are now indexed by a natural number to represent the amount of variables that are in scope, e.g. 2 ⊢ instead of (Maybe (Maybe ⊥)) ⊢
  • {-# OPTIONS --injective-type-constructors #-} is not needed anymore

Copy link
Contributor

@ana-pantilie ana-pantilie left a comment

Choose a reason for hiding this comment

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

Nice! I think you need to somehow restart CI since it timed-out. If CI is green, I think we can merge it.

@basetunnel basetunnel added the No Changelog Required Add this to skip the Changelog Check label Dec 19, 2025
@basetunnel basetunnel force-pushed the basetunnel/metatheory-maybe-to-fin branch from 5dc2c4a to a05c174 Compare January 30, 2026 09:48
@basetunnel basetunnel merged commit 55553bf into master Jan 30, 2026
5 checks passed
@basetunnel basetunnel deleted the basetunnel/metatheory-maybe-to-fin branch January 30, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No Changelog Required Add this to skip the Changelog Check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants