Coq is a proof assistant based on type theory that can be used to formally verify programs and proofs. It supports program extraction to OCaml and can be used to prove properties of programs written in languages like OCaml, Java, C, and Assembly. Coq has been used to verify high assurance systems like the seL4 microkernel and TLS and JavaCard implementations. Formal verification in Coq is based on the Curry-Howard correspondence where types correspond to propositions and programs correspond to proofs. Tactics and rewriting rules are used to interactively prove goals in Coq.
This document summarizes a discussion about formalizing Kleene algebra and Brzozowski's derivatives in the Coq proof assistant. It describes how regular expressions and their derivatives were defined inductively in Coq, and how properties like Kleene's star were proved using tactics like setoid rewriting. It also provides instructions for Coq users to contribute formalizations by packaging files into a tar archive and submitting it to the Coq user contributions website.
This document discusses the Coq proof assistant. It provides examples of defining concepts like booleans, natural numbers, and functions in Coq. It demonstrates tactics for proving properties like De Morgan's laws. It also shows how to define recursive functions over natural numbers like addition and equality testing. The document aims to introduce basic concepts and usage of the Coq system through examples.
This document discusses type classes in Coq. It begins by introducing polymorphism and monads. It then defines the Monad type class in Coq, with return, bind, and other laws. Instances are given for the identity, maybe, list, and cont monads. The MonadPlus type class is also defined, with instances for maybe and list.
eq_nat is recursively defined to test equality of two natural numbers n and m by pattern matching on their constructions. It returns true if both are 0, or if their successors S n' and S m' are recursively equal; otherwise it returns false. Evaluating eq_nat 3 3 returns true since 3 is constructed by applying S twice to 0, and both arguments have the same construction.
- The document discusses several papers and tools related to parsing and regular expressions, including Brzozowski's derivative approach to parsing context-free grammars and a Scala library that implements regular expression matching in under 100 lines of code.
- It also mentions "Yacc is Dead", a paper arguing that LR parsing techniques provide a better alternative to Yacc than general parser generators due to being smaller and easier to implement.
- Additionally, the document recommends resources for learning more about formal language theory, parsing, and regular expressions.
This document defines integers as pairs of natural numbers (Z') in Coq, proves it forms a setoid, and defines addition on Z' as a morphism. Properties of addition like commutativity and identities are proven. Tactics for rewriting and replacing in setoids like setoid_rewrite and setoid_replace are introduced.
Maude is a programming language based on rewriting logic that allows both declarative and concurrent programming. It has applications in formal specification, model checking, and programming domains like DSL development. The document provides examples of defining natural numbers and a cigarette smoking simulation in Maude. It also describes using Maude's model checking capabilities to analyze a river crossing puzzle.
17. 帰納的関数の定義 / プログラム抽出 Coq < Print plus. // 予め定義されている plus = fix plus (nm : nat) : nat := match n with | 0 => m | S p => S (p + m) end : nat -> nat -> nat Coq < Extraction “plus.ml” plus. // OCamlプログラムとして抽出 % cat plus.ml type nat = | O | S of nat (** val plus : nat -> nat -> nat **)// 普通のOcamlの関数 let rec plus nm = match n with | O -> m | S p -> S (plus pm) 17
18. 帰納的関数の性質の証明(1) Coq < Theorem t : forallnm : nat, n + m = m + n. // これを証明する。 1 subgoal ============================ forallnm : nat, n + m = m + n t < intros. // forallの除去。初手は大抵intros. 1 subgoal n : nat m : nat ============================ n + m = m + n t < induction n. // nについて帰納法。0と(S n)とに場合分け 2 subgoals m : nat ============================ 0 + m = m + 0 // n=0 の場合 subgoal 2 is: S n + m = m + S n t < simpl; trivial. // 0 + m = m + 0 を簡単化すると自明な式に。 18
19. 帰納的関数の性質の証明(2) 1 subgoal n : nat m : nat IHn : n + m = m + n // 帰納法の前提 ============================ S n + m = m + S n t < rewrite plus_Sn_m. 1 subgoal n : nat m : nat IHn : n + m = m + n ============================ S (n + m) = m + S n t < rewrite <- plus_n_Sm. 1 subgoal n : nat m : nat IHn : n + m = m + n ============================ S (n + m) = S (m + n) t < apply eq_S. 1 subgoal n : nat m : nat IHn : n + m = m + n ============================ n + m = m + n t < exact IHn. Proof completed. t < Qed. 19 Coq < Check plus_Sn_m. plus_Sn_m : forallnm : nat, S n + m = S (n + m) Coq < Check eq_S. eq_S : forallxy : nat, x = y -> S x = S y
38. 練習問題 Coq本より Theorem ex561 : forall A B C : Prop, A/B/) -> (A/)/. Theorem ex562 : forall A B C D : Prop, (A->B)/C->D)// -> B/. Theorem ex563 : forall A : Prop, ~(A/A). Theorem ex564 : forall A B C : Prop, A(BC) -> (AB)C. Theorem ex565 : forall A : Prop, ~~(A~A). Theorem ex566 : forall A B : Prop, (AB)/A -> B. Theorem ex567 : forallA:Set, forall P Q:A->Prop, (forallx, P x)(forally, Q y)->forallx, P xQ x. パズルゲーム感覚で解けます。 というか端から色々試すアドヴェンチャーゲーム? 適用出来ないtacticはエラーメッセージが出るだけ。 23
42. Hoare論理の公理 {Q[e/x]}x:=e{Q} {P}S1{R}, {R}S2{Q} ------------------------ {P}S1;S2{Q} {P∧B}S1{Q}, {P∧¬B}S2{Q} ----------------------------- {P} if B then S1 else S2 {Q} {P∧B}S{P} ----------------------------- {P} while B do S end {P∧¬B} PP1, {P1}S{Q1}, Q1Q ------------------------------ {P}S{Q} 27