By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
World of SoftwareWorld of SoftwareWorld of Software
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Search
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
Reading: Why Judgmental Equality Fails Under Defunctionalization | HackerNoon
Share
Sign In
Notification Show More
Font ResizerAa
World of SoftwareWorld of Software
Font ResizerAa
  • Software
  • Mobile
  • Computing
  • Gadget
  • Gaming
  • Videos
Search
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Have an existing account? Sign In
Follow US
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
World of Software > Computing > Why Judgmental Equality Fails Under Defunctionalization | HackerNoon
Computing

Why Judgmental Equality Fails Under Defunctionalization | HackerNoon

News Room
Last updated: 2026/03/04 at 1:59 PM
News Room Published 4 March 2026
Share
Why Judgmental Equality Fails Under Defunctionalization | HackerNoon
SHARE

Table Of Links

ABSTRACT

1 INTRODUCTION

2 DEPENDENTLY-TYPED OBJECT-ORIENTED PROGRAMMING

3 CASE STUDY

4 DESIGN CONSTRAINTS AND SOLUTIONS

5 FORMALIZATION

6 DE/REFUNCTIONALIZATION

7 FUTURE WORK

8 RELATED WORK

9 CONCLUSION AND REFERENCES

DESIGN CONSTRAINTS AND SOLUTIONS

Specifying a consistent set of typing and computation rules for data and codata types is not difficult. In this section, we show the difficulties that arise if we also want the rules to be closed under defunctionalization and refunctionalization. That is every program that typechecks should continue to typecheck if we defunctionalize or refunctionalize any of the types that occur in it.

4.1 Judgmental Equality of Comatches

Problem. For most dependently typed languages, the term 𝜆𝑥.𝑥 is judgmentally equal to the term 𝜆𝑦.𝑦, and likewise 𝜆𝑥.2 + 2 and 𝜆𝑥.4 are considered equal. Equating such terms becomes a problem, however, if we want to defunctionalize the programs which contain them. Different lambda abstractions in a program are defunctionalized to different constructors, which are then no longer judgmentally equal. Let us illustrate the problem with an example.

Consider the following proof that 𝜆𝑦.𝑦 is the same function from natural numbers to natural numbers as 𝜆𝑧.𝑧. We prove this fact using a third lambda abstraction 𝜆𝑥.𝑥 as an argument to the reflexivity constructor.

codata Fun(a b: Type) { Fun(a, b).ap(a b: Type, x: a): b } Refl(Fun(Nat, Nat), x. x) : Eq(Fun(Nat, Nat), y. y, z. z)

If we defunctionalize this program, then each of these three lambda abstractions becomes one constructor of the data type. However since different constructors are not judgmentally equal, the following defunctionalized program no longer typechecks.

data Fun(a b: Type) { F1: Fun(Nat, Nat), F2: Fun(Nat, Nat), F3: Fun(Nat, Nat) } def Fun(a, b).ap(a b: Type, x: a): b { F1 => x, F2 => x, F3 => x } Refl(Fun(Nat, Nat), F1) : Eq(Fun(Nat, Nat), F2, F3)

Here is the gist of the problem: Judgmental equality must be preserved by defunctionalization and refunctionalization. This means that if we don’t want to treat different constructors of a data type as judgmentally equal, then we cannot treat all 𝛼-𝛽-equivalent comatches as judgmentally equal either.

It is not impossible to devise a scheme which lifts judgmentally equal comatches to the same constructors. However, we decided against this as it leads to confusing behavior. First, de- and refunctionalization would no longer be inverse transformations at least under syntactic equality. Second, such an attempt would necessarily be a conservative approximation as program equivalence is undecidable in general. In practice, that would mean that some comatches would be collapsed to the same constructor during lifting, while others would not.

Solution. Note that the opposite approach—never equating any comatches—doesn’t work either, since typing would then no longer be closed under substitution. For example, if 𝑓 is a variable standing for a function from natural numbers to natural numbers, then the term Refl(Fun(Nat, Nat), 𝑓 ) is a proof of the proposition Eq(Fun(Nat, Nat), 𝑓 , 𝑓 ). But we could not substitute a comatch 𝜆𝑦.𝑦 for 𝑓 , since the result would no longer typecheck. We therefore have to find a solution between these two extremes.

