A formal model for ledger management systems based on contracts and temporal logic

arXiv:2109.15212 · cs.CR, cs.CL, cs.LO · Submitted 2021-09-30 · Read on arXiv

Listen

Radio episode about this paper

Transcript

Introduction to the show: ident: AI Radio. Generated commentary on the latest Artificial Intelligence papers.

Tom: Next we'll be talking about the paper "A formal model for ledger management systems based on contracts and temporal logic".

Jane: The paper was written by Paolo Bottoni, Anna Labella and Remo Pareschi from Sapienza University of Rome and University of Molise.

Tom: Stay tuned as we take you through the paper and discuss its implications.

Title and Authors: Tom: Welcome back, everyone! We're looking at "A formal model for ledger management systems based on contracts and temporal logic" — and Jane, I have to say, that title is a mouthful, but it's from a really interesting crew at Sapienza University of Rome and the University of Molise.

Jane: It really is, Tom. And honestly, the title tells you exactly what they're trying to do — they want to take ledgers, you know, the databases behind blockchain, and give them a proper formal foundation. The authors are Paolo Bottoni, Anna Labella, and Remo Pareschi, and they're coming at this from computer science and distributed systems.

Tom: Right, and what I love is that they're not just saying "blockchain is cool." They're asking a much deeper question — what does a ledger actually *mean* when you put contracts on it?

Jane: Exactly. So the key idea here is that a ledger is basically a notarial archive — it keeps the complete history of every transaction, forever. And smart contracts, which are supposed to automate agreements, have been implemented as programming code, which has caused real problems.

Tom: Oh, the DAO hack, right? That's the big one — someone exploited a bug in a Solidity smart contract and stole fifty million dollars from the Ethereum common pot back in two thousand sixteen.

Jane: That's exactly the kind of disaster they're trying to prevent. Their argument is that smart contracts should not be arbitrary programs. They should be declarative constructs — like formal agreements that have well-defined behavior, the way databases have ACID properties.

Tom: And that's the exciting part for me — they're bringing back the original vision of smart contracts from Nick Szabo in the 1990s. He saw them as automated legal contracts, not as scripting languages.

Jane: Yes! And they're building a model where a contract is essentially a finite-state automaton. You have states, you have transitions, and each transition is tied to actual transfers of resources between actors. It's like a machine that only moves forward when obligations are actually discharged.

Tom: So instead of writing code that says "do this, then do that," you're defining what resources exist, who holds them, and what transfers are allowed. The contract becomes a set of constraints on how the state of affairs can evolve.

Jane: And that's a huge shift. It means you can verify things, you can reason about the contract formally, and you can connect it back to the legal text in a meaningful way. The paper is really about rebuilding trust in these systems.

Tom: I'm already curious about how they actually model the transfers and the resources — that's the heart of it. Let's dig into that next.

Summary of the Paper: Tom: So, Jane, we're continuing with "A formal model for ledger management systems based on contracts and temporal logic" — and I want to get into what the paper actually does, because the summary is packed with ideas.

Jane: It really is. So the core setup is this: you have a set of resources — tokens representing things like property documents, payment instruments, even events like "a deadline has passed." And you have a set of actors — the parties involved in the contract. A state of affairs is just a mapping that says which actor holds which token at any given moment.

Tom: And then transfers are how you move tokens between actors. Simple enough — but here's where it gets clever. They introduce these things called bundles, which are sets of transfers that must happen together, transactionally.

Jane: Right, so think of a house sale. The buyer transfers the payment, and the seller transfers the property document. Those two transfers have to happen at the same time — you can't have one without the other. That's a bundle.

Tom: And they also introduce these special actors, > and ⊥, which represent the environment. So when an event happens — like a car accident — it's modeled as a transfer from > to ⊥. The event token moves from "not occurred" to "occurred."

Jane: That's such an elegant trick. It means everything relevant to a contract, including timeouts and external events, can be represented uniformly as transfers. You don't need a separate mechanism for events — they're just another kind of resource movement.

Tom: And then they build two automata. The first is the legal contract automaton, which captures the intended states and transitions of the contract — like the formal legal structure. The second is the contract execution automaton, which is a refinement that tracks every individual transfer, including partial progress toward completing a bundle.

