MAP INTERNATIONAL SPRING SCH L ON FORMALIZATION OF MATHEMATICS - - PowerPoint PPT Presentation

map international spring sch l on formalization of
SMART_READER_LITE
LIVE PREVIEW

MAP INTERNATIONAL SPRING SCH L ON FORMALIZATION OF MATHEMATICS - - PowerPoint PPT Presentation

Librairy overview - a first guided tour Laurence Rideau 14 March MAP INTERNATIONAL SPRING SCH L ON FORMALIZATION OF MATHEMATICS 2012 SOPHIA ANTIPOLIS, FRANCE / 12-16 MARCH numbers Finite Outline


slide-1
SLIDE 1

L ON FORMALIZATION OF SPRING SCH

SOPHIA ANTIPOLIS, FRANCE / 12-16 MARCH

MATHEMATICS 2012 MAP INTERNATIONAL

Librairy overview - a first guided tour

Laurence Rideau 14 March

slide-2
SLIDE 2

numbers Finite

Outline

http://coqfinitgroup.gforge.inria.fr/ssreflect-1.3/

1

Walk around in natural numbers area

2

About finite objects

Laurence Rideau Librairy overview - a first guided tour

slide-3
SLIDE 3

numbers Finite nat div prime binomial

Outline

1

Walk around in natural numbers area ssrnat div prime binomial

2

About finite objects

Laurence Rideau Librairy overview - a first guided tour

slide-4
SLIDE 4

numbers Finite nat div prime binomial

ssrnat: Type and Arithmetic Operators

Inductive type: nat := O | S of nat standard Coq

Laurence Rideau Librairy overview - a first guided tour

slide-5
SLIDE 5

numbers Finite nat div prime binomial

ssrnat: Type and Arithmetic Operators

Inductive type: nat := O | S of nat standard Coq Notations: ”0” and ”n.+1” (generalized till .+4).

Laurence Rideau Librairy overview - a first guided tour

slide-6
SLIDE 6

numbers Finite nat div prime binomial

ssrnat: Type and Arithmetic Operators

Inductive type: nat := O | S of nat standard Coq Notations: ”0” and ”n.+1” (generalized till .+4). Arithmetic operators: ”+” (addn), ”-” (subn), ”*” (muln), ”^” (expn)

Laurence Rideau Librairy overview - a first guided tour

slide-7
SLIDE 7

numbers Finite nat div prime binomial

ssrnat: Type and Arithmetic Operators

Inductive type: nat := O | S of nat standard Coq Notations: ”0” and ”n.+1” (generalized till .+4). Arithmetic operators: ”+” (addn), ”-” (subn), ”*” (muln), ”^” (expn) Convertible to plus, minus, and mult.

Laurence Rideau Librairy overview - a first guided tour

slide-8
SLIDE 8

numbers Finite nat div prime binomial

ssrnat: Type and Arithmetic Operators

Inductive type: nat := O | S of nat standard Coq Notations: ”0” and ”n.+1” (generalized till .+4). Arithmetic operators: ”+” (addn), ”-” (subn), ”*” (muln), ”^” (expn) Convertible to plus, minus, and mult. Locked to prevent simplification. Tactic: ”unlock addn.”

Laurence Rideau Librairy overview - a first guided tour

slide-9
SLIDE 9

numbers Finite nat div prime binomial

ssrnat: Rewriting Rules

Explicit rewriting rules for simplification:

addn0: n + 0 = n add0n: 0 + n = n

Laurence Rideau Librairy overview - a first guided tour

slide-10
SLIDE 10

numbers Finite nat div prime binomial

ssrnat: Rewriting Rules

Explicit rewriting rules for simplification:

addn0: n + 0 = n add0n: 0 + n = n addn1: n + 1 = n.+1 add1n: 1 + n = n.+1 till .+4

Laurence Rideau Librairy overview - a first guided tour

slide-11
SLIDE 11

numbers Finite nat div prime binomial

ssrnat: Rewriting Rules

Explicit rewriting rules for simplification:

