Skip to content
Snippets Groups Projects
Commit dabf8fc1 authored by Robbert Krebbers's avatar Robbert Krebbers
Browse files

Add test case.

parent 4901b4b6
No related branches found
No related tags found
1 merge request!519Add lemmas for easy measure/size induction.
Pipeline #91189 passed
...@@ -415,12 +415,12 @@ Global Program Instance gtest_countable `{Countable K} : Countable (gtest K) := ...@@ -415,12 +415,12 @@ Global Program Instance gtest_countable `{Countable K} : Countable (gtest K) :=
inj_countable' enc dec _. inj_countable' enc dec _.
Next Obligation. Next Obligation.
intros K ?? enc dec_list dec t. intros K ?? enc dec_list dec t.
remember (gtest_size t) as n eqn:Hn. revert t Hn. induction (Nat.lt_wf_0_projected gtest_size t) as [[ts] _ IH].
induction (lt_wf n) as [n _ IH]; intros [ts] ->; simpl in *; f_equal. simpl in *; f_equal.
revert ts IH. apply (map_fold_ind (λ r ts, _ dec_list dec r = ts)); [done|]. revert ts IH. apply (map_fold_ind (λ r ts, _ dec_list dec r = ts)); [done|].
intros i t ts r ? IHts IHt; simpl. f_equal. intros i t ts r ? IHts IHt; simpl. f_equal.
- eapply IHt; [|done]. rewrite map_fold_insert_L by auto with lia. lia. - eapply IHt. rewrite map_fold_insert_L by auto with lia. lia.
- apply IHts; intros n ? t' ->. eapply IHt; [|done]. - apply IHts; intros t' ?. eapply IHt.
rewrite map_fold_insert_L by auto with lia. lia. rewrite map_fold_insert_L by auto with lia. lia.
Qed. Qed.
......
le
: nat → nat → Prop
lt
: nat → nat → Prop
le
: nat → nat → Prop
lt
: nat → nat → Prop
le
: nat → nat → Prop
lt
: nat → nat → Prop
le
: nat → nat → Prop
lt
: nat → nat → Prop
From stdpp Require base numbers prelude. From stdpp Require Import list.
(** Check that we always get the [le] and [lt] functions on [nat]. *) (** Simple example of measure induction on lists using [Nat.lt_wf_0_projected]. *)
Module test1. Fixpoint evens {A} (l : list A) : list A :=
Import stdpp.base. match l with
Check le. | x :: _ :: l => x :: evens l
Check lt. | [x] => [x]
End test1. | _ => []
end.
Module test2. Fixpoint odds {A} (l : list A) : list A :=
Import stdpp.prelude. match l with
Check le. | _ :: y :: l => y :: odds l
Check lt. | _ => []
End test2. end.
Module test3. Lemma lt_wf_projected_induction_sample {A} (l : list A) :
Import stdpp.numbers. evens l ++ odds l l.
Check le. Proof.
Check lt. (** Note that we do not use [induction .. using ..]. The term
End test3. [Nat.lt_wf_0_projected length l] has type [Acc ..], so we perform induction
on the [Acc] predicate. *)
Module test4. induction (Nat.lt_wf_0_projected length l) as [l _ IH].
Import stdpp.list. destruct l as [|x [|y l]]; simpl; [done..|].
Check le. rewrite <-Permutation_middle. rewrite IH by (simpl; lia). done.
Check lt. Qed.
End test4.
le
: nat → nat → Prop
lt
: nat → nat → Prop
le
: nat → nat → Prop
lt
: nat → nat → Prop
le
: nat → nat → Prop
lt
: nat → nat → Prop
le
: nat → nat → Prop
lt
: nat → nat → Prop
From stdpp Require base numbers prelude.
(** Check that we always get the [le] and [lt] functions on [nat]. *)
Module test1.
Import stdpp.base.
Check le.
Check lt.
End test1.
Module test2.
Import stdpp.prelude.
Check le.
Check lt.
End test2.
Module test3.
Import stdpp.numbers.
Check le.
Check lt.
End test3.
Module test4.
Import stdpp.list.
Check le.
Check lt.
End test4.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment