arXiv:2609.07345cs.LOSep 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2609.07345

Monadic Second-Order Logic in HOL: Deep and Shallow with Automated Faithfulness (Extended Preprint)

Christoph Benzmueller, Daniel Kirchner

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Christoph Benzmüller¹,² [0000-0002-3392-3093]★ and Daniel Kirchner¹ [0000-0001-9229-1148]

¹ University of Bamberg, Bamberg, Germany christoph.benzmueller@uni-bamberg.de, daniel.kirchner@uni-bamberg.de ² Freie Universität Berlin, Berlin, Germany

Abstract. In Isabelle/HOL, we apply the deep-and-shallow embedding methodology of our prior work to monadic second-order logic (MSO). Three embeddings are developed side by side: a deep embedding (an inductive datatype with an explicit satisfaction relation); a maximal-shallow embedding that translates the connectives and quantifiers directly into HOL, carrying the interpretation and both assignments as explicit arguments; and a minimal-shallow embedding — a locale that fixes those parameters, collapsing the formula type to bool. The enabling new ingredient is a two-sorted substitution apparatus — capture-avoiding substitution, renaming, and a substitution lemma per namespace — in which each binder is transparent for the other; faithfulness of all three embeddings is mechanised and automated. Our central contribution is a fully mechanised two-sorted downward Löwenheim-Skolem theorem: the minimal embedding recovers deep validity relative to the (countable) assignment ranges, and this range-relative reading is shown to coincide with the general (Henkin-style) reading of MSO, whereas the standard reading is provably stronger, witnessed by comprehension. Both readings are nonetheless recovered from the minimal embedding, differing only in the admitted interpretations: all of them for the general reading, only the elementary substructures of the full model for the standard. We further exercise the embeddings on classical MSO landmarks: the Boolean-closure and graph schemata hold under the full second-order domain yet fail in the minimal embedding, making the dichotomy concrete, while reachability and 2-colorability are refuted throughout.

Keywords: Monadic second-order logic · Deep and shallow embedding · Isabelle/HOL · Henkin semantics · Automated faithfulness

1 Motivation and Introduction

Monadic second-order logic (MSO) sits at the heart of a body of results connecting logic, automata, and graph/tree structure theory [14,22,16]. It extends

  • Dedicated to David Basin, whom I first met in Saarbrücken in the mid-1990s, over a shared enthusiasm for automated reasoning, formal methods, and expressive logics.

C. Benzmüller & D. Kirchner

first-order relational logic with a single, but powerful, additional resource: quantification over monadic predicates, i.e. over sets of individuals.

On the algorithmic side, a substantial line of work led by David Basin approaches MSO through automata and decision procedures: Basin and Klarlund use the weak monadic second-order theory of one successor (WS1S) and canonical string automata to specify and verify hardware, obtaining a decision procedure with counter-model generation [4,3], and Ayari and Basin develop bounded model construction for monadic second-order logics [1]. That line targets decidable fragments over strings and trees; the present work is complementary — it embeds full and general (Henkin-style) MSO into classical higher-order logic for interactive proof and metatheory, rather than deciding a fixed fragment.

Embeddings in classical higher-order logic (HOL) [15] are a versatile host for non-classical and expressive logics: treating HOL as a universal meta-logic, a wide range of object logics — modal, deontic, epistemic, and others — inherit its semantic infrastructure and proof automation. This is the basis of LogiKEy [8,9], a logic-pluralistic knowledge representation methodology in HOL, from computational metaphysics to ethical and legal reasoning; it grew out of the early modal-logic embeddings developed together with Paulson [10,11].

Shallow embeddings, which represent object-level formulae directly as HOL terms (for MSO, by the standard translation of connectives and quantifiers), give immediate access to Isabelle/HOL's proof automation — the prover sledgehammer, the finite-countermodel finder nitpick, and auto. Deep embeddings, in which formulae are elements of an inductively defined datatype, are needed for metalogical reasoning about syntax, substitution, or proof systems.

Shallow semantical embeddings of propositional and quantified modal logics in HOL were developed by Benzmüller and Paulson [10,11], initially without a deep embedding or a mechanised faithfulness proof. We have recently shown [12] that both embeddings can be carried out simultaneously, in a single HOL theory, with mutual faithfulness proofs automated. That development, however, only treats propositional modal logic, whose binders are modal operators carrying no variable binding. The same methodology now spans a range of logics; we develop it here for monadic second-order logic (MSO). We take up MSO not for expressive strength but for the phenomena of its second-order quantifier — above all the standard-versus-general (Henkin) distinction behind our central result — and, on the technical side, for its two-sorted binding: quantifying over individuals and sets of individuals at once, MSO's first- and second-order existentials are the two binders our apparatus must handle.

Contributions. We contribute MSOinHOL, an Isabelle/HOL development of MSO with binary relational atoms, monadic predication atoms, the propositional connectives, a first-order existential quantifier, and a monadic second-order existential quantifier. The particular contributions include:

  1. A deep embedding (datatype F\mathcal{F}) and two shallow ones: a maximal embedding carrying explicit dependencies on the interpretation, the two domains, and the two assignments; and a minimal embedding that fixes the interpretation and assignments as locale parameters, collapsing the formula type to bool.

  2. The minimal embedding is an Isabelle/HOL locale MinS; it admits a faithfulness theorem FaithfulMS_all stating that quantifying over all locale interpretations recovers exactly deep validity relative to the assignment ranges. Faithfulness of the maximal-shallow embedding with respect to the deep one (FaithfulSD) is likewise established and automated.

  3. A two-sorted substitution apparatus for the deep embedding — free/bound/fresh predicates, capture-avoiding substitution, alphabetic renaming, the substitution lemma, and size-based induction — developed once per variable namespace, with each binder transparent for the other.

  4. Experiments confirming tautologies, the monadic comprehension schema (proved for an arbitrary formula, generalising two ad-hoc instances), and nitpick countermodels for invalid schemata.

  5. A suite of classical MSO landmarks — Boolean closure [14,22], monadic graph operations [16], reachability [4], and 2-colorability [22] — replicated across all three embeddings; the closure and graph schemata hold under the full second-order domain but fail in the general minimal embedding (and are recovered by its elementary refinement), while reachability and 2-colorability are non-theorems refuted throughout, turning the standard-vs-general dichotomy into a table of validity proofs, nitpick-found countermodels, and entailed cases.

  6. The converse: range-relative validity coincides with general (Henkin-style) MSO validity, by a two-sorted Löwenheim–Skolem construction, while the standard reading is provably stronger — all formally proved.

Organisation. §2 fixes notation for HOL and §3 recalls MSO. §4 presents the three embeddings – deep, maximal-shallow, and the locale-based minimal-shallow (§4.4). §5 outlines the two-sorted substitution machinery, §6 the faithfulness theorems, and §7 the surjectivity problem. §8 reports experiments and §9 concludes with related work. The complete formal development is published as the Archive of Formal Proofs entry MSOinHOL [6]. Rendered theory sources appear in App. B and the full two-sorted Löwenheim–Skolem proof in App. A.