1 / 13

Coq in Two Hours

Coq in Two Hours. A quick tutorial on reading Coq proofs. What is Coq?. https://www.seas.upenn.edu/~cis500/current/index.html. Software Engineering. Formal Verification. Foundation. Programming Languages. “More” Foundation. Math. Logic. “Application” in “Real-world”.

cumberland
Download Presentation

Coq in Two Hours

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Coq in Two Hours AquicktutorialonreadingCoqproofs.

  2. What is Coq? https://www.seas.upenn.edu/~cis500/current/index.html Software Engineering Formal Verification Foundation Programming Languages “More” Foundation Math Logic

  3. “Application”in“Real-world” • Certificatedcompiler • Compcert:http://compcert.inria.fr • L2C:https://github.com/l2ctsinghua/l2c(ShengyuanWang) • CertificatedOS • CertiKOS:http://flint.cs.yale.edu/shao/papers/certikos.html(ZhongShao) • Certificatedblockchain?

  4. Forus,… • Helptolearnlogic,types,semantics,verification,algebra,etc. • Rethinkwhatproofis. • Writeproofmorestrictlyandprecisely.

  5. Outline • Basics • Booleans, Function Types, Numbers • Proof by simplification, rewriting and case analysis • Proof by Induction • PolymorphismList • Tactics • Logic • Relation

  6. Basics • Coq people say “Proof.simpl. reflexivity. Qed.” is just a test! • Proofs are goal-guided. • Functions are first-class citizen. (functional) • Coq provides a programming language to model functions and data. • Recursive functions (fixpoints) must be written in a form s.t. Coq can show its termination. • Induction is the core of programming in Coq. • Q:Whodoestheproof?

  7. Proof by Induction • Coq people saymathematicalproofsareinformal!* • Works for inductivelydefined structures. • Only necessary if destruct fails. • Choosing which variable to induct is tricky (depends on the definition). *Logiciansthink(mathematicians’)mathematicsarenotstrict.Informalproofsmaybeambiguous,e.g.the“example”in“let’sseeanexample”(metalanguage)and“synthesisbyexample”(formallanguage).

  8. Polymorphism List • Types are first-class citizen. (dependent type) • Type arguments can be inferenced. (implicit type*) *Scala masters implicit types.

  9. Tactics • beq_natand = are two different things. • Induction hypothesis need to be general sometimes. • apply: behave symmetrically when applying to hypotheses/goals. • inversion: reduce complicated constructors, yield contradiction. • unfold: unfold definitions. • assert: show immediate conclusions for convenience. • destruct/induction: applied on expressions.

  10. Logic • Patterns: [A B] v.s. [A | B]. • Prove goals: split for /\ and <->, left/right for \/. • Prove existential: exists. • Propositions are first-class citizens. • Propositions and bools are different. • Coq uses Constructive Logic.

  11. Coq’sLogicalSystemisIncomplete For those who like a challenge, here is an exercise taken from theCoq’Art book by Bertot and Casteran (p. 123). Each of thefollowing four statements, together with excluded_middle, can beconsidered as characterizing classical logic. We can’t prove anyof them in Coq, but we can consistently add any one of them as anaxiom if we wish to work in classical logic.Prove that all five propositions (these four plusexcluded_middle) are equivalent. Definitionpeirce := forall P Q: Prop,((P->Q)->P)->P.Definitiondouble_negation_elimination := forallP:Prop,~~P -> P.Definitionde_morgan_not_and_not := forall P Q:Prop,~(~P /\ ~Q) -> P\/Q.Definitionimplies_to_or := forall P Q:Prop,(P->Q) -> (~P\/Q).

  12. Relations • Inductively defined relations tell all possible rules. • inversion: destruct on evidence. • induction: induction on evidence. • apply: use a rule.

  13. Future We will focus on a small imperative programming language IMP… • Syntax and Semantics • Equivalence • Hoare logic • Small-Step operational semantics

More Related