Jane: And that distinction matters. Because in the real world, you might file a claim but not yet upload the report. The legal automaton doesn't have a state for that — it only sees the completed bundle. But the execution automaton does, because it tracks each individual action.

Tom: So the execution automaton is like the fine-grained reality, and the legal automaton is the coarse-grained legal view. And they show how one is derived from the other.

Jane: Exactly. And then they connect this to the ledger — every transfer that happens in the execution automaton gets recorded on the ledger. And they define properties like resource-safeness, which ensures you can't transfer something you don't hold, and contract-safeness, which ensures the recorded sequence matches an admissible trajectory in the automaton.

Tom: And the good news — all these properties are decidable. You can actually check whether a ledger state is safe or not. That's a huge deal for auditing.

Jane: It really is. And it sets up the next question — once you have all this structure, how do you actually query the ledger in a meaningful way? That's where the temporal logic comes in.

Improvements Suggested by the Paper: Tom: Okay Jane, we're back with "A formal model for ledger management systems based on contracts and temporal logic" — and now I want to talk about the improvements they're proposing, because this is where it gets really exciting.

Jane: Absolutely. So the big improvement is the query language. They build a modal and temporal logic on top of the ledger structure. And this isn't just a gimmick — it lets you ask genuinely useful questions about the past, present, and future of a contract execution.

Tom: Give me an example. What kind of question can you ask that you couldn't ask before?

Jane: Well, one of my favorites is the "holding" query. You can ask: "At time t, does actor k hold resource r?" And the formula they construct actually checks the history — it looks back to find when the resource was transferred to k, and then checks that no transfer away from k happened after that.

Tom: So it's not just a snapshot — it's a query that verifies the history supports the current state. That's really powerful for auditing.

Jane: Exactly. And they also have operators for looking forward and backward in time. You can ask whether a formula will eventually become true in the future, or whether it was always true in the past. And they have "next" and "previous" operators for immediate steps.

Tom: And there's a really clever bit where they use the concept of adjunctions — from category theory — to show that these temporal operators have nice algebraic properties. They're not just arbitrary operators; they're mathematically well-behaved.

Jane: Right, and that means you can translate queries between different levels of abstraction. You can ask a question in terms of the legal contract automaton, and the translation function lets you interpret it in terms of the actual ledger states.

Tom: So you could ask "is the contract in the Refunded state?" and the system knows how to check that against the actual recorded transfers.

Jane: Precisely. And they also show how to express safety properties as formulas. For example, "no transfer of the form (r, ⊥, k)" — meaning once a resource goes to the bottom actor, it can never come back. And "once a resource is transferred to ⊥, no future transfer of that resource can occur."

Tom: And they have this beautiful axiom that formalizes ledger immutability — the formula Φt+one implies Φt, which says that each evolution at time t+one is contained in the evolution at time t. Once a ledger state is reached, it's reached forever.

Jane: That's the fundamental property of a ledger, and they've made it a logical axiom. And then they show examples of queries you can actually run — like checking whether a sequence of transfers occurred, or whether a certain pattern repeats over time.

Tom: And that pattern-matching query — looking for repeated sequences of transfers — that's like process mining on the ledger. You could detect suspicious activity, like money laundering patterns.

Jane: Exactly. The paper even mentions that — you could look for repeated transfers from Bob to Alice and then Alice to George, which might indicate laundering. Or you could identify supply chain patterns.

Tom: So the improvement here is not just a better query language — it's a way to turn the ledger into a first-class citizen for auditing and analysis. And that's a big deal.

Conclusion: Tom: Well, Jane, we've reached the end of our discussion on "A formal model for ledger management systems based on contracts and temporal logic" — and I have to say, this paper really delivers.

Jane: It does. Let me recap what we've learned. The paper gives us a formal model where contracts are automata, not programs. Resources are tokens, actors hold them, and transfers move them around. Bundles enforce transactionality, and events are just special transfers.

Tom: And the two automata — the legal one for the coarse-grained view and the execution one for the fine-grained view — give us a way to track both the intended structure and the actual progress of a contract.

Jane: Right. And the temporal logic query language lets us ask meaningful questions about the ledger's history, the present state, and even hypothetical futures. We can verify safety properties, audit contract execution, and detect patterns.

Tom: The implications are pretty profound. This could make smart contracts safer, more reliable, and more aligned with their original legal intent. It could help prevent disasters like the DAO hack.

