---
title: Logically Constrained Simply-Typed TRS
url: https://www.emergentmind.com/topics/logically-constrained-simply-typed-term-rewriting-systems-lcstrss
type: topic
---

# Logically Constrained Simply-Typed TRS

Logically Constrained Simply-typed Term Rewriting Systems (LCSTRSs) are a class of higher-order rewriting systems distinguished by the integration of simply-typed λ-calculus structures and first-order logical constraints rooted in background theories such as integer arithmetic or Boolean algebras. Their development enables formal reasoning about both functional and imperative programs, especially where built-in data types and constraints on execution paths are crucial. In LCSTRSs, termination, program equivalence, and reachability analysis benefit from advanced techniques such as constrained dependency pairs, higher-order path orderings, and bounded induction schemes.

## 1. Formal Structure of LCSTRSs

LCSTRSs are formulated over a simply-typed signature. The foundational ingredients are:

- **Sorts and Types:** A non-empty set $S$ of base sorts, with a subset $\mathcal{S} \subseteq S$ designated as "theory sorts" (e.g., int, bool). Simple types are generated inductively as $T ::= A \in S \mid (T_1 \to T_2)$, using right-associative arrows [2406.19379].
- **Signature:** Function symbols $F$, with a subset $\mathcal{F} \subset F$ of theory symbols. Each symbol $f \in F$ is assigned a unique simple type, and variables $V$ are infinitely many and similarly typed [1902.08421].
- **Terms:** Pre-terms are constructed from function symbols, variables, and application. Well-typed pre-terms form the set $F(V)$; ground terms are variable-free.
- **Constraints and Theory:** Logical constraints are closed theory terms of type bool, interpreted in a background domain $(X_A)$ for each theory sort $A$ via interpretation $\llbracket\cdot\rrbracket$. Subsets of "value" symbols carry result sort $A \in \mathcal{S}$ and represent interpreted constants.
- **Rewrite Rules:** Each rule $\ell \to r [\varphi]$ satisfies: $\ell, r$ have equal simple type; $\ell$ is a pattern with $f \in F \setminus \mathcal{F}$ at the head; $\varphi$ is a constraint, with all variables having theory sorts; variables in $r \setminus (\ell \cup \varphi)$ have theory sorts; a substitution $\sigma$ "respects" the rule if $\sigma(\varphi) = 1$ under $\llbracket\cdot\rrbracket$ and theory-sorted variables map to ground values [2307.13519].

The **rewrite relation** $\to_R$ consists of 
1. context reductions $\ell\sigma \to r\sigma$ under respecting substitutions,
2. theory calculations $f(v_1,\ldots,v_n)\to v'$ if $f\in\mathcal{F}$ and $v'$ is the unique theory value computed by the background interpretation.

Termination is defined as the well-foundedness of $\to_R$ on well-typed terms [2406.19379, 1601.03206].

## 2. Static Dependency Pair Framework for LCSTRSs

The dependency pair (DP) method is a central technique for termination analysis:

- **Marked Symbols:** For each defined symbol $f \in D$ (those that occur at the head of some left-hand side), introduce a marked symbol $f^\sharp$ (input-types as $f$, result sort $\mathrm{dp}$, a new sort).
- **Static Dependency Pairs (SDPs):** An SDP is a quadruple $s^\sharp \to t^\sharp [\varphi] \ L$, where both sides are $\mathrm{dp}$-typed, $\varphi$ is a constraint, $L$ contains all theory-sorted variables in $\varphi$ [2406.19379].
- **Extraction:** For each rule $f(s_1,\ldots,s_m)\to r[\varphi]$, extract pairs $f^\sharp(x_1,\ldots,x_m) \to g^\sharp(t_1,\ldots,t_n) [\varphi]$ for each full application $g(t_1,\ldots,t_n)$ within $r$, $g \in D$.
- **Chains and Termination:** 
    - A $(P, R)$–chain is a sequence $((s_i^\sharp \to t_i^\sharp[\varphi_i], L_i, \sigma_i))_{i\ge0}$ with each $\sigma_i$ respecting the SDP and $t_i^\sharp\sigma_i \to_R^* s_{i+1}^\sharp\sigma_{i+1}$.
    - Only *computable* chains are considered: all intermediate terms and accessible subterms are reducibility-candidate computable (Tait–Girard).
    - **Theorem:** An AFP LCSTRS $R$ is terminating if and only if it admits no infinite computable $(SDP(R), R)$–chain [2406.19379, 1601.03206].

This generalizes and refines classical first-order DP theory to the higher-order and constrained domain, supporting automated termination proofs for expressive program models.

## 3. Constrained Orderings: Higher-Order RPO and Reduction Pairs

Orderings suitable for LCSTRSs must combine semantic support for theory-sorted values with higher-order and constraint-aware structure.

- **Weakly-Monotonic HORPO-Variant** [2406.18493]:
    - **Ingredients:** Precedence on symbols, argument filter, and a well-founded order $>_\iota$ on ground theory values for each base sort $\iota$.
    - **Relations:** Constrained pairs $(\succeq_\varphi^L, \succ_\varphi^L)$ defined recursively.
    - Weak monotonicity is enforced: only $\succeq$ needs to be context-monotonic, not $\succ$.
    - **Theory Clauses:** Constraints $\varphi$ are woven into the ordering (e.g., if $s, t$ are theory-terms, $Var(s) \cup Var(t) \subseteq L$, and $\varphi \vdash s \geq_\iota t$, then $s \succeq_\varphi^L t$).
