Matita Tutorial

Matita Tutorial

Matita Tutorial ANDREA ASPERTI DISI: Dipartimento di Informatica, Universit`a degli Studi di Bologna and WILMER RICCIOTTI IRIT, Universit´e de Toulouse and CLAUDIO SACERDOTI COEN DISI: Dipartimento di Informatica, Universit`a degli Studi di Bologna This tutorial provides a pragmatic introduction to the main functionalities of the Matita interac- tive theorem prover, offering a guided tour through a set of not so trivial examples in the field of software specification and verification. Contents 0 Getting Started 94 0.1 Installing Matita............................. 94 0.2 Preparing a working directory...................... 95 0.3 Matita interface.............................. 95 0.4 Browsing the library........................... 96 0.5 Live DVD................................. 97 0.6 Matita Web................................ 98 1 Data Types, Functions and Theorems 99 1.1 The goat, the wolf and the cabbage................... 99 1.2 Defining functions............................ 100 1.3 Our first lemma.............................. 101 1.4 Introducing hypothesis in the context................. 102 1.5 Case analysis............................... 102 1.6 Predicates................................. 103 1.7 Rewriting................................. 103 1.8 Records.................................. 104 1.9 Automation................................ 105 1.10 Application................................ 105 1.11 Focusing.................................. 106 1.12 Implicit arguments and partial instantiation.............. 107 2 Induction 109 2.1 Elimination................................ 109 2.2 Existentials................................ 110 2.3 Decomposition.............................. 111 Journal of Formalized Reasoning Vol. 7, No. 2, 2014, Pages 91–199. 92 · A. Asperti and W. Ricciotti and C. Sacerdoti Coen 2.4 Computing vs. Proving......................... 112 2.5 Destruct.................................. 113 2.6 Cut.................................... 114 2.7 Lapply................................... 115 2.8 Mixing proofs and computations.................... 116 2.9 Tactic patterns.............................. 117 3 Everything is an inductive type 119 3.1 Conjunction................................ 119 3.2 Disjunction, False, True, Existential Quantification.......... 120 3.3 A bit of notation............................. 121 3.4 Leibniz Equality............................. 123 3.5 Equality, convertibility, inequality.................... 125 3.6 Inversion.................................. 126 4 Propositions as Types 128 4.1 Cartesian Product and Disjoint Sum.................. 128 4.2 Sigma Types and dependent matching................. 130 4.3 Kolmogorov interpretation........................ 131 4.4 The Curry-Howard correspondence................... 132 4.5 Prop vs. Type.............................. 134 5 More Data Types 137 5.1 Option Type............................... 137 5.2 Lists.................................... 137 5.3 List iterators............................... 140 5.4 Naive Set Theory............................. 141 5.5 Sets with decidable equality....................... 142 5.6 Unification hints............................. 143 5.7 Prop vs. bool............................... 144 5.8 Finite Sets................................. 145 5.9 Vectors.................................. 145 5.10 Dependent matching........................... 146 5.11 A heterogeneous notion of equality................... 147 6 A formalization example: regular expressions and DFA 150 6.1 Words and Languages.......................... 150 6.2 Regular Expressions........................... 151 6.3 Pointed regular expressions....................... 151 6.4 Intensional equality of PREs...................... 153 6.5 Broadcasting points........................... 153 6.6 Semantics................................. 155 6.7 Initial state................................ 156 6.8 Lifted operators.............................. 156 6.9 Moves................................... 157 6.10 Regular expression equivalence..................... 160 Journal of Formalized Reasoning Vol. 7, No. 2, 2014. Matita Tutorial · 93 7 Quotienting in type theory 162 7.1 Rewriting setoid equalities........................ 167 7.2 Dependent setoids............................ 170 7.3 Avoiding setoids............................. 170 8 Infinite structures and Coinductive Types 172 8.1 Real Numbers as Cauchy sequences................... 172 8.2 Traces of a program........................... 174 8.3 Infinite data types as coinductive types................ 176 8.4 Real numbers via coinductive types................... 178 8.5 Intermezzo: the dynamics of coinductive data............. 180 8.6 Traces of a program via coinductive types............... 181 8.7 How to compare coinductive types................... 185 8.8 Generic construction principles..................... 188 9 Logical Restrictions 190 9.1 Positivity in inductive definitions.................... 190 9.2 Universe Constraints........................... 192 9.3 Informative and non informative content................ 194 10 Further readings 197 Journal of Formalized Reasoning Vol. 7, No. 2, 2014. 94 · A. Asperti and W. Ricciotti and C. Sacerdoti Coen 0. GETTING STARTED Matita [4] is a dependently-typed interactive prover under development at the Com- puter Science Department of the University of Bologna. An interactive prover is a software tool aiding the development of formal proofs by man-machine collaboration. It provides a formal language where mathemat- ical definitions, executable algorithms and theorems coexist, and an interactive environment keeping the current status of the proof, and updating it according to commands (usually called tactics) issued by the user [13, 24]. This tutorial provides an introduction to the system, explicitly addressed to absolute beginners, and does not require previous knowledge about interactive the- orem proving or type theory. An executable version of the tutorial is available in the /usr/share/matita/lib/tutorial directory after having installed Matita (see next Section). The reader is supposed to run the executable tutorial while reading the current document: in this document we only illustrate those code snapshots that showcase noteworthy concepts and techniques for the first time. The tutorial is also a companion document to the user manual of Matita, that can be browsed from the Help menu of the application. The manual provides the comprehensive list of commands of Matita, comprising their syntax and semantics. 0.1 Installing Matita At present, Matita only works on Linux-based systems. Both Debian and Ubuntu systems have packages called “matita” in the standard system repositories, but we do not suggest to use them, since they would install an out-of-date and incompatible version of the Matita system. If you are running a Debian-based system with APT installed, you should first of all install the required dependencies by issuing the following command at a terminal window1 apt-get install ocaml ocaml-findlib libgdome2-ocaml-dev liblablgtk2-ocaml-dev liblablgtksourceview-ocaml-dev libsqlite3-ocaml-dev libocamlnet-ocaml-dev libzip-ocaml-dev libhttp-ocaml-dev ocaml-ulex08 libexpat-ocaml-dev libmysql-ocaml-dev camlp5 The next step is to prepare a directory for the Matita sources and binaries and enter it; for instance, issue the following series of commands: $ cd ˜ $ mkdir Matita $ cd Matita We shall henceforth refer to this directory as $MATITA_HOME. You should now down- load and unpack from the Matita download page at http://matita.cs.unibo.it/ download.shtml the most recent version of the Matita development source tarball; at present this is matita_130312.tar.gz: 1If you are running the latest Ubuntu release the package liblablgtksourceview-ocaml-dev has been superseded by liblablgtksourceview2-ocaml-dev Journal of Formalized Reasoning Vol. 7, No. 2, 2014. Matita Tutorial · 95 $ wget http://matita.cs.unibo.it/sources/matita_130312.tar.gz $ tar -xzf matita_130312.tar.gz In $MATITA_HOME you should now be left with two further subdirectories, matita and components, as well as numerous makefiles and auto-configuration scripts. Build the configuration script with the following command:2 $ autoconf configure.ac > configure $ chmod +x configure $ ./configure This will check that all needed tools and libraries are installed and prepare the sources for compilation and installation. Then, type: $ make world All being well, the previous command will build the various Matita-related binaries and their optimised counterparts and place them in $MATITA_HOME/matita. In particular, check for the presence of the optimised Matita binary, matita.opt, in this subdirectory. 0.2 Preparing a working directory Before you start editing proof scripts you must prepare a working directory; this can be anywhere in your file systemâĂŹs file hierarchy and does not need to be a subdirectory of $MATITA_HOME. For example: $ cd ˜ $ mkdir ProofScripts $ cd ProofScripts We shall refer to this directory as $SCRIPTS_HOME, henceforth. In $SCRIPTS_HOME create a file called root containing the following declaration: baseuri=cic:/matita Congratulations, you are ready to start proving things! 0.3 Matita interface In order to check that everything is up and running, let us perform a simple ex- periment. Open Matita by invoking $MATITA_HOME/matita/matita.opt from a command line. A window should appear on your screen with the shape in Fig- ure 0.3 The interface [8] is divided into three subpanes: one on the left and two stacked vertically

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    109 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us