Cost-Based Semantics
- Cost-based semantics is a family of formalisms that attach quantitative cost metrics—such as evaluation steps, resource charges, or violation counts—to computational models and logical systems.
- This approach is applied across various domains including higher-order functional languages, concurrent calculi, probabilistic programming, and description logics, using techniques like recurrences, monadic translations, and matrix iterations.
- By abstracting cost while preserving extensional reasoning, these methods provide certified upper bounds, sound semantic foundations, and efficient complexity analyses for both theoretical and practical applications.
Searching arXiv for recent and foundational papers on cost-based semantics to ground the article. Cost-based semantics denotes a family of semantic formalisms in which execution, interaction, or model preference is equipped with an explicit quantitative notion of cost. In higher-order functional analysis, the complexity of an expression is a pair consisting of a cost and a potential; in concurrent calculi, channels are treated as resources with costs and profits; in description logics, each interpretation receives a cost determined by the weighted axioms and assertions it violates; and in probabilistic Call-By-Push-Value, denotational semantics tracks accumulated cost together with probabilistic behavior (Danner et al., 2012, Hennessy, 2010, Bienvenu et al., 2024, Amorim, 2024). The term therefore names not a single formalism but a class of semantically grounded quantitative methods whose common purpose is to make resource usage part of the semantic object itself.
1. Semantic pattern and core constructions
A recurring pattern across the literature is to enrich an otherwise standard semantics with a numerical or algebraic component that accumulates along computation or measures deviation from preferred models. In the linear-operator approach of Cachera and Jobin, one starts from an operational semantics equipped with costs; the underlying cost domain is a commutative dioid , the one-step semantics is assembled into a transition matrix , and matrix iteration yields both global cost information and long-run cost (Cachera et al., 2010). In the higher-order functional analysis of Danner, means that under evaluates in inference steps to value under , so the cost is literally the size of the big-step derivation (Danner et al., 2012).
The semantic carrier of cost varies with the setting. Some work uses the natural numbers with addition, as in the writer-monad presentation for recurrence extraction (Danner et al., 2020). Some work uses a general cost monoid and a primitive 0 that increments abstract cost by 1 (Niu et al., 2024). In probabilistic semantics, cost can be paired with distributions, yielding 2, or separated into an expected-cost semantics 3 (Amorim, 2024). In ontology-mediated querying, cost is not accumulated along a run but assigned to an interpretation by summing the penalties of the violated TBox axioms and ABox assertions (Bienvenu et al., 2024).
This variety matters conceptually. Cost-based semantics is not committed to a single notion of resource usage. The literature contains derivation-size cost, writer-style step counts, owner-budget transfers, violation counts in weighted knowledge bases, and expected cost in probabilistic computation. A plausible implication is that the unifying theme is methodological rather than ontological: cost is made compositional, semantically explicit, and suitable for sound reasoning.
2. Higher-order functional languages, cost–potential pairs, and recurrence extraction
A central line of work studies cost-based semantics for higher-order functional programs. In "A static cost analysis for a higher-order language" (Danner et al., 2012), the complexity of an expression is a pair 4. The cost of a closed term 5 is the size of the unique big-step derivation 6,
7
while the potential is a measure of the “future” cost of using the resulting value. At base types, potential is the size of the value, such as list length. At higher types 8, the potential of a function is itself a map from potentials of 9-values to full complexities for 0-results. The analysis is driven by a translation 1 from target expressions to a complexity language, and the main theorem states that if 2, then 3; hence the cost component of 4 is an upper bound on the evaluation cost of 5 (Danner et al., 2012).
The same paper makes the cost–potential discipline explicit on examples. For insertion into a sorted list, unwinding the translated 6-term yields the recurrences
7
hence 8. For higher-order map, the cost recurrence is 9, where 0 is the fixed cost of applying the argument function to a size-1 element (Danner et al., 2012). These examples exhibit the characteristic advantage of cost-based semantics in this setting: higher-order structure is retained, but cost recurrences are extracted compositionally.
Later denotational work generalizes this two-phase program. In "Denotational cost semantics for functional languages with inductive types" (Danner et al., 2015), a call-by-value source language is translated into a complexity language via the writer monad 1, after which datatype values are abstracted to programmer-specified notions of size. The extracted recurrences are then interpreted in models that may use list length, tree height, or other preorder-based size domains. A logical-relations argument proves a bounding theorem that is deliberately syntactic, so it applies uniformly to the range of models considered (Danner et al., 2015). In "Denotational semantics as a foundation for cost recurrence extraction for functional languages" (Danner et al., 2020), the same methodology is presented for a higher-order language with let-polymorphism: first a cost-annotating monadic translation, then interpretation in a model whose size maps determine the numerical recurrence. Different models formalize different notions of input size, including list length, tree-node count, and tree height (Danner et al., 2020).
The denotational tradition also develops internal adequacy theorems. In 2, the denotational semantics lives in an SDT topos with cost monad
3
while the dynamic semantics is not given by reflexive-transitive closure but by a 4-valued fixed point 5. The adequacy theorem states that for every closed 6,
7
and the phase distinction yields a noninterference property: maps from the cost monoid into purely extensional codomains are weakly constant (Niu et al., 2024). This explicitly separates extensional behavior from intensional cost.
3. Behavioral, probabilistic, and lazy variants
Cost-based semantics extends beyond pure evaluation cost to behavioral and stochastic settings. In "A calculus for costed computations" (Hennessy, 2010), picost interprets channels as resources with associated use and provide costs. Programs run under the financial responsibility of named owners, and a cost environment 8 records resource-use charges, provision charges, owner budgets, and the running net cost. Reduction steps therefore carry both action labels and weights, and the resulting weighted LTS supports amortised weighted bisimulation. The preorder 9 means that 0 can match every move of 1 at no more than 2 units of extra cost, or at least as much profit. Full abstraction is obtained via coincidence with a contextual improvement preorder, under the stated restriction to simple types 3 (Hennessy, 2010).
Probabilistic programming introduces a distinct complication: cost is random. One route is measure-theoretic. In "Expected-Cost Analysis for Probabilistic Programs and Semantics-Level Adaption of Optional Stopping Theorems" (Wang et al., 2021), configurations are quadruples of state, statement, continuation, and cost accumulator, and the one-step semantics is a probability kernel. Infinite traces are generated by Ionescu–Tulcea, the stopping time 4 marks termination, and the expected-cost semantics is
5
A semantics-level supermartingale 6 is then constructed from an expected-potential 7, and Optional Stopping yields sound expected-cost bounds under hypotheses such as almost-sure finiteness, polynomial growth, and finite moments of 8 (Wang et al., 2021).
A second route is fully denotational. In 9, a CBPV metalanguage with charge, rand, fix, and lists, the operational big-step judgment 0 records cost 1, while the denotational cost semantics interprets computations in 2. To recover compositional expected cost, the paper introduces the strong monad
3
and proves a cost-adequacy theorem equating the expected cost extracted from the cost semantics with the first component of the expected-cost semantics. The relation between the two is expressed by an effect-simulation map 4, which is a monad morphism on the sub-monad of total distributions (Amorim, 2024).
Lazy evaluation motivates yet another variant. "Story of Your Lazy Function's Life" (Xia et al., 2024) develops a bidirectional demand semantics for a lazy 5-calculus with heaps of thunks. Big-step evaluation is indexed by a demand 6, written 7, and cost counts exactly each thunk-force and each pattern-match. This semantics supports worst-case and amortized reasoning without a special separation logic, and the paper introduces the reverse physicist's method to prove global bounds from local amortization inequalities (Xia et al., 2024). The mechanized case studies include insertion sort, selection sort, Okasaki's banker's queue, and the implicit queue.
4. Cost-aware type theory and semantic metalanguages
Type theory turns cost from a meta-level annotation into a judgmental or type-theoretic object. In "Cost-Aware Type Theory" (Niu et al., 2020), the big-step relation 8 counts exact small-step transitions, and CATT refines ordinary typing with cost-indexed judgments
9
Its characteristic type former is funtime, a dependent function type whose semantics is a cost-aware version of function extensionality. The elimination rule assigns one step plus the payload bound to application, and the semantic PER for funtime requires agreement on both result and cost bound (Niu et al., 2020).
The CăLF line of work pursues a related agenda in a dependent CBPV setting. "A metalanguage for cost-aware denotational semantics" (Niu et al., 2022) introduces 0 and 1, with universes, inductive types, a primitive
2
and equations 3 and 4. The metalanguage is phase-separated: under the extensional phase, cost becomes unobservable. This allows cost-aware adequacy theorems that restrict immediately to ordinary extensional adequacy by ignoring the cost in the extensional phase (Niu et al., 2022).
Canonicity and metatheory have also been developed for this setting. "Canonicity for Cost-Aware Logical Framework via Synthetic Tait Computability" (Li et al., 16 Apr 2025) studies the cost-aware logical framework CăLF and proves that every closed 5-term is canonically of the form
6
The proof is conducted internally in an Artin-gluing topos via synthetic Tait computability, using open and closed modalities to separate syntactic and behavioral phases (Li et al., 16 Apr 2025).
This body of work makes a particular conceptual point precise. Cost need not invalidate extensional reasoning; rather, cost can be tracked in a separate semantic phase. The noninterference theorem for 7, the phase modalities of CăLF, and the PER semantics of CATT all formalize versions of this separation (Niu et al., 2024, Niu et al., 2022, Niu et al., 2020).
5. Weighted knowledge bases and description-logic semantics
In description logics, cost-based semantics serves inconsistency-tolerant querying. A weighted knowledge base is a knowledge base together with a weight function 8 or 9, depending on the presentation. For an interpretation 0, the cost is defined by summing the weighted sizes of the TBox violation sets together with the weights of the violated ABox assertions: 1 or equivalently 2 with the corresponding notation (Leisegang et al., 1 Oct 2025, Bienvenu et al., 2024).
Two orthogonal choices then generate four entailment notions. One may quantify over all or some interpretations, and one may restrict either to those with cost at most a given 3 or to those having optimal cost 4. This yields bounded-cost certain and possible answers and optimal-cost certain and possible answers (Bienvenu et al., 2024). When the underlying KB is consistent, the zero-cost interpretations are exactly the classical models, and the cost-based semantics collapses to classical answering. When all TBox axioms have infinite weight and only ABox assertions have finite weights, optimal-cost certain semantics coincides with the AR semantics based on maximal consistent ABox subsets (Bienvenu et al., 10 Nov 2025).
The framework is semantically close to non-monotonic ranking semantics. "Semantic Bridges Between First Order c-Representations and Cost-Based Semantics: An Initial Perspective" (Leisegang et al., 1 Oct 2025) shows that under suitable conditions a weighted knowledge base and a set of defeasible conditionals generate the same ordering on interpretations, with exact equations
5
for the translation from a c-representation to a weighted KB, and
6
for the converse translation under the stated assumptions. The induced semantic structures are therefore equivalent up to an additive constant, and the minimal-cost worlds are exactly the rank-0 worlds (Leisegang et al., 1 Oct 2025).
This branch of the literature uses “cost-based semantics” in a sense rather different from programming-language cost semantics. The semantic object is an interpretation rather than a run, and cost measures inconsistency or defeasibility rather than time. The shared idea is still quantitative preference: lower-cost interpretations are semantically privileged.
6. Soundness, complexity, and methodological significance
A striking commonality is the emphasis on certified upper bounds, adequacy, and full abstraction. The higher-order functional analysis of Danner formalizes the soundness theorem in Coq, thereby providing certified upper bounds on the cost of any expression (Danner et al., 2012). The denotational work on inductive types proves a logical-relations bounding theorem applying across multiple models of size abstraction (Danner et al., 2015). The SDT treatment of 7 proves internal cost-sensitive computational adequacy (Niu et al., 2024). The probabilistic CBPV semantics proves operational soundness, adequacy for the denotational cost semantics, and cost adequacy for the expected-cost semantics (Amorim, 2024). Picost proves the soundness and completeness of amortised weighted bisimulation via contextual characterization (Hennessy, 2010).
Complexity-theoretic analysis is especially developed for description logics. "Cost-Based Semantics for Querying Inconsistent Weighted Knowledge Bases" (Bienvenu et al., 2024) gives a comprehensive analysis of combined and data complexity for bounded-cost satisfiability and certain and possible answer recognition for DLs between 8 and 9. "Data Complexity of Querying Description Logic Knowledge Bases under Cost-Based Semantics" (Bienvenu et al., 10 Nov 2025) refines this picture for DL-Lite dialects with inverse roles and role inclusions: when 0 is part of the input, several semantics remain intractable, but when 1 is fixed, 2 for arbitrary conjunctive queries and 3 for instance queries are both in 4 by first-order rewriting (Bienvenu et al., 10 Nov 2025). This is noteworthy because the same semantic framework can exhibit both high complexity and lowest-possible data complexity, depending on which quantitative parameter is fixed.
A further methodological theme is that cost is often abstracted without being erased. Cost dioids support abstraction of both states and costs in linear cost models (Cachera et al., 2010). Higher-order recurrence extraction abstracts values to size domains while retaining a sound upper bound on evaluation cost (Danner et al., 2020). The JSXML-inspired abstract machine of "Cost Analysis for Import and Export Using an Abstract Machine" (Bennetzen et al., 2024) equips machine transitions with costs and proves a sound type system that over-approximates the cost of any terminating program, with fresh variables introduced for while-loop iteration counts. This suggests a broad division of labor in cost-based semantics: operational rules define how cost is accumulated, denotational or algebraic structure makes the accumulation compositional, and proof-theoretic machinery establishes soundness or adequacy.
A common misconception is that cost-based semantics always studies runtime in the narrow sense of execution time. The literature shows a wider landscape: derivation size in big-step semantics, use/provide charges and profits in process interaction, violation counts in inconsistent knowledge bases, expected accumulated tick cost in probabilistic programs, and cost-indexed equality in dependent type theory (Danner et al., 2012, Hennessy, 2010, Bienvenu et al., 2024, Niu et al., 2020). Another misconception is that adding cost necessarily destroys extensional reasoning. Several systems instead isolate cost in a separate phase or modality, so that behavior can remain extensional while cost remains semantically available (Niu et al., 2022, Niu et al., 2024).
Taken together, these developments establish cost-based semantics as a broad semantic methodology for quantitative reasoning. Its forms differ substantially across higher-order programming languages, concurrency, probabilistic computation, type theory, abstract machines, and description logics, but the persistent invariants are compositionality, formally specified cost accumulation, and the pursuit of sound or adequate links between semantic cost and the quantitative property being analyzed.