A Complementary Approach to Incorrectness Typing
Pith reviewed 2026-05-18 06:34 UTC · model grok-4.3
The pith
Defining types over sets of normal forms allows a complement operator to act as negation in a two-sided type system for proving both correctness and incorrectness of programs.
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
Core claim
By defining types to range over sets of normal forms rather than values, the authors introduce a complement operator on types that acts as negation on typing formulas. This operator enables derivation of a wide range of refutation principles inside a single two-sided type system, including the analogue of co-implication. The resulting system is sound and complete for normal forms, and an expressive axiomatisation of the complement via subtyping is decidable.
What carries the argument
The complement operator on types, which acts as negation on typing formulas when types range over sets of normal forms rather than values.
If this is right
- Refutation principles such as the type-theoretic analogue of co-implication can be derived inside the type system.
- Erlang-like programs can be certified to go wrong using the refutation principles.
- The axiomatisation of the complement operator via subtyping is decidable.
- The type system is sound and complete for normal forms.
Where Pith is reading between the lines
- This two-sided approach might integrate into existing type checkers to detect both safe and unsafe behaviors in one pass.
- Completeness for normal forms could support exhaustive bug-finding tools for terminating functional programs.
- The normal-form focus might extend naturally to languages with similar pattern-matching constructs beyond Erlang.
Load-bearing premise
Defining types to range over sets of normal forms rather than values is sufficient to define a complement operator that acts as a negation on typing formulas and enables derivation of refutation principles.
What would settle it
A concrete program with atoms and pattern matching that goes wrong yet admits no derivation of incorrectness using the complement operator, or a subtyping judgment involving the complement operator that the axiomatisation cannot decide.
Figures
read the original abstract
We introduce a new two-sided type system for verifying the correctness and incorrectness of functional programs with atoms and pattern matching. A key idea in the work is that types should range over sets of normal forms, rather than sets of values, and this allows us to define a complement operator on types that acts as a negation on typing formulas. We show that the complement allows us to derive a wide range of refutation principles within the system, including the type-theoretic analogue of co-implication, and we use them to certify that a number of Erlang-like programs go wrong. An expressive axiomatisation of the complement operator via subtyping is shown decidable, and the type system as a whole is shown to be not only sound, but also complete for normal forms.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper introduces a two-sided type system for verifying the correctness and incorrectness of functional programs with atoms and pattern matching. A key idea is that types range over sets of normal forms rather than values, which enables definition of a complement operator on types that acts as negation on typing formulas. This allows derivation of a range of refutation principles, including a type-theoretic analogue of co-implication, which are used to certify that certain Erlang-like programs go wrong. An expressive axiomatisation of the complement operator via subtyping is shown decidable, and the overall type system is shown to be sound and complete for normal forms.
Significance. If the central claims hold, the work offers a distinctive approach to incorrectness reasoning within type systems by shifting the domain to normal forms and introducing a well-behaved complement operator. This unifies positive and negative verification in a single framework and supports derivation of refutation principles directly inside the type system. The decidability result for subtyping and the completeness property for normal forms are concrete strengths that could make the system practically relevant for static analysis of pattern-matching programs.
minor comments (2)
- The abstract would be strengthened by a single sentence clarifying the precise language fragment (e.g., the treatment of atoms and the form of pattern matching) before stating the main results.
- Consider adding a short illustrative derivation in an early section showing how the complement operator is applied to a concrete type to obtain a refutation judgment.
Simulated Author's Rebuttal
We thank the referee for their positive and constructive review, and for recommending acceptance of the paper. We are glad that the referee found the shift to types over normal forms, the complement operator, the derived refutation principles, the decidability result, and the completeness property to be strengths of the work.
Circularity Check
No significant circularity; derivation self-contained via new definitions and standard proofs
full rationale
The paper defines types as ranging over sets of normal forms (rather than values) to introduce a complement operator that acts as negation on typing judgments. Soundness, completeness for normal forms, and decidability of the subtyping axiomatisation for the complement are established through direct proofs on the type system rules for functional programs with atoms and pattern matching. No load-bearing step reduces by construction to a fitted parameter, self-citation chain, or renamed known result; the refutation principles follow from the internal definition of complement and co-implication. The system is self-contained against external benchmarks for type soundness and decidability.
Axiom & Free-Parameter Ledger
axioms (1)
- domain assumption Types range over sets of normal forms rather than values.
invented entities (1)
-
Complement operator on types
no independent evidence
Lean theorems connected to this paper
-
IndisputableMonolith/Foundation/RealityFromDistinctionreality_from_one_distinction unclear?
unclearRelation between the paper passage and the cited Recognition theorem.
types should range over sets of normal forms, rather than sets of values, and this allows us to define a complement operator on types that acts as a negation on typing formulas
-
IndisputableMonolith/Cost/FunctionalEquationwashburn_uniqueness_aczel unclear?
unclearRelation between the paper passage and the cited Recognition theorem.
An expressive axiomatisation of the complement operator via subtyping is shown decidable
What do these tags mean?
- matches
- The paper's claim is directly supported by a theorem in the formal canon.
- supports
- The theorem supports part of the paper's argument, but the paper may add assumptions or extra steps.
- extends
- The paper goes beyond the formal theorem; the theorem is a base layer rather than the whole result.
- uses
- The paper appears to rely on the theorem as machinery.
- contradicts
- The paper's claim conflicts with a theorem or certificate in the canon.
- unclear
- Pith found a possible connection, but the passage is too broad, indirect, or ambiguous to say the theorem truly supports the claim.
Reference graph
Works this paper leans on
-
[1]
Alexander Aiken, Edward L. Wimmers, and T. K. Lakshman. 1994. Soft Typing with Conditional Types. InConference Record of POPL’94: 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Portland, Oregon, USA, January 17-21, 1994. 163–173. https://doi.org/10.1145/174675.177847
-
[2]
Pedro Carrott, Sacha-Élie Ayoun, and Azalea Raad. 2025. Compositional Bug Detection for Internally Unsafe Libraries: A Logical Approach to Type Unsoundness. In39th European Conference on Object-Oriented Programming (ECOOP 2025) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 333), Jonathan Aldrich and Alexandra Silva (Eds.). Schloss Dagst...
-
[3]
2024.Programming with Union, Intersection, and Negation Types
Giuseppe Castagna. 2024.Programming with Union, Intersection, and Negation Types. Springer International Publishing, Cham, 309–378. https://doi.org/10.1007/978-3-031-34518-0_12
-
[4]
Giuseppe Castagna, Mickaël Laurent, Kim Nguy˜ên, and Matthew Lutze. 2022. On Type-Cases, Union Elimination, and Occurrence Typing.Proc. ACM Program. Lang.6, POPL, Article 13 (Jan. 2022), 31 pages. https://doi.org/10.1145/3498674
-
[5]
Giuseppe Castagna and Zhiwu Xu. 2011. Set-theoretic foundation of parametric polymorphism and subtyping. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming(Tokyo, Japan)(ICFP ’11). Association for Computing Machinery, New York, NY, USA, 94–106. https://doi.org/10.1145/2034773.2034788
-
[6]
Vikraman Choudhury and Simon J. Gay. 2025. The Duality of 𝜆-Abstraction.Proc. ACM Program. Lang.9, POPL, Article 12 (Jan. 2025), 30 pages. https://doi.org/10.1145/3704848
-
[8]
Patrick Cousot, Radhia Cousot, and Francesco Logozzo. 2011. Precondition Inference from Intermittent Assertions and Application to Contracts on Collections. InVerification, Model Checking, and Abstract Interpretation, Ranjit Jhala and David Schmidt (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 150–168. https://doi.org/10.1007/978-3-642- 18275-4_12
-
[9]
Tristan Crolard. 2001. Subtractive logic.Theoretical Computer Science254, 1 (2001), 151–185. https://doi.org/10.1016/ S0304-3975(99)00124-3
work page 2001
-
[10]
Tristan Crolard. 2004. A Formulae-as-Types Interpretation of Subtractive Logic.J. Log. Comput.14, 4 (2004), 529–570. https://doi.org/10.1093/LOGCOM/14.4.529 28 Celia Mengyue Li, Sophie Pull, and Steven Ramsay
-
[11]
Jana Dunfield and Neel Krishnaswami. 2021. Bidirectional Typing.ACM Comput. Surv.54, 5, Article 98 (May 2021), 38 pages. https://doi.org/10.1145/3450952
-
[12]
Erlang/OTP 28. 2025. Dialyzer v5.4. Last accessed: 1/7/2025
work page 2025
-
[13]
2013.Learn You Some Erlang for Great Good!No Starch Press
Fred Hébert. 2013.Learn You Some Erlang for Great Good!No Starch Press. As of 6/6/2025, the examples can be viewed directly at https://learnyousomeerlang.com/dialyzer#type-inference-and-discrepancies
work page 2013
-
[14]
Robert Jakob and Peter Thiemann. 2015. A Falsification View of Success Typing. InNASA Formal Methods, Klaus Havelund, Gerard Holzmann, and Rajeev Joshi (Eds.). Springer International Publishing, Cham, 234–247. https: //doi.org/10.1007/978-3-319-17524-9_17
-
[15]
Quang Loc Le, Azalea Raad, Jules Villard, Josh Berdine, Derek Dreyer, and Peter W. O’Hearn. 2022. Finding Real Bugs in Big Programs with Incorrectness Logic.Proc. ACM Program. Lang.6, OOPSLA1, Article 81 (apr 2022), 27 pages. https://doi.org/10.1145/3527325
-
[16]
Tobias Lindahl and Konstantinos Sagonas. 2006. Practical Type Inference Based on Success Typings. InProceedings of the 8th ACM SIGPLAN International Conference on Principles and Practice of Declarative Programming(Venice, Italy)(PPDP ’06). Association for Computing Machinery, New York, NY, USA, 167–178. https://doi.org/10.1145/1140335.1140356
-
[17]
Julian Mackay, Susan Eisenbach, James Noble, and Sophia Drossopoulou. 2022. Necessity Specifications for Robustness. Proc. ACM Program. Lang.6, OOPSLA2, Article 154 (oct 2022), 30 pages. https://doi.org/10.1145/3563317
-
[18]
Robin Milner. 1978. A theory of type polymorphism in programming.J. Comput. System Sci.17, 3 (1978), 348–375. https://doi.org/10.1016/0022-0000(78)90014-4
-
[19]
Tamás Nagy and Anikó Nagyné Víg. 2008. Erlang testing and tools survey. InProceedings of the 7th ACM SIGPLAN Workshop on ERLANG(Victoria, BC, Canada)(ERLANG ’08). Association for Computing Machinery, New York, NY, USA, 21–28. https://doi.org/10.1145/1411273.1411277
-
[20]
Peter W. O’Hearn. 2019. Incorrectness Logic.Proc. ACM Program. Lang.4, POPL, Article 10 (dec 2019), 32 pages. https://doi.org/10.1145/3371078
-
[21]
Lionel Parreaux and Chun Yin Chau. 2022. MLstruct: Principal Type Inference in a Boolean Algebra of Structural Types.Proc. ACM Program. Lang.6, OOPSLA2, Article 141 (oct 2022), 30 pages. https://doi.org/10.1145/3563304
-
[22]
David J. Pearce. 2013. Sound and Complete Flow Typing with Unions, Intersections and Negations. InVerification, Model Checking, and Abstract Interpretation, Roberto Giacobazzi, Josh Berdine, and Isabella Mastroeni (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 335–354
work page 2013
-
[23]
Luís Pinto and Tarmo Uustalu. 2009. Proof Search and Counter-Model Construction for Bi-intuitionistic Propositional Logic with Labelled Sequents. InAutomated Reasoning with Analytic Tableaux and Related Methods, Martin Giese and Arild Waaler (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 295–309
work page 2009
-
[24]
Andrew M. Pitts. 2012. Lecture Notes on Types for Part II of the Computer Science Tripos. (2012). Page 2. Available from https://www.cl.cam.ac.uk/teaching/1213/Types/typ-notes.pdf, last accessed 18/07/2025
work page 2012
-
[25]
Kelvin Qian, Scott Smith, Brandon Stride, Shiwei Weng, and Ke Wu. 2024. Semantic-Type-Guided Bug Finding.Proc. ACM Program. Lang.8, OOPSLA2, Article 348 (Oct. 2024), 28 pages. https://doi.org/10.1145/3689788
-
[26]
Azalea Raad, Josh Berdine, Derek Dreyer, and Peter W. O’Hearn. 2022. Concurrent Incorrectness Separation Logic. Proc. ACM Program. Lang.6, POPL, Article 34 (jan 2022), 29 pages. https://doi.org/10.1145/3498695
-
[27]
Steven Ramsay and Charlie Walpole. 2024. Ill-Typed Programs Don’t Evaluate.Proc. ACM Program. Lang.8, POPL, Article 67 (Jan 2024), 31 pages. https://doi.org/10.1145/3632909
- [28]
-
[29]
Konstantinos Sagonas. 2021. Fifteen years of successfully dialyzing Erlang and Elixir code (invited talk). InProceedings of the 20th ACM SIGPLAN International Workshop on Erlang(Virtual, Republic of Korea)(Erlang 2021). Association for Computing Machinery, New York, NY, USA, 1. https://doi.org/10.1145/3471871.3480952
-
[30]
Luca Tranchini. 2017. Natural deduction for bi-intuitionistic logic.Journal of Applied Logic25 (2017), S72–S96. https://doi.org/10.1016/j.jal.2017.12.001 Logical Investigations on Assertion and Denial
-
[31]
A. S. Troelstra and H. Schwichtenberg. 2000.Basic Proof Theory(2 ed.). Cambridge University Press
work page 2000
-
[32]
Hiroshi Unno, Yuki Satake, and Tachio Terauchi. 2017. Relatively Complete Refinement Type System for Verification of Higher-Order Non-Deterministic Programs.Proc. ACM Program. Lang.2, POPL, Article 12 (dec 2017), 29 pages. https://doi.org/10.1145/3158100
-
[33]
Robin Webbers, Klaus von Gleissenthall, and Ranjit Jhala. 2024. Refinement Type Refutations.Proc. ACM Program. Lang.8, OOPSLA2, Article 305 (Oct. 2024), 26 pages. https://doi.org/10.1145/3689745
-
[34]
Zhe Zhou, Ashish Mishra, Benjamin Delaware, and Suresh Jagannathan. 2023. Covering All the Bases: Type-Based Verification of Test Input Generators.Proc. ACM Program. Lang.7, PLDI, Article 157 (June 2023), 24 pages. https: //doi.org/10.1145/3591271
-
[35]
Noam Zilberstein, Derek Dreyer, and Alexandra Silva. 2023. Outcome Logic: A Unifying Foundation for Correctness and Incorrectness Reasoning.Proc. ACM Program. Lang.7, OOPSLA1, Article 93 (apr 2023), 29 pages. https: A Complementary Approach to Incorrectness Typing 29 //doi.org/10.1145/3586045 30 Celia Mengyue Li, Sophie Pull, and Steven Ramsay A Supplemen...
-
[36]
Then by the induction hypothosis we have𝜃 1 ⊑𝜃 ′ 1 and𝜃 2 ⊑𝜃 ′
-
[37]
Sincedom(𝜃) =dom(𝜃 ′) =FV(𝑝 1)∪FV(𝑝 2),𝜃⊑𝜃 ′ follows directly. □ Definition D.5 (Coherence of Term and Pattern Type Substitutions under Contexts).Let 𝜎 be a term substitution (mapping term variables to terms), 𝜃 a pattern type substitution (mapping term variables to types), andΓ,∆left and right contexts respectively. We define thecoherence relation Γ⊢𝜎::𝜃...
discussion (0)
Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.