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

SSReflect - Logics & Basic tactics Laurence Rideau 12 March MAP INTERNATIONAL SPRING SCH L ON FORMALIZATION OF MATHEMATICS 2012 SOPHIA ANTIPOLIS, FRANCE / 12-16 MARCH SSR Tactics Structure SSReflect Reminder (SSR = Small Scale


slide-1
SLIDE 1

L ON FORMALIZATION OF SPRING SCH

SOPHIA ANTIPOLIS, FRANCE / 12-16 MARCH

MATHEMATICS 2012 MAP INTERNATIONAL

SSReflect - Logics & Basic tactics

Laurence Rideau 12 March

slide-2
SLIDE 2

SSR Tactics Structure

SSReflect – Reminder

(SSR = Small Scale Reflection)

SSReflect: extension of Coq developed while formalizing the Four Color Theorem (2004), now used for the Odd Order Theorem.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-3
SLIDE 3

SSR Tactics Structure

SSReflect – Reminder

(SSR = Small Scale Reflection)

SSReflect: extension of Coq developed while formalizing the Four Color Theorem (2004), now used for the Odd Order Theorem. Changes with standard Coq: Vernacular (Commands) and Gallina are mostly unchanged (e.g., Definition, Lemma, forall, match with); standard tactics are still available some tactics are superseded (e.g., apply, rewrite) new libraries are provided (e.g., nat, seq)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-4
SLIDE 4

SSR Tactics Structure

Design Decisions

Simplify and generalize the syntax of tactics.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-5
SLIDE 5

SSR Tactics Structure

Design Decisions

Simplify and generalize the syntax of tactics. Add some ways to structure the scripts, so that breakages are easier to understand.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-6
SLIDE 6

SSR Tactics Structure

Design Decisions

Simplify and generalize the syntax of tactics. Add some ways to structure the scripts, so that breakages are easier to understand. Force the user to explicitly name things.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-7
SLIDE 7

SSR Tactics Structure

Design Decisions

Simplify and generalize the syntax of tactics. Add some ways to structure the scripts, so that breakages are easier to understand. Force the user to explicitly name things. Ease the use of boolean reflection.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-8
SLIDE 8

SSR Tactics Structure

Outline

1

Logics

2

Tactics, Tacticals

3

Proof Structure

Laurence Rideau SSReflect - Logics & Basic tactics

slide-9
SLIDE 9

SSR Tactics Structure FOL Bool

Outline

1

Logics First Order Logic Booleans

2

Tactics, Tacticals

3

Proof Structure

Laurence Rideau SSReflect - Logics & Basic tactics

slide-10
SLIDE 10

SSR Tactics Structure FOL Bool

Minimal Propositional Logic

Propositional variables: P Q R . . . Propositions: (even 4) (x < 10) (7 <= 2) Implication: -> Formulas: (P -> Q) -> (Q -> R) -> P -> R

Laurence Rideau SSReflect - Logics & Basic tactics

slide-11
SLIDE 11

SSR Tactics Structure FOL Bool

Minimal Propositional Logic

Propositional variables: P Q R . . . Propositions: (even 4) (x < 10) (7 <= 2) Implication: -> Formulas: (P -> Q) -> (Q -> R) -> P -> R Propositional are of sort Prop : (P : Prop). Declaring variables: Variables P Q R :Prop.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-12
SLIDE 12

SSR Tactics Structure FOL Bool

Minimal Propositional Logic

Propositional variables: P Q R . . . Propositions: (even 4) (x < 10) (7 <= 2) Implication: -> Formulas: (P -> Q) -> (Q -> R) -> P -> R Propositional are of sort Prop : (P : Prop). Declaring variables: Variables P Q R :Prop. Any term of type P (p : P) is a proof of P.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-13
SLIDE 13

SSR Tactics Structure FOL Bool

State and Proof a theorem

Lemma imp_trans :(P -> Q) -> (Q -> R) -> P -> R.

  • Proof. (* start the proof of a Lemma *)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-14
SLIDE 14

SSR Tactics Structure FOL Bool

State and Proof a theorem

Lemma imp_trans :(P -> Q) -> (Q -> R) -> P -> R.

  • Proof. (* start the proof of a Lemma *)

. . . P : Prop Q : Prop R : Prop          named hypotheses (Context) (P → Q) → (Q → R) → P → R } current goal

  • Assumptions

Conclusion

Laurence Rideau SSReflect - Logics & Basic tactics

slide-15
SLIDE 15

SSR Tactics Structure FOL Bool

State and Proof a theorem

Lemma imp_trans :(P -> Q) -> (Q -> R) -> P -> R.

  • Proof. (* start the proof of a Lemma *)

. . . P : Prop Q : Prop R : Prop          named hypotheses (Context) (P → Q) → (Q → R) → P → R } current goal

  • Assumptions

Conclusion Tactic: any operation that allows the simplification, decomposition into subgoals, or resolution of a goal.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-16
SLIDE 16

SSR Tactics Structure FOL Bool

Proof

Theorem command: Lemma imp_trans :(P -> Q) -> (Q -> R) -> P -> R.

  • Proof. (* start the proof of a Lemma *)

move=> Hpq.

P : Prop Q : Prop R : Prop Hpq : (P → Q) (Q → R) → P → R

Laurence Rideau SSReflect - Logics & Basic tactics

slide-17
SLIDE 17

SSR Tactics Structure FOL Bool

Proof

Theorem command: Lemma imp_trans :(P -> Q) -> (Q -> R) -> P -> R.

  • Proof. (* start the proof of a Lemma *)

move=> Hpq Hqr p.

P : Prop Q : Prop R : Prop Hpq : (P → Q) Hqr : (Q → R) p : P R

Laurence Rideau SSReflect - Logics & Basic tactics

slide-18
SLIDE 18

SSR Tactics Structure FOL Bool

Proof

Theorem command: Lemma imp_trans :(P -> Q) -> (Q -> R) -> P -> R.

  • Proof. (* start the proof of a Lemma *)

move=> Hpq Hqr p. apply: Hqr.

P : Prop Q : Prop R : Prop Hpq : (P → Q) p : P Q

Laurence Rideau SSReflect - Logics & Basic tactics

slide-19
SLIDE 19

SSR Tactics Structure FOL Bool

Proof

Theorem command: Lemma imp_trans :(P -> Q) -> (Q -> R) -> P -> R.

  • Proof. (* start the proof of a Lemma *)

move=> Hpq Hqr p. apply: Hqr. apply: (Hpq).

P : Prop Q : Prop R : Prop Hpq : (P → Q) p : P P

Laurence Rideau SSReflect - Logics & Basic tactics

slide-20
SLIDE 20

SSR Tactics Structure FOL Bool

Proof

Theorem command: Lemma imp_trans :(P -> Q) -> (Q -> R) -> P -> R.

  • Proof. (* start the proof of a Lemma *)

move=> Hpq Hqr p. apply: Hqr. apply: Hpq. exact: p.

Proof completed.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-21
SLIDE 21

SSR Tactics Structure FOL Bool

Proof

Theorem command: Lemma imp_trans :(P -> Q) -> (Q -> R) -> P -> R.

  • Proof. (* start the proof of a Lemma *)

move=> Hpq Hqr p. apply: Hqr. exact: (Hpq p).

Proof completed.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-22
SLIDE 22

SSR Tactics Structure FOL Bool

Proof

Theorem command: Lemma imp_trans :(P -> Q) -> (Q -> R) -> P -> R.

  • Proof. (* start the proof of a Lemma *)

move=> Hpq Hqr p. apply: Hqr. exact: (Hpq p). Qed.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-23
SLIDE 23

SSR Tactics Structure FOL Bool

Minimal Propositional Logic with universal quantifier

forall (P Q R :Prop), (P ->Q)-> (Q -> R) -> P -> R

Laurence Rideau SSReflect - Logics & Basic tactics

slide-24
SLIDE 24

SSR Tactics Structure FOL Bool

Minimal Propositional Logic with universal quantifier

forall (P Q R :Prop), (P ->Q)-> (Q -> R) -> P -> R as a goal: move=> P Q R.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-25
SLIDE 25

SSR Tactics Structure FOL Bool

Minimal Propositional Logic with universal quantifier

forall (P Q R :Prop), (P ->Q)-> (Q -> R) -> P -> R as a goal: move=> P Q R. as an hypothesis named H: apply: H. apply: (H A B). or . . .

Laurence Rideau SSReflect - Logics & Basic tactics

slide-26
SLIDE 26

SSR Tactics Structure FOL Bool

Minimal Propositional Logic with universal quantifier

forall (P Q R :Prop), (P ->Q)-> (Q -> R) -> P -> R as a goal: move=> P Q R. as an hypothesis named H: apply: H. apply: (H A B). or . . . forall n:nat, 0 <= n

Laurence Rideau SSReflect - Logics & Basic tactics

slide-27
SLIDE 27

SSR Tactics Structure FOL Bool

Minimal Propositional Logic with universal quantifier

forall (P Q R :Prop), (P ->Q)-> (Q -> R) -> P -> R as a goal: move=> P Q R. as an hypothesis named H: apply: H. apply: (H A B). or . . . forall n:nat, 0 <= n move=> n.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-28
SLIDE 28

SSR Tactics Structure FOL Bool

Minimal Propositional Logic with universal quantifier

forall (P Q R :Prop), (P ->Q)-> (Q -> R) -> P -> R as a goal: move=> P Q R. as an hypothesis named H: apply: H. apply: (H A B). or . . . forall n:nat, 0 <= n move=> n. apply: H. apply: (H a).

Laurence Rideau SSReflect - Logics & Basic tactics

slide-29
SLIDE 29

SSR Tactics Structure FOL Bool

Propositional Logic, Conjunction

Conjunction : A /\ B

Laurence Rideau SSReflect - Logics & Basic tactics

slide-30
SLIDE 30

SSR Tactics Structure FOL Bool

Propositional Logic, Conjunction

Conjunction : A /\ B

case: ab. (* Break the (ab : A /\ B) hypothesis *)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-31
SLIDE 31

SSR Tactics Structure FOL Bool

Propositional Logic, Conjunction

Conjunction : A /\ B

case: ab. (* Break the (ab : A /\ B) hypothesis *) ab : A /\ B G → A -> B -> G

Laurence Rideau SSReflect - Logics & Basic tactics

slide-32
SLIDE 32

SSR Tactics Structure FOL Bool

Propositional Logic, Conjunction

Conjunction : A /\ B

case: ab. (* Break the (ab : A /\ B) hypothesis *) ab : A /\ B G → A -> B -> G

  • split. (* Prove a conjunction :A /\B *)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-33
SLIDE 33

SSR Tactics Structure FOL Bool

Propositional Logic, Conjunction

Conjunction : A /\ B

case: ab. (* Break the (ab : A /\ B) hypothesis *) ab : A /\ B G → A -> B -> G

  • split. (* Prove a conjunction :A /\B *)

A /\ B → A B

Laurence Rideau SSReflect - Logics & Basic tactics

slide-34
SLIDE 34

SSR Tactics Structure FOL Bool

Propositional Logic, Disjunction

Disjunction : A \/ B

Laurence Rideau SSReflect - Logics & Basic tactics

slide-35
SLIDE 35

SSR Tactics Structure FOL Bool

Propositional Logic, Disjunction

Disjunction : A \/ B

case: ab. (* Break the (ab : A \/ B) hypothesis *)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-36
SLIDE 36

SSR Tactics Structure FOL Bool

Propositional Logic, Disjunction

Disjunction : A \/ B

case: ab. (* Break the (ab : A \/ B) hypothesis *) ab : A \/ B G → A -> G B -> G

Laurence Rideau SSReflect - Logics & Basic tactics

slide-37
SLIDE 37

SSR Tactics Structure FOL Bool

Propositional Logic, Disjunction

Disjunction : A \/ B

case: ab. (* Break the (ab : A \/ B) hypothesis *) ab : A \/ B G → A -> G B -> G

  • left. (* Prove a disjunction :A \/ B *)

(* by choosing the left part *)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-38
SLIDE 38

SSR Tactics Structure FOL Bool

Propositional Logic, Disjunction

Disjunction : A \/ B

case: ab. (* Break the (ab : A \/ B) hypothesis *) ab : A \/ B G → A -> G B -> G

  • left. (* Prove a disjunction :A \/ B *)

(* by choosing the left part *) A \/ B → A

Laurence Rideau SSReflect - Logics & Basic tactics

slide-39
SLIDE 39

SSR Tactics Structure FOL Bool

Propositional Logic, Disjunction

Disjunction : A \/ B

case: ab. (* Break the (ab : A \/ B) hypothesis *) ab : A \/ B G → A -> G B -> G

  • left. (* Prove a disjunction :A \/ B *)

(* by choosing the left part *) A \/ B → A

  • right. (* Prove a disjunction :A \/ B *)

(* by choosing the right part *)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-40
SLIDE 40