Jane: And it opens the door for better auditing tools, better compliance checking, and a deeper understanding of how contracts and ledgers interact.

Tom: So, a big thank you to Bottoni, Labella, and Pareschi for this work. We're excited to see where this line of research goes.

Jane: Absolutely. And that's a wrap on this paper. We'll be back with the next one soon — stay tuned!

Tom: Thanks for listening, everyone. See you next time!

Paolo Bottoni, Anna Labella, Remo Pareschi

Sapienza University of Rome · University of Molise

cs.CR, cs.CL, cs.LO

Submitted: 2021-09-30

Updated: 2026-08-18

Comments: 49 pages, under review with Blockchain: Research and Applications (Elsevier)

License: http://arxiv.org/licenses/nonexclusive-distrib/1.0/

Importance score: 64/100

Key concepts

Smart Contracts as Automata
Instead of being arbitrary programming scripts, smart contracts are modeled as finite-state automata. This means they have defined states and transitions, acting like formal legal agreements with well-defined behavior rather than just code.
Bundles
A bundle is a set of transfers that must happen together transactionally. For instance, in a property sale, the transfer of payment and the transfer of the deed form a single bundle that cannot be separated.
Temporal Logic
This is a query language built on top the ledger structure. It allows users to ask complex questions about a contract's history, present state, and future possibilities, such as verifying if an actor holds a resource at time t.
Legal vs. Execution Automaton
The legal automaton captures the intended structure of the contract (the coarse view). The execution automaton tracks every individual transfer, providing a fine-grained record of how the contract is actually progressing.

Terminology

Summary

Summary

This paper proposes a formal model for ledger management systems, integrating contracts and temporal logic to address the shortcomings of current smart contract implementations. The authors argue that while second-generation blockchains like Ethereum have coupled ledgers with smart contracts to enable applications such as Decentralized Autonomous Organizations (DAOs), Initial Coin Offerings (ICOs), and Decentralized Finance (DeFi), the implementation of smart contracts as arbitrary programming constructs (e.g., Solidity) has introduced dangerous bugs and moved their semantics away from legal contracts. The paper aims to "recompose the split and recover the reliability of databases by formalizing a notion of contract modelled as a finite-state automaton with well-defined computational characteristics derived from an encoding in terms of allocations of resources to actors, as an alternative to the approach based on programming." Furthermore, the authors use temporal logic as the basis for an abstract query language suited to the historical nature of ledger information.

The paper begins by introducing fundamental concepts: resources, actors, and transfers. A resource is any virtual or tangible asset or service relevant to a contract, represented by a unique token. An actor is an individual entity bound by a contract, participating in transfers. A state of affairs is defined as a set of allocations, where each token is allocated to exactly one actor. A transfer, denoted θ = (r, k1, k2), represents the yielding of resource r from actor k1 to actor k2. Transfers can be grouped into bundles, which are sets of transfers that must occur transactionally (co-occurrently). The paper also introduces environment actors > and ⊥ to model the creation and destruction of resources, as well as the occurrence of events (e.g., deadlines).

The core of the paper models contracts using two finite-state automata. The first is the legal contract automaton MlC = (V l, E l, F, sl, tl, Act, T O, λl, υ), where states represent conditions, transitions represent the discharge of obligations, and final states are mapped to outcomes (HON for honoured or BRC for breach). The second is the contract execution automaton MeC = (V e, E e, F, se, te, Act, T O, λe, υ), which is derived from MlC and considers all possible sequences of individual actions (transfers), including intermediate states that represent partial completion of a set of obligations. This allows the model to track progress towards completing a bundle of transfers. The paper provides a detailed example of an insurance policy contract (Example 2) to illustrate the construction of these automata.

The paper then shows how transfers are encoded on a ledger. A ledger state is a sequence of encodings of transfers. The paper defines several safety properties for ledger states: resource-safeness (a new transfer of a resource is not logged before the previous transfer of that resource), C-wallet safeness (actors only use resources they are entitled to), MlC-bundle safeness (transactions are atomic), and MlC-contract safeness (the sequence of transfers is consistent with the contract automata). These properties are shown to be decidable.