addn0: n + 0 = n add0n: 0 + n = n addn1: n + 1 = n.+1 add1n: 1 + n = n.+1 till .+4 addnS: m + n.+1 = (m + n).+1 addSn: m.+1 + n = (m + n).+1

Laurence Rideau Librairy overview - a first guided tour

slide-12
SLIDE 12

numbers Finite nat div prime binomial

ssrnat: Rewriting Rules

Explicit rewriting rules for simplification:

addn0: n + 0 = n add0n: 0 + n = n addn1: n + 1 = n.+1 add1n: 1 + n = n.+1 till .+4 addnS: m + n.+1 = (m + n).+1 addSn: m.+1 + n = (m + n).+1

Other rewriting rules:

addnC: m + n = n + m commutativity addnA: m + (n + p) = (m + n) + p associativity

Laurence Rideau Librairy overview - a first guided tour

slide-13
SLIDE 13

numbers Finite nat div prime binomial

ssrnat: Rewriting Rules

Explicit rewriting rules for simplification:

addn0: n + 0 = n add0n: 0 + n = n addn1: n + 1 = n.+1 add1n: 1 + n = n.+1 till .+4 addnS: m + n.+1 = (m + n).+1 addSn: m.+1 + n = (m + n).+1

Other rewriting rules:

addnC: m + n = n + m commutativity addnA: m + (n + p) = (m + n) + p associativity addnK: (n + p) − p = n cancellation addKn: (p + n) − p = n

Laurence Rideau Librairy overview - a first guided tour

slide-14
SLIDE 14

numbers Finite nat div prime binomial

ssrnat: Rewriting Rules

Explicit rewriting rules for simplification:

addn0: n + 0 = n add0n: 0 + n = n addn1: n + 1 = n.+1 add1n: 1 + n = n.+1 till .+4 addnS: m + n.+1 = (m + n).+1 addSn: m.+1 + n = (m + n).+1

Other rewriting rules:

addnC: m + n = n + m commutativity addnA: m + (n + p) = (m + n) + p associativity addnK: (n + p) − p = n cancellation addKn: (p + n) − p = n addnI: p + m = p + n ⇒ m = n injectivity addIn: m + p = n + p ⇒ m = n

Laurence Rideau Librairy overview - a first guided tour

slide-15
SLIDE 15

numbers Finite nat div prime binomial

ssrnat: Comparison Operators

”<=” leq ”<” Notation "m < n":= (m.+1 <= n) ”>=” ”>”

Laurence Rideau Librairy overview - a first guided tour

slide-16
SLIDE 16

numbers Finite nat div prime binomial

ssrnat: Comparison Operators

”<=” leq ”<” Notation "m < n":= (m.+1 <= n) ”>=” ”>” Boolean functions: leq: nat -> nat -> bool. For propositions, implicitly: (m <= n) = true.

Laurence Rideau Librairy overview - a first guided tour

slide-17
SLIDE 17

numbers Finite nat div prime binomial

ssrnat: Comparison Operators

”<=” leq ”<” Notation "m < n":= (m.+1 <= n) ”>=” ”>” Boolean functions: leq: nat -> nat -> bool. For propositions, implicitly: (m <= n) = true. Reflection with standard Coq:

leP: le m n ⇔ leq m n = true ltP: lt m n ⇔ leq m.+1 n = true

Laurence Rideau Librairy overview - a first guided tour

slide-18
SLIDE 18

numbers Finite nat div prime binomial

ssrnat: Comparison Operators

Usual properties:

leq0n: 0 ≤ n ltn0Sn: 0 < n.+1

Laurence Rideau Librairy overview - a first guided tour

slide-19
SLIDE 19

numbers Finite nat div prime binomial

ssrnat: Comparison Operators

Usual properties:

leq0n: 0 ≤ n ltn0Sn: 0 < n.+1 leqnn: n ≤ n ltnSn: n < n.+1 leqnSn: n ≤ n.+1

Laurence Rideau Librairy overview - a first guided tour

slide-20
SLIDE 20

numbers Finite nat div prime binomial

ssrnat: Comparison Operators

Usual properties:

