Textbook in PDF format
This book describes some basic principles that allow developers of computer programs (computer scientists, software engineers, programmers) to clearly think about the artifacts they deal with in their daily work: data types, programming languages, programs written in these languages that compute wanted outputs from given inputs, and programs that describe continuously executing systems. The core message is that clear thinking about programs can be expressed in a single, universal language, the formal language of logic. Apart from its universal elegance and expressiveness, this “logical” approach to the formal modeling of, and reasoning about, computer programs has another advantage: due to advances in computational logic (automated theorem proving, satisfiability solving, model checking), nowadays much of this process can be supported by software. This book therefore accompanies its theoretical elaborations by practical demonstrations of various systems and tools that are based on or make use of the presented logical underpinnings.
Chapter "Programming Languages" discusses the formal semantics of programming languages. For this we extend the previously introduced type specification language to an imperative (command-based) programming language whose semantics we describe by two approaches. In denotational semantics, we first map commands to partial functions on program states; these functions are defined by logical terms. Later we generalize this classical “functional” style to a non-classical but much more flexible “relational” style where commands are mapped to state relations defined by logical formulas. In operational semantics, we give programs a semantics by mapping them to transition relations defined by logical inference systems; we then show the essential equivalence of denotational and operational semantics. We apply these techniques to model the translation of the command language to a low-level machine language and prove the correctness of the translation. Finally, we extend the command language by the abstraction mechanism of procedures and model their semantics.
Logic for Programming: A Perspective
The Foundations
Syntax and Semantics
Abstract Syntax Trees in OCaml and SLANG
The Language of Logic
The Logic of the RISCProof Navigator
The Art of Reasoning
ReasoningwiththeRISCProofNavigator
Building Models
WritingDefinitionsinIsabelle/HOL
Recursion.
The Higher Planes
Abstract Data Types
Abstract Data Types in CafeOBJ and CASL
Programming Languages
Language Semantics in OCaml, the KFramework, and SLANG
ComputerPrograms..
Program Reasoning in RISCAL and the RISCProgramExplorer
Concurrent Systems
Exercises
System Analysis inTLA+ and RISCAL