Certified Security by Design Using Higher Order Logic
Total Page:16
File Type:pdf, Size:1020Kb
Certified Security by Design Using Higher Order Logic1 Shiu-Kai Chin and Susan Older Department of Electrical Engineering and Computer Science Syracuse University, Syracuse, New York 13244 Fall 2018 Version 2.0 (August 2018) 1The development of this book was partially supported by the US National Science Foundation (Award #1245867). 2 VERSION 2.0 Copyright © 2018 by Shiu-Kai Chin All rights reserved. No part of this publication may be reproduced, stored, or transmitted in any form without permission of the author In memory of Lockwood Morris for his unwavering support To the engineers and computer scientists who design and deliver the systems on which we depend 4 VERSION 2.0 Contents Preface 15 I Introduction and Motivation 17 1 Introduction 19 1.1 What this book is about . 19 1.2 Our audience . 20 1.3 What computer engineers and scientists need to know . 21 1.4 Certified Security by Design . 22 1.4.1 Concepts of Operation . 22 1.4.2 A motivating example . 24 1.4.3 What you will learn . 25 II Lab Exercises: Introduction to ML 27 2 Getting Started with Linux, ML, and Emacs 29 2.1 Getting set up . 29 2.2 Looking around using Linux commands within a terminal . 30 2.3 Starting HOL and Evaluating ML Expressions . 31 2.4 Starting Emacs . 32 2.5 Exercises . 34 3 An Introduction to ML within HOL 37 3.1 Values and Types in ML . 38 3.2 Compound Values . 42 3.3 Value Declarations . 44 3.4 Exercises . 49 4 Functions in ML 51 4.1 Functions, Evaluation Rules, and Values . 51 4.2 Functions, Evalution Rules and Values in ML . 54 4.3 Naming Functions in ML . 55 4.4 Defining Functions Using Pattern Matching in ML . 57 4.5 Let Expressions in ML . 59 4.6 Exercises . 62 5 6 VERSION 2.0 5 Polymorphism and Higher-Order Functions in ML 63 5.1 Polymorphism . 64 5.2 Higher-Order Functions . 66 5.3 Exercises . 69 III Lab Exercises: Introduction to HOL 71 6 Introduction to HOL 73 6.1 HOL Terms . 73 6.1.1 Entering HOL terms and types . 73 6.2 Exercises . 75 7 Constructing and Deconstructing HOL Terms 77 7.1 Introduction to Constructing and Deconstructing HOL Terms . 77 7.2 Manipulating HOL terms . 79 7.3 Exercises . 82 8 Introduction to Forward Proofs in HOL 83 8.1 Structure of HOL Theorems . 83 8.2 Inference Rules in HOL . 85 8.3 Relating Proofs in HOL to Traditional Proofs . 86 8.4 Exercises . 89 9 Goal-Oriented Proofs 91 9.1 Goal-Oriented Proofs . 91 9.1.1 Basic Techniques . 91 9.1.2 Tactics . 92 9.2 Using Tactics and Tacticals . 94 9.2.1 Tactics . 94 9.2.2 Tacticals . 96 9.2.3 Working with Assumptions . 100 9.3 Using HOL within Emacs . 101 9.4 High-Level Proof Tactics . 106 9.5 Exercises . 107 10 Dealing with Assumptions in Goal-Oriented Proofs 109 10.1 Rewriting and Resolution . 109 10.2 Manipulating the Assumptions with PAT ASSUM . 112 10.3 More Examples . 114 10.4 Exercises . 126 11 Defining Theories, Types, and Functions in HOL 127 11.1 Defining New Theories in HOL . 127 11.2 Using Existing Theories and Types in HOL . 129 11.3 Adding New Definitions to HOL . 130 11.4 Proofs Using Structural Induction . 132 11.5 Defining New Types and Their Properties in HOL . 135 VERSION 2.0 7 11.6 Exercises . 141 12 Inductive Relations in HOL 143 12.1 Inductive Definitions in HOL . 143 12.2 Reasoning About Inductive Relations . 149 12.2.1 Even rules . 149 12.2.2 Odd rules . 152 12.2.3 not odd 0........................................ 152 12.2.4 not even 1 ....................................... 154 12.2.5 even not odd...................................... 155 12.2.6 odd not even...................................... 158 12.2.7 even theorem . 159 12.2.8 odd theorem . 162 12.2.9 not even lemma . 162 12.2.10 not odd lemma . 164 12.2.11 even odd theorem . 164 12.2.12 odd even theorem . 165 12.2.13 evenEven lemma . 165 12.2.14 oddOdd lemma . 167 12.2.15 Even even Odd odd lemma . 167 12.2.16 even is Even ...................................... 168 12.2.17 odd is Odd....................................... 169 12.2.18 even is EVEN ..................................... 169 12.2.19 Even is EVEN..................................... 175 12.2.20 odd is ODD ...................................... 175 12.2.21 Odd is ODD ...................................... 175 12.3 Exercises . 176 IV Lab Exercises: Access-Control Logic in HOL 179 13 An Access-Control Logic in HOL 181 13.1 Syntax . 181 13.2 Semantics . 182 13.3 Inference Rules . 183 13.4 Describing Access-Control Concepts in the C2 Calculus . 184 13.5 The Access-Control Logic in HOL . 186 13.6 Syntax of the Access-Control Logic in HOL . 187 13.7 Semantics of the Access-Control Logic in HOL . 188 13.8 C2 Inference Rules in HOL . 190 13.9 Using the Access Control Logic in HOL . 190 13.9.1 Specifying Directory Paths for HOL . 190 13.9.2 Documentation for the ACL Implementation in HOL . 191 13.9.3 The ACL ASSUM and CONTROLS Inference Rules . 193 13.9.4 Using the ACL ASSUM and Controls Inference Rules . 195 13.9.5 Goal-Oriented Access-Control Logic Proofs . 199 13.9.6 More.