TP06: The accessiblity predicate
The Acc accessiblity predicate
well_founded =
fun (A : Type) (R : A -> A -> Prop) => forall a : A, Acc R a
: forall A : Type, (A -> A -> Prop) -> Prop
Argument A is implicit
Argument scopes are [type_scope _]
Inductive Acc (A : Type) (R : A -> A -> Prop) (x : A) : Prop :=
Acc_intro : (forall y : A, R y x -> Acc R y) -> Acc R x
First example: lt and its lexicographic product.
Require Import Relations.
Require Import Arith.
Require Import Omega.
The following line turn implicit all arguments that can be infered
from other arguments, this removing the need to explicitely tag
them with { }.
Set Implicit Arguments.
2) As an example, prove the lemmas Acc lt 0, Acc lt 1,
and Acc lt 2.
3) What is the structure of a proof of Acc lt n?
4) Prove (on paper) that any natural number is accessible by <.
Then (and only then), translate this proof to Coq.
Theorem lt_wf : well_founded lt.
Proof.
...
Qed.
Proof.
...
Qed.
5) Define lt2 the lexicographic product of <.
Definition lt2 : relation (nat*nat) := ...
Notation "x << y " := (lt2 x y) (at level 70).
Notation "x << y " := (lt2 x y) (at level 70).
6) Prove that lt2 is a strict order, i.e. is irreflexive and
transitive.
You can use SearchPattern or SearchAbout to look for lemmas
you might need about lt and le.
7) Prove (on paper) that the strict lexicographic ordering on
nat*nat is well-founded.
Then (and only then) translate this proof to Coq.
Lemma lt2_wf : well_founded lt2.
Proof.
...
Qed.
Proof.
...
Qed.
Lemma Acc_inv : forall (A : Type) (R : relation A) x y, R x y -> Acc R y -> Acc R x.
Proof.
...
Qed.
Proof.
...
Qed.
Definition rel_incl (A : Type) (R S : relation A) := ...
10) Prove that if R is included in S and S is well-founded,
then R is well-founded.
Theorem rel_incl_wf (A : Type) (R S : relation A) :
rel_incl R S -> well_founded S -> well_founded R.
Proof.
...
Qed.
rel_incl R S -> well_founded S -> well_founded R.
Proof.
...
Qed.
Section Inverse_image.
Variables (A B : Type) (R : relation B) (f : A -> B).
Definition R' x y := R (f x) (f y).
11) Prove the following lemma relating Acc R and Acc R'.
Lemma Acc_inverse_eq : forall y, Acc R y -> forall x, y = (f x) -> Acc R' x.
Proof.
...
Qed.
Proof.
...
Qed.
12) Deduce from this lemma that the reverse image of a well-founded
relation by any function is a well-founded relation.
Lemma wf_inverse_image : well_founded R -> well_founded R'.
Proof.
...
Qed.
End Inverse_image.
Proof.
...
Qed.
End Inverse_image.
Transitive closure
Lemma Acc_trans (A : Type) (R : relation A) :
forall x, Acc R x -> Acc (trans R) x.
Proof.
...
Qed.
forall x, Acc R x -> Acc (trans R) x.
Proof.
...
Qed.
15) Prove that if R is well-founded, then its transitive closure
is well-founded.
Theorem wf_trans : forall (A : Type) (R : relation A),
well_founded R -> well_founded (trans R).
Proof. intros A R wfR x. apply Acc_trans. apply wfR. Qed.
well_founded R -> well_founded (trans R).
Proof. intros A R wfR x. apply Acc_trans. apply wfR. Qed.
Definition lexprod (A B : Type) (RA : relation A) (RB : relation B)
: relation (A*B) := ...
: relation (A*B) := ...
17) prove that the lexicographic product of two well-founded relations
is a well-founded relation.
Theorem lexprod_wf (A B : Type) (RA : relation A) (RB : relation B) :
well_founded RA -> well_founded RB -> well_founded (lexprod RA RB).
Proof.
...
Qed.
well_founded RA -> well_founded RB -> well_founded (lexprod RA RB).
Proof.
...
Qed.
18) Bonus: What about the dependent lexicographic product?
(i.e. when the type of the second component of the pair depends
on the value of the first component)
This page has been generated by coqdoc