Quantcast
Channel: Inductive vs. recursive definitions - Proof Assistants Stack Exchange
Viewing all articles
Browse latest Browse all 5

Inductive vs. recursive definitions

$
0
0

In Coq there are two ways to define a new type on an inductive type: Using Inductive and using Fixpoint. What are pros and cons of these approaches? Some aspects in which they can be compared: Difficulty of interacting with them (proofs, constructions). How large are the generated internal terms? Effects on performance.

Example:

Inductive list (A : Type) : Type :=| nil : list | cons : A -> list -> list.Inductive In {A : Type} (a : A) : list A -> Prop :=| In_cons_hd (l : list A) : In (cons a l)| In_cons_tl (hd : A) (tl : list A) : In tl -> In (hd :: tl).Fixpoint In' {A : Type} (a : A) (l : list A) : Prop :=  match l with  | nil => False  | cons hd tl =>    a = hd \/ In' a tl  end.Theorem In_equiv (A : Type) (a : A) (l : list A) :  In a l <-> In' a l.

If Inductive is used, one has to use the destruct, induction, inversion and constructor tactics (or explicitly choose a constructor using apply).This makes it harder to write proof terms manually, I think.

If Fixpoint is used and (in the above example) the list starts with constructors, the computation will take care of these steps.

Sometimes the Fixpoint is not definable in Coq, because of issue #1433.

Edit: Using Fixpoint made more "primitive logical operations" (conj., disj., quantifiers) appear in my proofs, which firstorder could process and often solve quickly.

Edit 2, regarding Fixpoint being "strongly normalizing":I think this is not that much of a problem per se, if enough disjunctions are used.I see another difficulty with Fixpoint. The recursive property must be structurally (or well-founded) recursive in the data, for all possible input data. (Proven at the time of definition)

So for example a sequent calculus is "easily" definable using Fixpoint if it has the subformula property, or if we add a dummy natural number as "fuel", which must decrease when going up in the deduction tree. Calculi without subformula property probably can't be to translated directly from Inductive to Fixpoint.


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images