The paper then builds an algebraic model of contracts and its logic. The set of all possible ledger states forms a tree, and the set of all possible contract trajectories forms other trees. The paper defines occurring maps (νCl and νCe) that extract the useful part of a ledger state (i.e., the subsequence of transfers relevant to a contract) and map it to the maximal trajectory in the contract automata. These maps are proven to be monotonic functions. The paper then establishes that the subtrees of these trees form Boolean algebras, allowing for a Boolean logic to be defined. Modal and temporal operators are introduced, including u (there is a future), d (in all futures), d (there is a past), u (in all pasts), NXT (next), and PRV (previous). These operators are shown to have algebraic properties, forming temporal doctrines.

Finally, the paper defines an abstract query language based on this logic. It introduces atomic sentences for querying ledger states (e.g., appθ for transfer θ appears, appθ,n for transfer θ appears at position n). It then shows how to express complex queries, such as:

  • Determining the state of a contract automaton for a given ledger state.

  • Checking if a formula holds for all ledger states in a time interval.

  • Verifying future states given past transfers.

  • Performing hypothetical reasoning about alternative pasts.

  • Finding repetitions of sequences of transfers (useful for auditing and process mining).

The paper concludes by discussing related work, contrasting its approach with temporal data models, the Situation Calculus, and other contract automata models. It emphasizes that its model treats contracts as declarative transactional constructs rather than procedural programs, reproducing some ACID properties while being more flexible. The query logic can be used to audit contract execution and progress.

Improvements for AI systems

Based on the paper, here are specific improvements that can be made to AI systems, along with what the improved systems can do:


Improvement: Replace arbitrary smart contract code (e.g., Solidity) with a finite-state automaton derived from the paper’s MlC (legal contract automaton) and MeC (contract execution automaton). The AI system would parse a legal contract text, extract obligations, resources, actors, and deadlines, and generate the automaton directly.

What it can do:

  • Automatically verify that a sequence of transfers (e.g., payments, document deliveries) is contract-safe (Definition 5) before committing to the ledger.

  • Reject any transaction that would violate bundle-safeness (e.g., partial payment without receipt) or resource-safeness (e.g., double-spending a token).

  • Provide a formal, auditable proof that a given ledger state is a valid prefix of some trajectory in MeC.

Improvement: Implement the modal/temporal operators from Section 6 (u, d, d, u, NXT, PRV) as a query language over ledger states. The AI system would use the tree structure LT and the occurring maps νCl and νCe to translate natural-language queries into logical formulas.

Improvement: Build an AI auditor that, given a ledger state σ and a contract C, computes νCl(σ) and νCe(σ) to determine the current legal and execution states. It then checks whether σ is MlC-contract-safe (Definition 5) and whether any useless transfers (Section 5) are present.

Improvement: Use the bundle and transfer trajectory-labelings (BβC, LρC) to schedule co-occurrent transfers (Section 3) in a transactional manner. The AI system would, given a set of pending obligations, compute the minimal set of transfers that must be applied jointly to satisfy a bundle.

Improvement: Leverage the automaton structure to compute, for any current state v ∈ V l, the set of reachable final states F and their outcomes (HON or BRC). The AI system would use the partial order on trajectories to estimate the probability of each outcome based on historical transfer patterns.

Improvement: Implement the pruning mechanism described in Figure 2. The AI system would maintain a tree of possible ledger states E0, E1,..., En, and upon each new transfer, prune all paths that are not prolongations of the current state.

Improvement: Extend the model to handle multiple contracts simultaneously by using the meet-semilattice structure of LT and the adjoint functions between Subtree(LT) and Subtree(Bβ,in C) for each contract C. The AI system would maintain a separate νCl and νCe for each contract, but share the same ledger LT.

Improvement: Use the paper’s automaton as a specification. The AI system would take a Solidity program, translate it into a state machine, and check whether it is behaviorally equivalent to the legal contract automaton MlC (i.e., whether every legal trajectory in the automaton is a possible execution of the program, and vice versa).

Improvement: Build an AI system that takes a natural-language legal contract (e.g., a lease, insurance policy, or supply agreement) and automatically generates the RSC tuple (resources, actors, transfers, bundles) and the MlC automaton.

Improvement: Use the temporal operators to define alert conditions. The AI system would continuously evaluate formulas like u (deadline expired ∧ ¬payment made) on the evolving ledger tree.

These improvements collectively transform AI systems from passive record-keepers into active, verifiable, and predictive contract-management engines, grounded in formal logic and automata theory.

Related papers