Skip to content

Add casing on builtins to the metatheory - #7895

Merged
ana-pantilie merged 2 commits into
masterfrom
ana/metatheory-casing-builtins
Aug 21, 2026
Merged

Add casing on builtins to the metatheory#7895
ana-pantilie merged 2 commits into
masterfrom
ana/metatheory-casing-builtins

Conversation

@ana-pantilie

@ana-pantilie ana-pantilie commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Fixes https://github.com/IntersectMBO/plutus-private/issues/2331, since the only thing that needs to be done for BuiltinBool is to support casing on it.

@ana-pantilie
ana-pantilie marked this pull request as ready for review August 18, 2026 12:59
@ana-pantilie
ana-pantilie requested review from basetunnel and kwxm and removed request for kwxm August 18, 2026 13:01

@kwxm kwxm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good: I was expecting it to be a lot more complicated.

Comment thread plutus-conformance/agda/Spec.hs Outdated
runUplcEvalTests
(agdaEvalUplcProg WithCosting)
(flip elem failingEvaluationTests)
(const False) -- no evaluation tests are expected to fail

@kwxm kwxm Aug 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd suggest leaving it as it is here but having failingEvaluationTests = []. If we later add more conformance tests that the Agda code can't handle that would make it easier to turn them off until we update the Agda.

@ana-pantilie
ana-pantilie force-pushed the ana/metatheory-casing-builtins branch from 5027289 to 3c2ff74 Compare August 21, 2026 09:49
@ana-pantilie
ana-pantilie enabled auto-merge (squash) August 21, 2026 09:50
@ana-pantilie
ana-pantilie merged commit 80fb0d9 into master Aug 21, 2026
8 checks passed
@ana-pantilie
ana-pantilie deleted the ana/metatheory-casing-builtins branch August 21, 2026 11:48
caseCon s ρ bool true (_ ∷ t ∷ []) = s ; ρ ▻ t
caseCon s ρ integer (ℤ.pos n) ts = maybe (s ; ρ ▻_) ◆ (lookup? n ts)
caseCon s ρ (list ty) (x ∷ xs) (t ∷ []) = pushValueFrames s ((ε , V-con ty x) , V-con (list ty) xs) ; ρ ▻ t
caseCon s ρ (list ty) (x ∷ xs) (t ∷ _ ∷ []) = pushValueFrames s ((ε , V-con ty x) , V-con (list ty) xs) ; ρ ▻ t

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might be more readable to not use pushValueFrames in these cases, since we can construct the new stack directly:

caseCon s ρ (list ty) (x ∷ xs) (t ∷ []) =
  ((s , -·v (V-con (list ty) xs)) , -·v (V-con ty x)) ; ρ ▻ t

I find pushValueFrames particularly confusing because it reverses its second stack, e.g.

pushValueFrames ((ε , a) , b) ((ε , c) , d) = (((((ε , a) , b) , -·v d) , -·v c)

so the direct style makes it obvious what the order in the new stack is.

(it would be useful to have an infixl for , to avoid all those parentheses).

@basetunnel

Copy link
Copy Markdown
Contributor

Nice how this change was only a few lines!

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