SSR Tactics Structure FOL Bool

Propositional Logic, Negation

Negation : ~B

Laurence Rideau SSReflect - Logics & Basic tactics

slide-41
SLIDE 41

SSR Tactics Structure FOL Bool

Propositional Logic, Negation

Negation : ~B

~B is defined as (B -> False)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-42
SLIDE 42

SSR Tactics Structure FOL Bool

Propositional Logic, Negation

Negation : ~B

~B is defined as (B -> False) move=> B. (* To prove the goal (~B)*)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-43
SLIDE 43

SSR Tactics Structure FOL Bool

Propositional Logic, Negation

Negation : ~B

~B is defined as (B -> False) move=> B. (* To prove the goal (~B)*) . . . ~B → b : B False

Laurence Rideau SSReflect - Logics & Basic tactics

slide-44
SLIDE 44

SSR Tactics Structure FOL Bool

Propositional Logic, Negation

Negation : ~B

~B is defined as (B -> False) move=> B. (* To prove the goal (~B)*) . . . ~B → b : B False Then apply: H. (* for a (H :~C) in the context*)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-45
SLIDE 45

SSR Tactics Structure FOL Bool

Existential Quantifier

Existential: exists n:nat, P n

(* P is a predicate on nat (P :nat ->Prop)*)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-46
SLIDE 46

SSR Tactics Structure FOL Bool

Existential Quantifier

Existential: exists n:nat, P n

(* P is a predicate on nat (P :nat ->Prop)*) exists 2. (*To prove an exists, give a witness *)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-47
SLIDE 47

SSR Tactics Structure FOL Bool

Existential Quantifier

Existential: exists n:nat, P n

(* P is a predicate on nat (P :nat ->Prop)*) exists 2. (*To prove an exists, give a witness *)

. . .

exists n:nat, P n

→ . . .

P 2

Laurence Rideau SSReflect - Logics & Basic tactics

slide-48
SLIDE 48

SSR Tactics Structure FOL Bool

Existential Quantifier

Existential: exists n:nat, P n

(* P is a predicate on nat (P :nat ->Prop)*) exists 2. (*To prove an exists, give a witness *)

. . .

exists n:nat, P n

→ . . .

P 2 case: Hex. (* To break the (Hex:exists n, P n)hypothesis *) (* combined with (move=>n Hn.)*)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-49
SLIDE 49

SSR Tactics Structure FOL Bool

Existential Quantifier

Existential: exists n:nat, P n

(* P is a predicate on nat (P :nat ->Prop)*) exists 2. (*To prove an exists, give a witness *)

. . .

exists n:nat, P n

→ . . .

P 2 case: Hex. (* To break the (Hex:exists n, P n)hypothesis *) (* combined with (move=>n Hn.)*) Hex: exists n, P n G

n : nat Hn : P n

G

Laurence Rideau SSReflect - Logics & Basic tactics

slide-50
SLIDE 50

SSR Tactics Structure FOL Bool

Outline

1

Logics First Order Logic Booleans

2

Tactics, Tacticals

3

Proof Structure

Laurence Rideau SSReflect - Logics & Basic tactics

slide-51
SLIDE 51

SSR Tactics Structure FOL Bool

Booleans

Inductive bool := true | false.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-52
SLIDE 52

SSR Tactics Structure FOL Bool

Booleans

Inductive bool := true | false.

Operators: ”&&”, ”||”, ”~~”, ”==>”, ”(+)”.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-53
SLIDE 53

SSR Tactics Structure FOL Bool

Booleans

Inductive bool := true | false.

Operators: ”&&”, ”||”, ”~~”, ”==>”, ”(+)”. b1 b2 b1 && b2 b1 || b2 b1 ==> b2 b1 (+) b2 T T T T T F T F F T F T F T F T T T F F F F T F

Laurence Rideau SSReflect - Logics & Basic tactics

slide-54
SLIDE 54

SSR Tactics Structure FOL Bool

Booleans

Inductive bool := true | false.

Operators: ”&&”, ”||”, ”~~”, ”==>”, ”(+)”. Some notations

"[ && b1 , b2 , .. , bn & c ]" := (b1 && (b2 && .. (bn && c).. )) "[ || b1 , b2 , .. , bn | c ]" := (b1 || (b2 || .. (bn || c).. ))

Laurence Rideau SSReflect - Logics & Basic tactics

slide-55
SLIDE 55

