Skip to content

Commit

Permalink
Make test suite compile.
Browse files Browse the repository at this point in the history
  • Loading branch information
proux01 committed Jul 30, 2018
1 parent 70c398c commit 7deba50
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 20 deletions.
5 changes: 4 additions & 1 deletion test-suite/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ COQC := $(COQBIN)coqc

all: Parametricity.vo

examples:: example.vo ListQueue.vo features.vo wadler.vo
examples:: example.vo ListQueue.vo features.vo wadler.vo bug.vo bug2.vo bug3.vo bug4.vo bug5.vo dummyFix.v exmNotParametric.v

Parametricity.vo: Parametricity.v
$(COQC) -I ../src $<
Expand All @@ -30,6 +30,9 @@ features.vo: features.v Parametricity.vo
wadler.vo: wadler.v Parametricity.vo
$(COQC) -I ../src $<

bug%.vo: bug%.v
$(COQC) -I ../src $<

ide:: Parametricity.vo
$(COQBIN)coqide -debug -I ../src *.v

Expand Down
4 changes: 1 addition & 3 deletions test-suite/Parametricity.v
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,11 @@ Global Parametricity Tactic := ((destruct_reflexivity; fail)

Require Import ProofIrrelevance. (* for opaque terms *)

(*
Parametricity Module Logic.
Parametricity Module Datatypes.

Parametricity Module Logic_Type.
Parametricity Module Decimal.
Parametricity Module Nat.

Parametricity Module Specif.
Expand All @@ -65,4 +64,3 @@ Parametricity Module Wf.
Parametricity Module Tactics.

Export Logic_R Datatypes_R Logic_Type_R Specif_R Nat_R Peano_R Wf_R Tactics_R.
*)
49 changes: 48 additions & 1 deletion test-suite/bug3.v
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,56 @@ Proof.
- exact lt_wf.
Defined.

Ltac destruct_reflexivity :=
intros ; repeat match goal with
| [ x : _ |- _ = _ ] => destruct x; reflexivity; fail
end.

Ltac destruct_construct x :=
(destruct x; [ constructor 1 ]; auto; fail)
|| (destruct x; [ constructor 1 | constructor 2 ]; auto; fail)
|| (destruct x; [ constructor 1 | constructor 2 | constructor 3]; auto; fail).

Ltac unfold_cofix := intros; match goal with
[ |- _ = ?folded ] =>
let x := fresh "x" in
let typ := type of folded in
(match folded with _ _ => pattern folded | _ => pattern folded at 2 end);
match goal with [ |- ?P ?x ] =>
refine (let rebuild : typ -> typ := _ in
let path : rebuild folded = folded := _ in
eq_rect _ P _ folded path) end;
[ intro x ; destruct_construct x; fail
| destruct folded; reflexivity
| reflexivity]; fail
end.

Ltac destruct_with_nat_arg_pattern x :=
pattern x;
match type of x with
| ?I 0 => refine (let gen : forall m (q : I m),
(match m return I m -> Type with
0 => fun p => _ p
| S n => fun _ => unit end q) := _ in gen 0 x)
| ?I (S ?n) => refine (let gen : forall m (q : I m),
(match m return I m -> Type with
0 => fun _ => unit
| S n => fun p => _ p end q) := _ in gen (S n) x)
end; intros m q; destruct q.

Ltac destruct_reflexivity_with_nat_arg_pattern :=
intros ; repeat match goal with
| [ x : _ |- _ = _ ] => destruct_with_nat_arg_pattern x; reflexivity; fail
end.

Global Parametricity Tactic := ((destruct_reflexivity; fail)
|| (unfold_cofix; fail)
|| (destruct_reflexivity_with_nat_arg_pattern; fail)
|| auto).

Require Import ProofIrrelevance.

Parametricity Recursive GcdS.
Parametricity Recursive GcdS qualified.



Expand Down
48 changes: 48 additions & 0 deletions test-suite/bug4.v
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,52 @@ with sub_mask_carry (xx yy : positive) {struct yy} : BinPosDef.Pos.mask :=
end.

Set Parametricity Debug.

Ltac destruct_reflexivity :=
intros ; repeat match goal with
| [ x : _ |- _ = _ ] => destruct x; reflexivity; fail
end.

Ltac destruct_construct x :=
(destruct x; [ constructor 1 ]; auto; fail)
|| (destruct x; [ constructor 1 | constructor 2 ]; auto; fail)
|| (destruct x; [ constructor 1 | constructor 2 | constructor 3]; auto; fail).

Ltac unfold_cofix := intros; match goal with
[ |- _ = ?folded ] =>
let x := fresh "x" in
let typ := type of folded in
(match folded with _ _ => pattern folded | _ => pattern folded at 2 end);
match goal with [ |- ?P ?x ] =>
refine (let rebuild : typ -> typ := _ in
let path : rebuild folded = folded := _ in
eq_rect _ P _ folded path) end;
[ intro x ; destruct_construct x; fail
| destruct folded; reflexivity
| reflexivity]; fail
end.

Ltac destruct_with_nat_arg_pattern x :=
pattern x;
match type of x with
| ?I 0 => refine (let gen : forall m (q : I m),
(match m return I m -> Type with
0 => fun p => _ p
| S n => fun _ => unit end q) := _ in gen 0 x)
| ?I (S ?n) => refine (let gen : forall m (q : I m),
(match m return I m -> Type with
0 => fun _ => unit
| S n => fun p => _ p end q) := _ in gen (S n) x)
end; intros m q; destruct q.

Ltac destruct_reflexivity_with_nat_arg_pattern :=
intros ; repeat match goal with
| [ x : _ |- _ = _ ] => destruct_with_nat_arg_pattern x; reflexivity; fail
end.

Global Parametricity Tactic := ((destruct_reflexivity; fail)
|| (unfold_cofix; fail)
|| (destruct_reflexivity_with_nat_arg_pattern; fail)
|| auto).

Parametricity Recursive sub_mask.
55 changes: 51 additions & 4 deletions test-suite/bug5.v
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ Admitted.

Definition T := forall a b : nat, b <> 0 -> modS a b < b.
Parametricity Recursive T.
Print Top__o__T_R.
Print T_R.

Axiom NNmod_upper_boundA_R : (fun H H0 : forall a b : nat, b <> 0 -> modS a b < b =>
forall (a₁ a₂ : nat) (a_R : nat_R a₁ a₂) (b₁ b₂ : nat) (b_R : nat_R b₁ b₂)
(H1 : b₁ <> 0) (H2 : b₂ <> 0),
Coq__o__Init__o__Logic__o__not_R (eq_R nat_R b_R nat_R_O_R) H1 H2 ->
Coq__o__Init__o__Peano__o__lt_R (Top__o__modS_R a_R b_R) b_R (H a₁ b₁ H1)
not_R (eq_R nat_R b_R nat_R_O_R) H1 H2 ->
lt_R (modS_R a_R b_R) b_R (H a₁ b₁ H1)
(H0 a₂ b₂ H2)) NNmod_upper_boundA NNmod_upper_boundA.

Realizer NNmod_upper_boundA as NNmod_upper_boundA_RR := NNmod_upper_boundA_R.
Expand Down Expand Up @@ -79,7 +79,54 @@ Defined.
Require Import ProofIrrelevance.
Parametricity Recursive sig_rec.

Parametricity Recursive GcdS.
Ltac destruct_reflexivity :=
intros ; repeat match goal with
| [ x : _ |- _ = _ ] => destruct x; reflexivity; fail
end.

Ltac destruct_construct x :=
(destruct x; [ constructor 1 ]; auto; fail)
|| (destruct x; [ constructor 1 | constructor 2 ]; auto; fail)
|| (destruct x; [ constructor 1 | constructor 2 | constructor 3]; auto; fail).

Ltac unfold_cofix := intros; match goal with
[ |- _ = ?folded ] =>
let x := fresh "x" in
let typ := type of folded in
(match folded with _ _ => pattern folded | _ => pattern folded at 2 end);
match goal with [ |- ?P ?x ] =>
refine (let rebuild : typ -> typ := _ in
let path : rebuild folded = folded := _ in
eq_rect _ P _ folded path) end;
[ intro x ; destruct_construct x; fail
| destruct folded; reflexivity
| reflexivity]; fail
end.

Ltac destruct_with_nat_arg_pattern x :=
pattern x;
match type of x with
| ?I 0 => refine (let gen : forall m (q : I m),
(match m return I m -> Type with
0 => fun p => _ p
| S n => fun _ => unit end q) := _ in gen 0 x)
| ?I (S ?n) => refine (let gen : forall m (q : I m),
(match m return I m -> Type with
0 => fun _ => unit
| S n => fun p => _ p end q) := _ in gen (S n) x)
end; intros m q; destruct q.

Ltac destruct_reflexivity_with_nat_arg_pattern :=
intros ; repeat match goal with
| [ x : _ |- _ = _ ] => destruct_with_nat_arg_pattern x; reflexivity; fail
end.

Global Parametricity Tactic := ((destruct_reflexivity; fail)
|| (unfold_cofix; fail)
|| (destruct_reflexivity_with_nat_arg_pattern; fail)
|| auto).

Parametricity Recursive GcdS qualified.

(*
1 subgoal
Expand Down
2 changes: 1 addition & 1 deletion test-suite/features.v
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Print Module A_R.
Print Module A_R.B_R.

(* Parametricity Module Bool. *)
Print Module Bool_R.
(* Print Module Bool_R. *)

(** Unary parametricity *)
Parametricity Translation (forall X, X -> X) as ID_R arity 1.
Expand Down
11 changes: 1 addition & 10 deletions test-suite/wadler.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Require Import List.
Require Import Parametricity.

Parametricity nat.

Lemma nat_R_equal :
forall x y, nat_R x y -> x = y.
intros x y H; induction H; subst; trivial.
Expand All @@ -15,8 +13,6 @@ intros x y H; subst.
induction y; constructor; trivial.
Defined.

Parametricity list.

Definition full_relation {A B} (x : A) (y : B) := True.

Definition same_length {A B} := list_R A B full_relation.
Expand Down Expand Up @@ -198,9 +194,4 @@ Fixpoint zip {X Y} (l1 : list X) (l2 : list Y) : list (X * Y) :=
Parametricity zip.
Definition zip_free_theorem : FREE_THEOREM (@zip) := param_ZIP_naturality _ zip_R.







End ZipType.

0 comments on commit 7deba50

Please sign in to comment.