leq0n: 0 ≤ n ltn0Sn: 0 < n.+1 leqnn: n ≤ n ltnSn: n < n.+1 leqnSn: n ≤ n.+1 leq trans: m ≤ p ⇒ p ≤ n ⇒ m ≤ n transitivity ltn trans: m < p ⇒ p < n ⇒ m < n leq ltn trans: m ≤ p ⇒ p < n ⇒ m < n

Laurence Rideau Librairy overview - a first guided tour

slide-21
SLIDE 21

numbers Finite nat div prime binomial

ssrnat: Comparison Operators

Usual properties:

leq0n: 0 ≤ n ltn0Sn: 0 < n.+1 leqnn: n ≤ n ltnSn: n < n.+1 leqnSn: n ≤ n.+1 leq trans: m ≤ p ⇒ p ≤ n ⇒ m ≤ n transitivity ltn trans: m < p ⇒ p < n ⇒ m < n leq ltn trans: m ≤ p ⇒ p < n ⇒ m < n

But actually rewriting rules!

Laurence Rideau Librairy overview - a first guided tour

slide-22
SLIDE 22

numbers Finite nat div prime binomial

div

Divisibility for natural numbers

Operators:

”%/” (divn) quotient ”%%” (modn) remainder ”%|” (dvdn) divisor predicate

Laurence Rideau Librairy overview - a first guided tour

slide-23
SLIDE 23

numbers Finite nat div prime binomial

div

Divisibility for natural numbers

Operators:

”%/” (divn) quotient ”%%” (modn) remainder ”%|” (dvdn) divisor predicate

Some properties:

divn eq: m = (m %/ d) ∗ d + (m %% d) dvdn eq: (d %| m) = ((m %/ d) ∗ d == m)

Laurence Rideau Librairy overview - a first guided tour

slide-24
SLIDE 24

numbers Finite nat div prime binomial

div

More definitions

Definitions using divisibility:

gcdn A function computing the gcd of 2 numbers coprime Definition coprime m n := gcdn m n == 1.

Laurence Rideau Librairy overview - a first guided tour

slide-25
SLIDE 25

numbers Finite nat div prime binomial

div

More definitions

Definitions using divisibility:

gcdn A function computing the gcd of 2 numbers coprime Definition coprime m n := gcdn m n == 1.

The chinese remainder theorem Lemma chinese: forall x y, (x == y %[mod m1 * m2]) = (x == y %[mod m1]) && (x == y %[mod m2]).

Laurence Rideau Librairy overview - a first guided tour

slide-26
SLIDE 26

numbers Finite nat div prime binomial

prime

prime p p is a prime. primes m the sorted list of prime divisors of m > 1, else [::]. prime decomp m the list of prime factors of m > 1, sorted by primes. divisors m the sorted list of divisors of m > 0, else [::].

Laurence Rideau Librairy overview - a first guided tour

slide-27
SLIDE 27

numbers Finite nat div prime binomial

prime

prime p p is a prime. primes m the sorted list of prime divisors of m > 1, else [::]. prime decomp m the list of prime factors of m > 1, sorted by primes. divisors m the sorted list of divisors of m > 0, else [::]. Lemma dvdn_divisors : forall d m, 0 < m -> (d %| m)= (d \in divisors m).

Laurence Rideau Librairy overview - a first guided tour

slide-28
SLIDE 28

numbers Finite nat div prime binomial

prime

prime p p is a prime. primes m the sorted list of prime divisors of m > 1, else [::]. prime decomp m the list of prime factors of m > 1, sorted by primes. divisors m the sorted list of divisors of m > 0, else [::]. Lemma dvdn_divisors : forall d m, 0 < m -> (d %| m)= (d \in divisors m). Φ n the Euler totient : ♯|{i < n | i and n are coprime}|.

Laurence Rideau Librairy overview - a first guided tour

slide-29
SLIDE 29

numbers Finite nat div prime binomial

prime

prime p p is a prime. primes m the sorted list of prime divisors of m > 1, else [::]. prime decomp m the list of prime factors of m > 1, sorted by primes. divisors m the sorted list of divisors of m > 0, else [::]. Lemma dvdn_divisors : forall d m, 0 < m -> (d %| m)= (d \in divisors m). Φ n the Euler totient : ♯|{i < n | i and n are coprime}|. Lemma phi_coprime : forall m n, coprime m n -> phi (m * n)= phi m * phi n.

