03a inductive definitions
play

03aInductive Definitions CS 3234: Logic and Formal Systems Martin - PowerPoint PPT Presentation

What are inductive definitions? Formal definitions Taking cases and proofs by induction Inductive definitions and proofs by induction in Coq Extensions to other structures & summary 03aInductive Definitions CS 3234: Logic and Formal


  1. What are inductive definitions? Formal definitions Taking cases and proofs by induction Inductive definitions and proofs by induction in Coq Extensions to other structures & summary 03a—Inductive Definitions CS 3234: Logic and Formal Systems Martin Henz and Aquinas Hobor August 24, 2006 Generated on Thursday 27 th August, 2009, 04:59 CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  2. What are inductive definitions? Formal definitions Binary trees Taking cases and proofs by induction Natural numbers Inductive definitions and proofs by induction in Coq Naturals as trees Extensions to other structures & summary Inductive definitions Often one wishes to define a set with a collection of rules that determine the elements of that set. Simple examples: Binary trees Natural numbers What does it mean to define a set by a collection of rules? CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  3. What are inductive definitions? Formal definitions Binary trees Taking cases and proofs by induction Natural numbers Inductive definitions and proofs by induction in Coq Naturals as trees Extensions to other structures & summary Example 1: Binary trees (w/o data at nodes) • is a binary tree; if l and r are binary trees, then so is l r Examples of binary trees: • CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  4. What are inductive definitions? Formal definitions Binary trees Taking cases and proofs by induction Natural numbers Inductive definitions and proofs by induction in Coq Naturals as trees Extensions to other structures & summary Example 1: Binary trees (w/o data at nodes) • is a binary tree; if l and r are binary trees, then so is l r Examples of binary trees: • • • CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  5. What are inductive definitions? Formal definitions Binary trees Taking cases and proofs by induction Natural numbers Inductive definitions and proofs by induction in Coq Naturals as trees Extensions to other structures & summary Example 1: Binary trees (w/o data at nodes) • is a binary tree; if l and r are binary trees, then so is l r Examples of binary trees: • • • • • • CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  6. What are inductive definitions? Formal definitions Binary trees Taking cases and proofs by induction Natural numbers Inductive definitions and proofs by induction in Coq Naturals as trees Extensions to other structures & summary Example 1: Binary trees (w/o data at nodes) • is a binary tree; if l and r are binary trees, then so is l r Examples of binary trees: • • • • • • • • • • • • CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  7. What are inductive definitions? Formal definitions Binary trees Taking cases and proofs by induction Natural numbers Inductive definitions and proofs by induction in Coq Naturals as trees Extensions to other structures & summary Example 2: Natural numbers in unary (base-1) notation Z is a natural; if n is a natural, then so is S ( n ). CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  8. What are inductive definitions? Formal definitions Binary trees Taking cases and proofs by induction Natural numbers Inductive definitions and proofs by induction in Coq Naturals as trees Extensions to other structures & summary Example 2: Natural numbers in unary (base-1) notation Z is a natural; if n is a natural, then so is S ( n ). We pronouce Z as “zed” and “S” as successor. We can now define the natural numbers as follows: ≡ zero Z CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  9. What are inductive definitions? Formal definitions Binary trees Taking cases and proofs by induction Natural numbers Inductive definitions and proofs by induction in Coq Naturals as trees Extensions to other structures & summary Example 2: Natural numbers in unary (base-1) notation Z is a natural; if n is a natural, then so is S ( n ). We pronouce Z as “zed” and “S” as successor. We can now define the natural numbers as follows: ≡ zero Z one ≡ S ( Z ) CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  10. What are inductive definitions? Formal definitions Binary trees Taking cases and proofs by induction Natural numbers Inductive definitions and proofs by induction in Coq Naturals as trees Extensions to other structures & summary Example 2: Natural numbers in unary (base-1) notation Z is a natural; if n is a natural, then so is S ( n ). We pronouce Z as “zed” and “S” as successor. We can now define the natural numbers as follows: ≡ zero Z one ≡ S ( Z ) ≡ S ( S ( Z )) two CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  11. What are inductive definitions? Formal definitions Binary trees Taking cases and proofs by induction Natural numbers Inductive definitions and proofs by induction in Coq Naturals as trees Extensions to other structures & summary Example 2: Natural numbers in unary (base-1) notation Z is a natural; if n is a natural, then so is S ( n ). We pronouce Z as “zed” and “S” as successor. We can now define the natural numbers as follows: ≡ zero Z one ≡ S ( Z ) ≡ S ( S ( Z )) two . . . CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  12. What are inductive definitions? Formal definitions Binary trees Taking cases and proofs by induction Natural numbers Inductive definitions and proofs by induction in Coq Naturals as trees Extensions to other structures & summary It’s possible to view naturals as trees, too: zero ≡ Z Z one ≡ S ( Z ) S Z two ≡ S ( S ( Z )) S S Z . . . CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  13. What are inductive definitions? Definition via rules Formal definitions Extremal clause Taking cases and proofs by induction Inductive definitions Inductive definitions and proofs by induction in Coq A useful notation: recursive definitions Extensions to other structures & summary Examples (more formally) Binary trees: The set Tree is defined by the rules t l t r • t l t r Naturals: The set Nat is defined by the rules n Z S ( n ) CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  14. What are inductive definitions? Definition via rules Formal definitions Extremal clause Taking cases and proofs by induction Inductive definitions Inductive definitions and proofs by induction in Coq A useful notation: recursive definitions Extensions to other structures & summary Given a collection of rules, what set does it define? What is the set of trees? What is the set of naturals? Do the rules pick out a unique set? CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  15. What are inductive definitions? Definition via rules Formal definitions Extremal clause Taking cases and proofs by induction Inductive definitions Inductive definitions and proofs by induction in Coq A useful notation: recursive definitions Extensions to other structures & summary There can be many sets that satisfy a given collection of rules MyNum = { Z , S ( Z ) , . . . } YourNum = MyNum ∪ {∞ , S ( ∞ ) , . . . } , where ∞ is an arbitrary symbol. Both MyNum and YourNum satisfy the rules defining numerals (i.e., the rules are true for these sets). CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  16. What are inductive definitions? Definition via rules Formal definitions Extremal clause Taking cases and proofs by induction Inductive definitions Inductive definitions and proofs by induction in Coq A useful notation: recursive definitions Extensions to other structures & summary There can be many sets that satisfy a given collection of rules MyNum = { Z , S ( Z ) , . . . } YourNum = MyNum ∪ {∞ , S ( ∞ ) , . . . } , where ∞ is an arbitrary symbol. Both MyNum and YourNum satisfy the rules defining numerals (i.e., the rules are true for these sets). Really? CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  17. What are inductive definitions? Definition via rules Formal definitions Extremal clause Taking cases and proofs by induction Inductive definitions Inductive definitions and proofs by induction in Coq A useful notation: recursive definitions Extensions to other structures & summary MyNum Satisfies the Rules n Z S ( n ) MyNum = { Z , Succ ( Z ) , S ( S ( Z )) , . . . } Does MyNum satisfy the rules? Z ∈ MyNum . √ If n ∈ MyNum , then S ( n ) ∈ MyNum . √ CS 3234: Logic and Formal Systems 03a—Inductive Definitions

  18. What are inductive definitions? Definition via rules Formal definitions Extremal clause Taking cases and proofs by induction Inductive definitions Inductive definitions and proofs by induction in Coq A useful notation: recursive definitions Extensions to other structures & summary YourNum Satisfies the Rules n Z S ( n ) YourNum = { Z , S ( Z ) , S ( S ( Z )) , . . . } ∪ {∞ , S ( ∞ ) , . . . } Does YourNum satisfy the rules? Z ∈ YourNum . √ If n ∈ YourNum , then S ( n ) ∈ YourNum . √ CS 3234: Logic and Formal Systems 03a—Inductive Definitions

Recommend


More recommend