CoInduction in Coq

Yves Bertot
DOI: https://doi.org/10.48550/arXiv.cs/0603119
2006-03-30
Abstract:We describe the basic notions of co-induction as they are available in the coq system. As an application, we describe arithmetic properties for simple representations of real numbers.
Logic in Computer Science
What problem does this paper attempt to address?
The problem that this paper attempts to solve is to explore how to define and use co - inductive types in the Coq theorem prover. Specifically, it addresses the following aspects: 1. **Definition of co - inductive types**: Different from inductive types, co - inductive types represent the largest stable set rather than the smallest. The paper explains how to define co - inductive types in Coq and introduces the constructors and destructors of these types. 2. **Definition of co - recursive functions**: The paper discusses how to define co - recursive functions, which are used to generate elements of co - inductive types. Co - recursive functions must follow certain rules, for example, they can only appear as parameters of constructors. 3. **Calculation of co - inductive values**: The paper explores the calculation methods of co - inductive values, pointing out that since co - inductive values may represent infinite objects, they are regarded as normal forms by default and can only be gradually expanded through pattern matching. 4. **Proof of properties of co - inductive values**: The paper introduces how to prove the equality of two co - inductive values and how to use co - inductive propositions to express and prove the properties of data structures such as lists. 5. **Application examples**: The paper gives several practical application examples, including applications in the fields of hardware description, concurrent programming, finite - state automata, infinite execution traces, temporal logic, etc. In particular, the paper details how to use co - inductive types to represent real numbers and their exact arithmetic operations. ### Key formulas 1. **Definition of co - inductive types**: - For example, the definition of an infinite list (stream): ```markdown CoInductive stream (A:Set) : Set := Cons : A -> stream A -> stream A. ``` 2. **Definition of co - recursive functions**: - For example, the co - recursive function to generate the infinite list `ones`: ```markdown CoFixpoint ones : stream nat := Cons 1 ones. ``` 3. **Proof of properties of co - inductive values**: - Use the co - inductive proposition `bisimilar` to prove that two lists have the same elements: ```markdown CoInductive bisimilar (A:Set) : Llist A -> Llist A -> Prop := bisim0 : bisimilar A (Lnil A) (Lnil A) | bisim1 : forall a l l’, bisimilar A l l’ -> bisimilar A (Lcons a l) (Lcons a l’). ``` 4. **Representation of real numbers**: - Use the infinite sequence `idigit` to represent real numbers: ```markdown CoInductive represents : stream idigit -> Rdefinitions.R -> Prop := reprL : for all s r, represents s r -> (0 <= r <= 1)%R -> represents (Cons L s) (r/2) | reprR : for all s r, represents s r -> (0 <= r <= 1)%R -> represents (Cons R s) ((r+1)/2) | reprC : for all s r, represents s r -> (0