Laurence Rideau Librairy overview - a first guided tour

slide-30
SLIDE 30

numbers Finite nat div prime binomial

binomial

’C(n, m) the binomial coefficient choose m among n a Fixpoint definition, using the Pascal’s triangle property.

Laurence Rideau Librairy overview - a first guided tour

slide-31
SLIDE 31

numbers Finite nat div prime binomial

binomial

’C(n, m) the binomial coefficient choose m among n a Fixpoint definition, using the Pascal’s triangle property. Lemma bin_factd : forall n m, 0 < n -> ’C(n, m)= n‘! %/ (m‘! * (n - m)‘!).

Laurence Rideau Librairy overview - a first guided tour

slide-32
SLIDE 32

numbers Finite nat div prime binomial

binomial

’C(n, m) the binomial coefficient choose m among n a Fixpoint definition, using the Pascal’s triangle property. Lemma bin_factd : forall n m, 0 < n -> ’C(n, m)= n‘! %/ (m‘! * (n - m)‘!). Lemma prime_dvd_bin : forall k p, prime p -> 0 < k < p -> p %| ’C(p, k).

Laurence Rideau Librairy overview - a first guided tour

slide-33
SLIDE 33

numbers Finite seq fintype tuple finfun finset

Outline

1

Walk around in natural numbers area

2

About finite objects seq fintype tuple finfun finset

Laurence Rideau Librairy overview - a first guided tour

slide-34
SLIDE 34

numbers Finite seq fintype tuple finfun finset

seq

http://coqfinitgroup.gforge.inria.fr/ssreflect-1.3/seq.html

Laurence Rideau Librairy overview - a first guided tour

slide-35
SLIDE 35

numbers Finite seq fintype tuple finfun finset

seq

http://coqfinitgroup.gforge.inria.fr/ssreflect-1.3/seq.html

Always read the file header!

Laurence Rideau Librairy overview - a first guided tour

slide-36
SLIDE 36

numbers Finite seq fintype tuple finfun finset

fintype

Types with finitely many elements, supplying a duplicate-free sequence of all the elements.

Laurence Rideau Librairy overview - a first guided tour

slide-37
SLIDE 37

numbers Finite seq fintype tuple finfun finset

fintype

Types with finitely many elements, supplying a duplicate-free sequence of all the elements. Properties : decidable equality (eqtype), countable, choice.

Laurence Rideau Librairy overview - a first guided tour

slide-38
SLIDE 38

numbers Finite seq fintype tuple finfun finset

fintype

Types with finitely many elements, supplying a duplicate-free sequence of all the elements. Properties : decidable equality (eqtype), countable, choice. Functions: ”card”, ”enum”, ”pick”.

Laurence Rideau Librairy overview - a first guided tour

slide-39
SLIDE 39

numbers Finite seq fintype tuple finfun finset

fintype

Types with finitely many elements, supplying a duplicate-free sequence of all the elements. Properties : decidable equality (eqtype), countable, choice. Functions: ”card”, ”enum”, ”pick”. boolean version of quantifiers: forallb and existb with their reflection lemma forallP and existP

Laurence Rideau Librairy overview - a first guided tour

slide-40
SLIDE 40

numbers Finite seq fintype tuple finfun finset

Ordinals

Fintype of natural numbers: ”’I n” is {k | k < n}. Ordinal lt_i_n the element of ’I_n with (nat) value i

  • rd_enum n

enumeration is 0, ..., n.-1

Laurence Rideau Librairy overview - a first guided tour

slide-41
SLIDE 41

numbers Finite seq fintype tuple finfun finset

Ordinals

Fintype of natural numbers: ”’I n” is {k | k < n}. Ordinal lt_i_n the element of ’I_n with (nat) value i

  • rd_enum n

enumeration is 0, ..., n.-1 ’I_n coerces to nat integer arithmetic available

Laurence Rideau Librairy overview - a first guided tour

slide-42
SLIDE 42

numbers Finite seq fintype tuple finfun finset

Ordinals

Fintype of natural numbers: ”’I n” is {k | k < n}. Ordinal lt_i_n the element of ’I_n with (nat) value i

  • rd_enum n

enumeration is 0, ..., n.-1 ’I_n coerces to nat integer arithmetic available

  • rd0

Laurence Rideau Librairy overview - a first guided tour

slide-43
SLIDE 43

numbers Finite seq fintype tuple finfun finset

Ordinals

Fintype of natural numbers: ”’I n” is {k | k < n}. Ordinal lt_i_n the element of ’I_n with (nat) value i

  • rd_enum n

enumeration is 0, ..., n.-1 ’I_n coerces to nat integer arithmetic available

  • rd0

lshift : ’I_n -> ’I_(m + n) same value rshift : ’I_n -> ’I_(m + n) value i + m.

Laurence Rideau Librairy overview - a first guided tour

slide-44
SLIDE 44

numbers Finite seq fintype tuple finfun finset

Ordinals

Fintype of natural numbers: ”’I n” is {k | k < n}. Ordinal lt_i_n the element of ’I_n with (nat) value i

  • rd_enum n

enumeration is 0, ..., n.-1 ’I_n coerces to nat integer arithmetic available

  • rd0

lshift : ’I_n -> ’I_(m + n) same value rshift : ’I_n -> ’I_(m + n) value i + m. split : ’I_(m + n) -> ’I_m + ’I_n unsplit : ’I_m + ’I_n -> ’I_(m + n)

Laurence Rideau Librairy overview - a first guided tour

slide-45
SLIDE 45

numbers Finite seq fintype tuple finfun finset

tuple

Lists with a fixed (known) length n.-tuple T the type of n-tuples of elements of type T. a sequence s with the proof that (size s = n).

Laurence Rideau Librairy overview - a first guided tour

slide-46
SLIDE 46

numbers Finite seq fintype tuple finfun finset

tuple

Lists with a fixed (known) length n.-tuple T the type of n-tuples of elements of type T. a sequence s with the proof that (size s = n). Coerces to (seq T), (i.e. all operations for seq (size, nth, ...) are available)

Laurence Rideau Librairy overview - a first guided tour

slide-47
SLIDE 47

numbers Finite seq fintype tuple finfun finset

tuple

Lists with a fixed (known) length n.-tuple T the type of n-tuples of elements of type T. a sequence s with the proof that (size s = n). Coerces to (seq T), (i.e. all operations for seq (size, nth, ...) are available) [tuple x1; ..; xn] the explicit n.-tuple <x1; ..; xn>.

Laurence Rideau Librairy overview - a first guided tour

slide-48
SLIDE 48

numbers Finite seq fintype tuple finfun finset

tuple

Lists with a fixed (known) length n.-tuple T the type of n-tuples of elements of type T. a sequence s with the proof that (size s = n). Coerces to (seq T), (i.e. all operations for seq (size, nth, ...) are available) [tuple x1; ..; xn] the explicit n.-tuple <x1; ..; xn>. [tuple of s] where s has a known size.

Laurence Rideau Librairy overview - a first guided tour

slide-49
SLIDE 49

numbers Finite seq fintype tuple finfun finset

tuple

Lists with a fixed (known) length n.-tuple T the type of n-tuples of elements of type T. a sequence s with the proof that (size s = n). Coerces to (seq T), (i.e. all operations for seq (size, nth, ...) are available) [tuple x1; ..; xn] the explicit n.-tuple <x1; ..; xn>. [tuple of s] where s has a known size. A central element for the definition of finite functions!

Laurence Rideau Librairy overview - a first guided tour

slide-50
SLIDE 50

numbers Finite seq fintype tuple finfun finset

finfun

{ffun aT -> rT} : Type for functions (aT -> rT) where aT is a finType structure.

Laurence Rideau Librairy overview - a first guided tour

slide-51
SLIDE 51

numbers Finite seq fintype tuple finfun finset

finfun

{ffun aT -> rT} : Type for functions (aT -> rT) where aT is a finType structure. A finfun is given by his graph: #|aT|. − tupleT.

Laurence Rideau Librairy overview - a first guided tour

slide-52
SLIDE 52

numbers Finite seq fintype tuple finfun finset

finfun

{ffun aT -> rT} : Type for functions (aT -> rT) where aT is a finType structure. A finfun is given by his graph: #|aT|. − tupleT. [ffun x => expr] to build the finfun associated to (fun x => expr)

Laurence Rideau Librairy overview - a first guided tour

slide-53
SLIDE 53

numbers Finite seq fintype tuple finfun finset

finfun

{ffun aT -> rT} : Type for functions (aT -> rT) where aT is a finType structure. A finfun is given by his graph: #|aT|. − tupleT. [ffun x => expr] to build the finfun associated to (fun x => expr) Lemma fgraph_map : forall f : fT, fgraph f = [tuple of map f (enum aT)].

Laurence Rideau Librairy overview - a first guided tour

slide-54
SLIDE 54

numbers Finite seq fintype tuple finfun finset

finfun

{ffun aT -> rT} : Type for functions (aT -> rT) where aT is a finType structure. A finfun is given by his graph: #|aT|. − tupleT. [ffun x => expr] to build the finfun associated to (fun x => expr) Lemma fgraph_map : forall f : fT, fgraph f = [tuple of map f (enum aT)]. Lemma ffunE : forall f : aT -> rT, finfun f =1 f.

Laurence Rideau Librairy overview - a first guided tour

slide-55
SLIDE 55

numbers Finite seq fintype tuple finfun finset

finset

Sets over a finite Type The finsets are finite functions with boolean values.

Laurence Rideau Librairy overview - a first guided tour

slide-56
SLIDE 56

numbers Finite seq fintype tuple finfun finset

finset

Type of finsets: {set T} where T has a finType structure.

Laurence Rideau Librairy overview - a first guided tour

slide-57
SLIDE 57

numbers Finite seq fintype tuple finfun finset

finset

Type of finsets: {set T} where T has a finType structure. the type {set T} itself is equipped with a finType structure ⇒ we get equality, and we can form {set {set T}}

Laurence Rideau Librairy overview - a first guided tour

slide-58
SLIDE 58

numbers Finite seq fintype tuple finfun finset

finset

Type of finsets: {set T} where T has a finType structure. the type {set T} itself is equipped with a finType structure ⇒ we get equality, and we can form {set {set T}} x \in A , mem A x belonging predicate

Laurence Rideau Librairy overview - a first guided tour

slide-59
SLIDE 59

numbers Finite seq fintype tuple finfun finset

finset

Type of finsets: {set T} where T has a finType structure. the type {set T} itself is equipped with a finType structure ⇒ we get equality, and we can form {set {set T}} x \in A , mem A x belonging predicate [set x | C] the set of x such that C holds [set x1; ..; xn] the explicit set <x1; ..; xn>.

Laurence Rideau Librairy overview - a first guided tour

slide-60
SLIDE 60

numbers Finite seq fintype tuple finfun finset

finset

Type of finsets: {set T} where T has a finType structure. the type {set T} itself is equipped with a finType structure ⇒ we get equality, and we can form {set {set T}} x \in A , mem A x belonging predicate [set x | C] the set of x such that C holds [set x1; ..; xn] the explicit set <x1; ..; xn>. set0 the empty set A :|: B , A :&: B , A :\: B, ~: A Union, Intersection, Difference and Complement x |: A , A \: x add, remove an element

Laurence Rideau Librairy overview - a first guided tour

slide-61
SLIDE 61

numbers Finite seq fintype tuple finfun finset

finset

Type of finsets: {set T} where T has a finType structure. the type {set T} itself is equipped with a finType structure ⇒ we get equality, and we can form {set {set T}} x \in A , mem A x belonging predicate [set x | C] the set of x such that C holds [set x1; ..; xn] the explicit set <x1; ..; xn>. set0 the empty set A :|: B , A :&: B , A :\: B, ~: A Union, Intersection, Difference and Complement x |: A , A \: x add, remove an element and a lot of lemmas (!! naming conventions at the end of the file header !!)

Laurence Rideau Librairy overview - a first guided tour