the coq proof assistant
play

The Coq proof assistant : From graphical presentation to - PowerPoint PPT Presentation

Coq J.-F. Monin Case analysis Enumerated types General case The Coq proof assistant : From graphical presentation to principles and practice Coq syntax Simple inductive definitions Case analysis Reduction of a case analysis J.-F. Monin


  1. Coq J.-F. Monin Case analysis Enumerated types General case The Coq proof assistant : From graphical presentation to principles and practice Coq syntax Simple inductive definitions Case analysis Reduction of a case analysis J.-F. Monin Functions Remarks Université Grenoble Alpes 2016 Lecture 2

  2. Outline Coq J.-F. Monin Case analysis Enumerated types Case analysis General case From graphical Enumerated types presentation to Coq syntax General case Simple inductive definitions Case analysis Reduction of a From graphical presentation to Coq syntax case analysis Simple inductive definitions Functions Case analysis Remarks Reduction of a case analysis Functions Remarks

  3. Outline Coq J.-F. Monin Case analysis Enumerated types Case analysis General case From graphical Enumerated types presentation to Coq syntax General case Simple inductive definitions Case analysis Reduction of a From graphical presentation to Coq syntax case analysis Simple inductive definitions Functions Case analysis Remarks Reduction of a case analysis Functions Remarks

  4. Definition by cases on an enumerated type Coq J.-F. Monin Case analysis Enumerated types Question General case From graphical Give a color for each possible value in rgb presentation to Coq syntax Simple inductive definitions Rf Gf Bf Case analysis rgb rgb rgb Reduction of a case analysis Functions Example Remarks Rf maps to Red , Gf maps to Green , Bf maps to Blue ↓ r Red Green Blue rgb color color color case color

  5. Definition by cases on an enumerated type Coq J.-F. Monin Case analysis Enumerated types General case Question From graphical presentation to Give a rgb for each possible value in rgb Coq syntax Simple inductive definitions Case analysis Rf Gf Bf Reduction of a rgb rgb rgb case analysis Functions Remarks Example Rf maps to Bf , Gf maps to Gf , Bf maps to Rf ↓ r Bf Gf Rf rgb rgb rgb rgb case rgb

  6. Building block Coq J.-F. Monin Case analysis Enumerated types General case In this presentation, the order of contructors matters: From graphical Rf , Gf , Bf presentation to Coq syntax The case construct is driven by 2 parameters Simple inductive definitions Case analysis ◮ the type of the value to be analyzed Reduction of a each enumerated type (e.g. rgb ) comes automatically case analysis Functions with its case construct, which should actually be Remarks written, e.g. case rgb ◮ the type of the result ↓ ↓ ↓ ↓ ↓ A r x 1 x 2 x 3 Set rgb A A A case A

  7. Correct version of previous examples Coq J.-F. Monin Case analysis Enumerated types General case From graphical presentation to Coq syntax ↓ color r R G B Simple inductive definitions Case analysis Set rgb color co co Reduction of a case case analysis color Functions Remarks ↓ rgb r Bf Gf Rf Set rgb rgb rgb rgb case rgb

  8. Definition by cases on a general inductive type Coq J.-F. Monin Case analysis Enumerated types General case From graphical presentation to Coq syntax Simple inductive definitions Case analysis Reduction of a case analysis To be introduced below... Functions Remarks

  9. Outline Coq J.-F. Monin Case analysis Enumerated types Case analysis General case From graphical Enumerated types presentation to Coq syntax General case Simple inductive definitions Case analysis Reduction of a From graphical presentation to Coq syntax case analysis Simple inductive definitions Functions Case analysis Remarks Reduction of a case analysis Functions Remarks

  10. From graphical presentation to Coq syntax Red Orange Yellow Green color color color color Blue Indigo Violet color color color color And simultaneously Set Inductive color: Set := | Red : color | Orange : color | Yellow : color | Green : color | Blue : color | Indigo : color | Violet : color .

  11. Coq syntax of tuple4 Making a 4-tuple of rgb ↓ ↓ ↓ ↓ x 1 x 2 x 3 x 4 rgb rgb rgb rgb Mk4rgb tuple4 Inductive tuple4 : Set := | Mk4rgb : forall x1: rgb, forall x2: rgb, forall x3: rgb, forall x4: rgb, tuple4

  12. Coq syntax of tuple4, shorthand Coq J.-F. Monin Case analysis Enumerated types General case From graphical Making a 4-tuple of rgb presentation to Coq syntax Simple inductive definitions Case analysis ↓ ↓ ↓ ↓ x 1 x 2 x 3 x 4 Reduction of a case analysis rgb rgb rgb rgb Mk4rgb Functions tuple4 Remarks Inductive tuple4 : Set := | Mk4rgb : forall x1 x2 x3 x4: rgb, tuple4.

  13. More general 4-tuples: several constructors Coq J.-F. Monin ↓ ↓ ↓ ↓ Case analysis x 1 x 2 x 3 x 4 Enumerated types rgb rgb rgb rgb General case Mk4rgb From graphical tuple4 presentation to Coq syntax Simple inductive definitions ↓ ↓ ↓ ↓ Case analysis x 1 x 2 x 3 x 4 Reduction of a color color color color case analysis Mk4co Functions tuple4 Remarks ↓ ↓ ↓ ↓ x 1 x 2 x 3 x 4 tuple4 tuple4 tuple4 tuple4 Mk4t4 tuple4 Inductive tuple4 : Set := | Mk4rgb : forall x1 x2 x3 x4: rgb, tuple4 | Mk4color : forall x1 x2 x3 x4: color, tuple4 | Mk4t4 : forall x1 x2 x3 x4: tuple4, tuple4 .

  14. Pluging trees: the interactive way Coq J.-F. Monin Case analysis A concrete 4-tuple of rgb Enumerated types General case From graphical presentation to Gf Rf Gf Bf Coq syntax rgb rgb rgb rgb Simple inductive definitions Mk4rgb Case analysis tuple4 Reduction of a case analysis Functions Remarks Definition t1: tuple4. apply Mk4rgb. apply Gf. apply Rf. apply Gf. apply Bf. Defined .

  15. Open trees Coq J.-F. Monin Case analysis ↓ ↓ Enumerated types Gf x 2 Rf x 4 General case rgb rgb rgb rgb From graphical Mk4rgb presentation to Coq syntax tuple4 Simple inductive definitions Case analysis In Coq Reduction of a case analysis Functions Section a_tuple_with_variable. Remarks Variable x2: rgb. Variable x4: rgb. Definition t4 etc. End a_tuple_with_variable.

  16. Exercises Coq J.-F. Monin Case analysis Enumerated types General case From graphical presentation to Coq syntax Simple inductive definitions Case analysis Write trees for examples of 4-tuples of 4-tuples using Reduction of a case analysis tuple4 . Functions Some of them, closed, some of them open Remarks E.g. �� R , Y , B , B � , � B , O , x 4 , R � , � x 7 , x 7 , x 7 , V � , � V , Y , O , R ��

  17. Definition by cases on an enumerated type Coq J.-F. Monin Case analysis Rf maps to Red , Gf maps to Green , Bf maps to Blue Enumerated types General case From graphical presentation to ↓ Coq syntax color r R G B Simple inductive definitions Set rgb color co co Case analysis case Reduction of a color case analysis Functions Remarks Definition color_of_r: color. destruct r. apply Red. apply Green. apply Blue. Defined .

  18. General case Coq J.-F. Monin Case analysis Enumerated types General case ↓ ↓ ↓ ↓ ↓ From graphical A r x 1 x 2 x 3 presentation to Set rgb A A A Coq syntax Simple inductive definitions case Case analysis A Reduction of a case analysis Functions Definition A_of_r: A. Remarks destruct r. apply x1. apply x2. apply x3. Defined .

  19. Direct definition Coq J.-F. Monin Case analysis Enumerated types General case From graphical presentation to Coq syntax Simple inductive definitions Case analysis Definition color_of_r : color := Reduction of a match r with case analysis | Rf => Red Functions | Gf => Green Remarks | Bf => Blue end.

  20. Case analysis on a tree Coq J.-F. Monin Case analysis Enumerated types General case From graphical presentation to Coq syntax Simple inductive definitions Case analysis Reduction of a case analysis See interactive session Functions Remarks

  21. Outline Coq J.-F. Monin Case analysis Enumerated types Case analysis General case From graphical Enumerated types presentation to Coq syntax General case Simple inductive definitions Case analysis Reduction of a From graphical presentation to Coq syntax case analysis Simple inductive definitions Functions Case analysis Remarks Reduction of a case analysis Functions Remarks

  22. Case analysis on a constant Coq J.-F. Monin Case analysis Enumerated types General case From graphical presentation to Coq syntax Simple inductive definitions Case analysis Definition color_of_Bf : color := Reduction of a match Bf with case analysis | Rf => Red Functions | Gf => Green Remarks | Bf => Blue end .

  23. Reduction Coq J.-F. Monin Case analysis Enumerated types General case From graphical match Bf with presentation to Coq syntax | Rf => Red Simple inductive definitions Case analysis | Gf => Green Reduction of a | Bf => Blue case analysis Functions end . Remarks Reduces to Blue

  24. Outline Coq J.-F. Monin Case analysis Enumerated types Case analysis General case From graphical Enumerated types presentation to Coq syntax General case Simple inductive definitions Case analysis Reduction of a From graphical presentation to Coq syntax case analysis Simple inductive definitions Functions Case analysis Remarks Reduction of a case analysis Functions Remarks

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend