In this article we explain how typing rules and type soundness work in the Core and Fun languages, and why these concepts are key to designing reliable and safe languages.
Basic concepts and purpose: Core is a minimalist language that exposes fundamental notions of typing, evaluation, and control, while Fun is a layer with high-level constructs designed for practical functional programming. Both share common goals: ensuring that well-typed programs do not fail at runtime and being able to reason formally about their behavior.
Producers and consumers: In type analysis it is useful to distinguish between producers, which generate data or codata, and consumers, which consume or observe that data. This separation helps define typing rules that preserve invariants when components interact, ensuring that a consumer always receives the type of data it expects.
Codata and recursive definitions: Codata models potentially infinite structures such as streams, and requires typing and evaluation rules that handle observation and decomposition rather than strict construction. Recursive definitions, whether over data or codata, require care to guarantee termination or productivity; in Core, static focus restrictions are used, and in Fun, translation strategies that preserve type properties can be used.
Terminal statements as values: In Core, the notion of value is generalized to terminal statements that represent irreducible intermediate states during evaluation. Correctly identifying these terminal statements is essential for formulating and proving progress and preservation theorems that constitute type soundness.
Progress theorem: A well-typed program in Core or Fun can always take an evaluation step or is already in a terminal statement. This theorem guarantees the absence of unexpected stuck states and is the first piece in demonstrating that typing protects against certain runtime errors.
Preservation theorem: If a well-typed program takes an evaluation step, the result remains well-typed with the same type. Preservation ensures that the type structure is maintained throughout execution and that static invariants carry over to runtime.
In Core these properties are proven with static focus: the system distinguishes evaluation phases and applies rules that maintain local invariants until reaching terminal statements. This strategy facilitates reasoning about codata and evaluation flow control in the presence of recursion and observation.
In Fun, the type soundness proof is often approached by translation: a safe transformation is defined from Fun programs to Core terms that already have guaranteed type soundness. If the translation preserves types and observable behavior, Fun inherits Core's safety properties, which simplifies the proof for high-level languages.
Implications for language designers: Choosing between a direct approach with static focus or a translation-based approach depends on design priorities. Static focus offers fine-grained control and modular reasoning in Core, while translation allows implementing rich features in Fun supported by an already established base semantics.
Practical application: These principles are not purely theoretical. In custom software development, understanding typing and type soundness reduces errors, improves maintainability, and enables safe optimizations. For companies developing critical software or systems with AI agents and continuous data flows, applying well-defined typing rules and formal proofs is a competitive advantage.
About Q2BSTUDIO: Q2BSTUDIO is a software development company specialized in custom applications and custom software, with experience in artificial intelligence, AI for businesses, AI agents, cybersecurity, and AWS and Azure cloud services. We offer business intelligence services and solutions with Power BI to turn data into actionable decisions. Our approach combines good engineering practices, typing models and verification when appropriate, and secure architectures to deploy robust and scalable solutions.
Featured services: custom application development, custom software, artificial intelligence and AI agent integration, cybersecurity auditing and improvement, migrations and deployments on AWS and Azure cloud services, and business intelligence service projects using Power BI and other analytical tools.
Conclusion: Understanding typing rules and type soundness in Core and Fun provides a theoretical and practical foundation for building safe languages and systems. Both static focus and translation are valid strategies for demonstrating safety, and their application in custom software development by teams like Q2BSTUDIO provides reliable solutions for companies that need secure artificial intelligence, cybersecurity, and cloud platforms.