Our solution consists of always considering local comatches together with a name5 . Only comatches which have the same name are judgmentally equal, and this equality is preserved by reduction since the comatch is duplicated together with its name. Where do the names for local comatches come from? We support user-annotated labels, which allow the programmer to give meaningful names to comatches. Manually naming comatches in this way is useful as these labels can also be used by defunctionalization to name the generated constructors.

We enforce that these user-annotated labels are globally unique. However, as we do not want to burden the user with naming every single comatch in the program, we also allow unannotated comatches, for which we automatically generate unique names. As a result, each comatch occurring textually in the program has a unique name, but these names possibly become duplicated during normalization and typechecking.

4.2 Eta Equality

Problem. For reasons very similar to the previous section, 𝜂-equality is not preserved under defunctionalization and refunctionalization. Let us again consider a simple example. In the following proof, we show that a function 𝑓 is equal to its 𝜂-expanded form 𝜆𝑥.𝑓 .ap(𝑥). In order to typecheck, the proof would need to use a judgmental 𝜂-equality for functions.

codata Fun { ap(x: Nat): Nat } let prop_eta(f: Fun): Eq(Fun, f, (x. f.ap(x))) ⅟= Refl(Fun, f);

However, defunctionalization of this proof would result in the following program, where we have used an ellipsis to mark all the constructors that were generated for the other lambda abstractions in the program.

data Fun { Eta(f: Fun), … } def Fun.ap(x: Nat): Nat { Eta(f) => f.ap(x),… } let prop_eta(f: Fun): Eq(Fun, f, Eta(f)) ⅟= Refl(Fun, f);

Using prop_eta it would now be possible to show that any constructor f of Fun is equal to Eta(f). This would contradict the provable proposition that distinct constructors are not equal.

Solution. We do not support 𝜂-equality in our formalization and implementation. This means that we only normalize 𝛽-redexes but not 𝜂-redexes during typechecking. However, it would be possible to support judgmental 𝜂-equality on a case-by-case basis similar to the eta-equality and no-eta-equality keywords in Agda which enable or disable eta-equality for a specific record type6 . De- and refunctionalization is then only available for types without 𝜂-equality.

:::info
Authors:

  1. David Binder
  2. Ingo Skupin
  3. Tim Süberkrüb
  4. Klaus Ostermann

:::

:::info
This paper is available on arxiv under CC 4.0 license.

:::

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter Email Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article As the U.S. wages war with Iran, social media users face worsening disinformation As the U.S. wages war with Iran, social media users face worsening disinformation
Next Article MacBook Neo Pre-Orders at Best Buy Include Free  Gift Card MacBook Neo Pre-Orders at Best Buy Include Free $25 Gift Card
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow

Latest News

When Meta replaces its moderators with… the AI ​​they trained
When Meta replaces its moderators with… the AI ​​they trained
Computing
Germany is looking for AI experts: 9,000 vacancies in the IT sector alone
Germany is looking for AI experts: 9,000 vacancies in the IT sector alone
Gadget
DSAG criticizes SAP’s new API policy
DSAG criticizes SAP’s new API policy
News
Top 10: The best mini Bluetooth speaker in the test – Marshall, Teufel & JBL
Top 10: The best mini Bluetooth speaker in the test – Marshall, Teufel & JBL
Software

You Might also Like

When Meta replaces its moderators with… the AI ​​they trained
Computing

When Meta replaces its moderators with… the AI ​​they trained

3 Min Read
the electric city car at 25,000 euros is official
Computing

the electric city car at 25,000 euros is official

5 Min Read
the new smartphone reference is already being prepared!
Computing

the new smartphone reference is already being prepared!

4 Min Read
Microsoft enriches its PowerToys with tools inspired by Linux
Computing

Microsoft enriches its PowerToys with tools inspired by Linux

4 Min Read
//

World of Software is your one-stop website for the latest tech news and updates, follow us now to get the news that matters to you.

Quick Link

  • Privacy Policy
  • Terms of use
  • Advertise
  • Contact

Topics

  • Computing
  • Software
  • Press Release
  • Trending

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

World of SoftwareWorld of Software
Follow US
Copyright © All Rights Reserved. World of Software.
Welcome Back!

Sign in to your account

Lost your password?