Mathematical Components, an introduction

  • Welcome!
  • Objective: help you enter the MC library



Propaganda

  • For Isabelle users: it is like HOL
  • For Coq users: it is simpler
  • For newcomers: it works


Lesson 1 (of 4)

  • Boolean reflection
  • Tactic language


Boolean reflection in a nutshell

  • Bool datatype to represent mere propositions
  • Symbolic computation is a predictable, pervasive, form of automation


The emblematic example

to say: .+1 , lt , = true , = mean equiv , by , elim , apply , rewrite


A logic in bool

  • One can also place conectives in bool
  • Here symbolic computation means progress
  • In bool EM holds

ssrbool

by case: b1; case; b2.

if b1 then true else b2

by case: b1; case: b2.


Objective: infinitude of primes

Let's take a number m and exhibit a prime bigger than it.

Every natural number greater than 1 has at least one prime divisor. If we take m! + 1, then such prime divisor p can be shown to be grater than m as follows.

By contra position we assume p <= m and we show p does not divide m! + 1.

Being smaller than m, p|m!, hence to divide m! + 1, p should divide 1, that is not possible since p is prime, hence greater than 1.


Some arithmetic

ssrnat prime div

to say: move, rewrite //, Search, .. <= .. <= ..

Lemma contraL c b : (c -> ~~ b) -> b -> ~~ c.
Lemma gtnNdvd n d : 0 < n -> n < d -> (d %| n) = false.
Lemma dvdn_addr m d n : d %| m -> (d %| m + n) = (d %| n).
Lemma dvdn_fact m n : 0 < m <= n -> m %| n`!.


Bool is not enough

  • The bool data type is not closed under general quantifiers
  • Coq provides the Prop world for propositions
  • We need a way to relate the two worlds

to say: exists/curry howard, bool/Prop, reflect

  by case: a; case: b.
by move=> [pa pb]; rewrite pa pb.


Views and intro patterns

  • Two ways to use a reflect

to say: move= /andP eqP ==

Lemma ltnW m n : m < n -> m <= n.
Lemma eqP m n : reflect (m = n) (m == n).
Lemma ltngtP m n : compare_nat m n (m < n) (n < m) (m == n)


Infinitude of primes

Lemma pdivP n : 1 < n -> exists2 p, prime p & p %| n.	
Lemma dvdn_mull d m n : d %| n -> d %| m * n.
Lemma dvdn_mulr d m n : d %| m -> d %| m * n.


Wrap up

  • logic of Coq
    • lets you express programs
    • Coq knows hot compute them
    • their execution is a legit form of proof

  • boolean predicates
    • symbolic computation at hand
    • EM at hand
    • ... UIP at hand ...

  • proof language
    • small bricks
    • compose well
    • squeezing video game quite addictive ;-)

Exercises

  • Hint1: Search results can be limited to the ssrnat module as in Search _ something in ssrnat. All the lemmas you are looking for live in there.

  • Hint2: removing an hypothesis named Hyp from the context can be done with move=> {Hyp}.

elim: n => // n IHn.
rewrite expnS odd_mul IHn orbC.
move=> {IHn}.
by case: (odd m).

by rewrite mulnBl !mulnDr addnC (mulnC m) subnDl !mulnn.