- **HORPO for LCSTRSs** [2307.13519]:
    - Handles partial application, simply-typed terms, and theory constraints.
    - Strict and weak orders $\succ_\varphi, \succeq_\varphi$ are defined, parameterized by logical constraints, ensuring well-foundedness and orientation of all rules.

These structures are necessary for soundness of the DP method under constraints and for orienting rules with built-in values and logical conditions.

## 4. Open-World Computability and Modular Termination

A foundational advance in LCSTRSs is the notion of *universal* and *public* computability, which generalize termination guarantees to modular and open-world contexts [2406.19379]:

- **Definitions:**
    - An *extension* $R_1$ of $R_0$ adds new rules without redefining symbols from $R_0$, using a compatible theory-symbol interpretation.
    - A *public extension* $R_1$ is further forbidden from mentioning “hidden” symbols from $R_0$.
    - A term $t \in R_0$ is *universally computable* if for every extension $R_1$, $t$ is computable in $R_0 \cup R_1$.
    - *Public computability* restricts the quantification to public extensions.
- **SDP Characterization:**
    - $R_0$ is (publicly) computable if and only if, for each public extension $R_1$, there is no infinite *public* computable $(SDP(R_0), R_0 \cup R_1)$–chain starting from a non-hidden symbol.
    - SDP processors that only inspect the SDP set (e.g., graph/SCC, subterm, integer-mapping, theory-argument processors) are directly applicable in this setting.

This framework enables the analysis of libraries or program fragments under arbitrary client linking, yielding robust guarantees analogous to open-world termination in software systems.

## 5. Applications in Program Reasoning and Verification

LCSTRSs and their methodologies have significant applications in software analysis:

- **Verification of Imperative Programs:**
    - Transformation of imperative code with global variables and function calls into an LCSTRS involves representing execution environments, global state, and call stacks as term constructors, with side-conditions encoding program invariants and guards [1902.08421].
    - Correctness is ensured via simulation theorems demonstrating that rewriting sequences correspond exactly to operational steps in the program, including both big-step and small-step semantics.
- **Coinductive Reachability Analysis:**
    - LCSTRSs provide a natural substrate for the coinductive proof system for constrained reachability, combining symbolic execution, guarded circularity, and sound/complete proof schemas for complex properties such as "every execution from $P$ eventually reaches $Q$ or diverges" [1804.08308].
- **Inductive Equivalence Proofs:**
    - Bounded rewriting induction leverages LCSTRSs as the language of induction, reducing termination obligations compared to classical rewriting induction [2601.02803]. Only local, instance-based well-foundedness is required when applying induction hypotheses, enabling automatic proofs even when global termination is unavailable.

## 6. Limitations, Open Problems, and Tooling

Current methodologies for LCSTRSs face several formal and practical restrictions:

- **Orderings:** Reduction pairs are, at present, restricted to a weakly-monotonic HORPO variant [2406.18493]. More general algebraic or polynomial interpretations are not yet directly available for LCSTRSs, limiting the flexibility and power of automated termination analysis [2406.19379].
- **Strategies:** There is no direct treatment of innermost or call-by-value strategies, nor comprehensive handling of narrowing or theory-specific optimizations outside integers [2406.19379].
- **Non-termination:** Frameworks for non-termination (recurrence) remain under development. While ground confluence, counterexamples, and disproving equivalences are addressable, systematic non-termination technology is absent.
- **Implementation:** The Cora tool implements these methods and serves as a research platform for both termination and inductive theorem proving over LCSTRSs [2601.02803, 2406.19379].

## 7. Representative Example: Continuation-Passing Factorial

The factorial-in-CPS example illuminates the framework:

- **Types:** $int$, $bool$, $K = int \to int$, $fact : int \to K \to int$, $comp : K \to (int \to int) \to K$, $* : int \to int \to int$.
- **Rules:**
    - $fact(n, k) \to k(1) \ [n \leq 0]$
    - $fact(n, k) \to fact(n-1, comp\ k\ (\lambda x. x*n)) \ [n > 0]$
    - $comp(g, f)(x) \to g(f(x))$

**Extracted SDPs:**

| SDP | Constraint |
|:---|:---|
| $fact^\sharp(n,k) \to fact^\sharp(n-1, comp\ k\ (\lambda x. x*n))$ | $n > 0$ |
| $fact^\sharp(n,k) \to k^\sharp(1)$ | $n \leq 0$ |
| $comp^\sharp(g,f,x) \to g^\sharp(f(x))$ | true |

Termination is demonstrated by decomposing the graph, applying the subterm criterion and integer mappings. No infinite computable SDP chain can arise, establishing the system as terminating [2406.19379].

---

**References**:  
- [2406.19379]  
- [2507.09326]  
- [1601.03206]  
- [2406.18493]  
- [2307.13519]  
- [1902.08421]  
- [1804.08308]  
- [2601.02803]

Source: https://www.emergentmind.com/topics/logically-constrained-simply-typed-term-rewriting-systems-lcstrss