SSR Tactics Structure FOL Bool

Booleans

Inductive bool := true | false.

Operators: ”&&”, ”||”, ”~~”, ”==>”, ”(+)”. is true : bool -> Prop.

fun b : bool => b = true. Notation : "x ’is_true’" := (is_true x)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-56
SLIDE 56

SSR Tactics Structure FOL Bool

Booleans in proofs

Reason by case on a boolean:

case: a.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-57
SLIDE 57

SSR Tactics Structure FOL Bool

Booleans in proofs

Reason by case on a boolean:

case: a.

. . . a : bool b : bool

a (+) b = (a && ~~b)|| (~~a && b)

→ . . . b : bool

true (+)b = (true && ~~b)|| (~~true && b)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-58
SLIDE 58

SSR Tactics Structure FOL Bool

Booleans in proofs

Reason by case on a boolean:

case: a.

. . . a : bool b : bool

a (+) b = (a && ~~b)|| (~~a && b)

→ . . . b : bool

true (+)b = (true && ~~b)|| (~~true && b)

. . . b : bool

false (+)b = (false && ~~b)|| (~~false && b)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-59
SLIDE 59

SSR Tactics Structure FOL Bool

Booleans in proofs(2)

Compute, simplify:

rewrite /=.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-60
SLIDE 60

SSR Tactics Structure FOL Bool

Booleans in proofs(2)

Compute, simplify:

rewrite /=.

. . . b : bool

true (+)b = (true && ~~ b)|| (~~ true && b)

→ . . . b : bool

~~ b = ~~ b || false

Laurence Rideau SSReflect - Logics & Basic tactics

slide-61
SLIDE 61

SSR Tactics Structure

Outline

1

Logics First Order Logic Booleans

2

Tactics, Tacticals

3

Proof Structure Forward reasoning Proof control flow Subgoal selectors

Laurence Rideau SSReflect - Logics & Basic tactics

slide-62
SLIDE 62

SSR Tactics Structure

Tactics / Tacticals

Tactic: any operation that allows the simplification, decomposition into subgoals, or resolution of a goal. Tactical: any function of tactics (eg. ; the composition of two tactics).

Laurence Rideau SSReflect - Logics & Basic tactics

slide-63
SLIDE 63

SSR Tactics Structure

Tactics and Tacticals

move=> by tactical apply: exact: case: elim: rewrite

Laurence Rideau SSReflect - Logics & Basic tactics

slide-64
SLIDE 64

SSR Tactics Structure

Introduction Tactic

move=> a b c.

pops the top 3 elements of the goal, and it puts them into the context with names a, b, and c.

move=> _.

pops the first top element of the goal, without putting it in the context.

move=> a _ c.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-65
SLIDE 65

SSR Tactics Structure

Tactical by and Tactics apply / exact

”by []” tries to solve the current goal by some trivial means; it fails if it doesn’t succeed.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-66
SLIDE 66

SSR Tactics Structure

Tactical by and Tactics apply / exact

”by []” tries to solve the current goal by some trivial means; it fails if it doesn’t succeed. ”by any tactic” applies the argument tactic, then tries to solve the current goal. ”apply: H” applies H to the goal.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-67
SLIDE 67

SSR Tactics Structure

Tactical by and Tactics apply / exact

”by []” tries to solve the current goal by some trivial means; it fails if it doesn’t succeed. ”by any tactic” applies the argument tactic, then tries to solve the current goal. ”apply: H” applies H to the goal. . . . H: P -> Q Q → . . . P

Laurence Rideau SSReflect - Logics & Basic tactics

slide-68
SLIDE 68

SSR Tactics Structure

Tactical by and Tactics apply / exact

”by []” tries to solve the current goal by some trivial means; it fails if it doesn’t succeed. ”by any tactic” applies the argument tactic, then tries to solve the current goal. ”apply: H” applies H to the goal. . . . H: P -> Q Q → . . . P "exact:H” performs ”by apply: H”

Laurence Rideau SSReflect - Logics & Basic tactics

slide-69
SLIDE 69

SSR Tactics Structure

Tactics case: / elim:

Performs a case analysis / inductive elimination on the element given as an argument.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-70
SLIDE 70

SSR Tactics Structure

Tactics case: / elim:

Performs a case analysis / inductive elimination on the element given as an argument.

Inductive nat := O | S of nat

Laurence Rideau SSReflect - Logics & Basic tactics

slide-71
SLIDE 71

SSR Tactics Structure

Tactics case: / elim:

Performs a case analysis / inductive elimination on the element given as an argument.

Inductive nat := O | S of nat Lemma P_of_n forall n : nat , P n. move=>n.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-72
SLIDE 72

SSR Tactics Structure

Tactics case: / elim:

Performs a case analysis / inductive elimination on the element given as an argument.

Inductive nat := O | S of nat Lemma P_of_n forall n : nat , P n. move=>n. case:n.

1. P 0 2. forall n : nat, P (S n)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-73
SLIDE 73

SSR Tactics Structure

Tactics case: / elim:

Performs a case analysis / inductive elimination on the element given as an argument.

Inductive nat := O | S of nat Lemma P_of_n forall n : nat , P n. move=>n. elim:n.

1. P 0 2. forall n, P n -> P (S n)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-74
SLIDE 74

SSR Tactics Structure

Basic Rewriting tactic

Tactic ”rewrite items . . .” modifies subterms of the goal: ”/name” unfolds a definition ”-/name” folds a definition ”term” rewrites (left to right) with a lemma or an hypothesis which conclusion is an equality

Laurence Rideau SSReflect - Logics & Basic tactics

slide-75
SLIDE 75

SSR Tactics Structure

Basic Rewriting tactic

Tactic ”rewrite items . . .” modifies subterms of the goal: ”/name” unfolds a definition ”-/name” folds a definition ”term” rewrites (left to right) with a lemma or an hypothesis which conclusion is an equality

Eqab: a = b

P a →

Eqab: a = b

P b

Laurence Rideau SSReflect - Logics & Basic tactics

slide-76
SLIDE 76

SSR Tactics Structure

Basic Rewriting tactic

Tactic ”rewrite items . . .” modifies subterms of the goal: ”/name” unfolds a definition ”-/name” folds a definition ”term” rewrites (left to right) with a lemma or an hypothesis which conclusion is an equality

Eqab: a = b

P a →

Eqab: a = b

P b ”-term” rewrites right to left

Laurence Rideau SSReflect - Logics & Basic tactics

slide-77
SLIDE 77

SSR Tactics Structure

Multiple Rewriting and Occurrence selection

rewrite -multiplicityterm ”?”: as many times as possible, possibly none, ”!”: as many times as possible, at least once, ”n?”: at most n times, ”n!”: exactly n times.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-78
SLIDE 78

SSR Tactics Structure

Multiple Rewriting and Occurrence selection

rewrite -multiplicityterm ”?”: as many times as possible, possibly none, ”!”: as many times as possible, at least once, ”n?”: at most n times, ”n!”: exactly n times. rewrite -{number}term

Laurence Rideau SSReflect - Logics & Basic tactics

slide-79
SLIDE 79

SSR Tactics Structure

Multiple Rewriting and Occurrence selection

rewrite -multiplicityterm ”?”: as many times as possible, possibly none, ”!”: as many times as possible, at least once, ”n?”: at most n times, ”n!”: exactly n times. rewrite -{number}term

Lemma dbl a b : 2 * (a + b) = (b + a) + (a + b).

Laurence Rideau SSReflect - Logics & Basic tactics

slide-80
SLIDE 80

SSR Tactics Structure

Multiple Rewriting and Occurrence selection

rewrite -multiplicityterm ”?”: as many times as possible, possibly none, ”!”: as many times as possible, at least once, ”n?”: at most n times, ”n!”: exactly n times. rewrite -{number}term

Lemma dbl a b : 2 * (a + b) = (b + a) + (a + b). Proof.

a : nat b : nat 2 * (a + b) = (b + a) + (a + b)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-81
SLIDE 81

SSR Tactics Structure

Multiple Rewriting and Occurrence selection

rewrite -multiplicityterm ”?”: as many times as possible, possibly none, ”!”: as many times as possible, at least once, ”n?”: at most n times, ”n!”: exactly n times. rewrite -{number}term

Lemma dbl a b : 2 * (a + b) = (b + a) + (a + b). rewrite

  • !addnA.

a : nat b : nat 2 * (a + b) = b + (a + (a + b))

Laurence Rideau SSReflect - Logics & Basic tactics

slide-82
SLIDE 82

SSR Tactics Structure

Multiple Rewriting and Occurrence selection

rewrite -multiplicityterm ”?”: as many times as possible, possibly none, ”!”: as many times as possible, at least once, ”n?”: at most n times, ”n!”: exactly n times. rewrite -{number}term

Lemma dbl a b : 2 * (a + b) = (b + a) + (a + b). rewrite {2} addnC.

a : nat b : nat 2 * (a + b) = (b + a) + (b + a)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-83
SLIDE 83

SSR Tactics Structure

Multiple Rewriting and Occurrence selection

rewrite -multiplicityterm ”?”: as many times as possible, possibly none, ”!”: as many times as possible, at least once, ”n?”: at most n times, ”n!”: exactly n times. rewrite -{number}term

Lemma dbl a b : 2 * (a + b) = (b + a) + (a + b). rewrite

  • !addnA {2} addnC.

a : nat b : nat 2 * (a + b) = (b + (a + (b + a)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-84
SLIDE 84

SSR Tactics Structure Forward Control flow Subgoals

Outline

1

Logics

2

Tactics, Tacticals

3

Proof Structure Forward reasoning Proof control flow Subgoal selectors

Laurence Rideau SSReflect - Logics & Basic tactics

slide-85
SLIDE 85

SSR Tactics Structure Forward Control flow Subgoals

Forward Reasoning

have suffices (suff)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-86
SLIDE 86

SSR Tactics Structure Forward Control flow Subgoals

Forward Reasoning: have / suffices

have H : intermediate goal performs a logical cut.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-87
SLIDE 87

SSR Tactics Structure Forward Control flow Subgoals

Forward Reasoning: have / suffices

have H : intermediate goal performs a logical cut.

Variable f : nat -> nat. Variable P : nat -> Prop. Lemma P_of_3: P 3.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-88
SLIDE 88

SSR Tactics Structure Forward Control flow Subgoals

Forward Reasoning: have / suffices

have H : intermediate goal performs a logical cut.

Variable f : nat -> nat. Variable P : nat -> Prop. Lemma P_of_3: P 3. Proof. have H: exists x, f x = 3.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-89
SLIDE 89

SSR Tactics Structure Forward Control flow Subgoals

Forward Reasoning: have / suffices

have H : intermediate goal performs a logical cut.

Variable f : nat -> nat. Variable P : nat -> Prop. Lemma P_of_3: P 3. Proof. have H: exists x, f x = 3.

1. exists x, f x = 3 2. H: exists x, f x = 3 P 3

Laurence Rideau SSReflect - Logics & Basic tactics

slide-90
SLIDE 90

SSR Tactics Structure Forward Control flow Subgoals

Forward Reasoning: have / suffices

have H : intermediate goal performs a logical cut.

Variable f : nat -> nat. Variable P : nat -> Prop. Lemma P_of_3: P 3. Proof. have H: exists x, f x = 3.

Tactic ”suff” also performs a logical cut, but it produces the two subgoals in the opposite order.

Laurence Rideau SSReflect - Logics & Basic tactics

slide-91
SLIDE 91

SSR Tactics Structure Forward Control flow Subgoals

Proof control flow

Tabulation (depending on the number of subgoals number)

Laurence Rideau SSReflect - Logics & Basic tactics

slide-92
SLIDE 92

SSR Tactics Structure Forward Control flow Subgoals

Proof control flow

Tabulation (depending on the number of subgoals number) Bullets -, +, *

Laurence Rideau SSReflect - Logics & Basic tactics

slide-93
SLIDE 93

SSR Tactics Structure Forward Control flow Subgoals

Proof control flow

Tabulation (depending on the number of subgoals number) Bullets -, +, * Proof terminators : by , exact:

Laurence Rideau SSReflect - Logics & Basic tactics

slide-94
SLIDE 94

SSR Tactics Structure Forward Control flow Subgoals

A proof example

Laurence Rideau SSReflect - Logics & Basic tactics

slide-95
SLIDE 95

SSR Tactics Structure Forward Control flow Subgoals

Subgoal Selectors

Solving one subgoal with a single tactic:

tactic ; first by tactic tactic ; last by tactic

Laurence Rideau SSReflect - Logics & Basic tactics

slide-96
SLIDE 96

SSR Tactics Structure Forward Control flow Subgoals

Subgoal Selectors

Solving one subgoal with a single tactic:

tactic ; first by tactic tactic ; last by tactic

Changing the order of subgoals:

tactic ; first last (or last first)

Laurence Rideau SSReflect - Logics & Basic tactics