aboutsummaryrefslogtreecommitdiff
path: root/mathcomp
diff options
context:
space:
mode:
authoraffeldt-aist2020-04-10 15:31:34 +0200
committerGitHub2020-04-10 15:31:34 +0200
commitbdb7ba0daeb2ea8487dfc12578a2d69f44a39751 (patch)
treee16111e1a759416906f84557c7a7e5f940616bb1 /mathcomp
parent74089ef84dca48c11cae79f7f49a7060160c0000 (diff)
parentb4673a3f6d06a4ff38789fd82f33dd517186eb44 (diff)
Merge pull request #471 from math-comp/all2_guard_cond
Make `all2` better wrt the guard condition
Diffstat (limited to 'mathcomp')
-rw-r--r--mathcomp/Make.test-suite1
-rw-r--r--mathcomp/ssreflect/seq.v10
-rw-r--r--mathcomp/test_suite/test_guard.v6
3 files changed, 12 insertions, 5 deletions
diff --git a/mathcomp/Make.test-suite b/mathcomp/Make.test-suite
index 99d8289..2be741b 100644
--- a/mathcomp/Make.test-suite
+++ b/mathcomp/Make.test-suite
@@ -1,5 +1,6 @@
test_suite/hierarchy_test.v
test_suite/test_ssrAC.v
+test_suite/test_guard.v
-I .
-R . mathcomp
diff --git a/mathcomp/ssreflect/seq.v b/mathcomp/ssreflect/seq.v
index dca4136..aca2b77 100644
--- a/mathcomp/ssreflect/seq.v
+++ b/mathcomp/ssreflect/seq.v
@@ -2634,7 +2634,7 @@ Prenex Implicits mask map pmap foldr foldl scanl pairmap.
Section Zip.
-Variables S T : Type.
+Variables (S T : Type) (r : S -> T -> bool).
Fixpoint zip (s : seq S) (t : seq T) {struct t} :=
match s, t with
@@ -2645,10 +2645,10 @@ Fixpoint zip (s : seq S) (t : seq T) {struct t} :=
Definition unzip1 := map (@fst S T).
Definition unzip2 := map (@snd S T).
-Fixpoint all2 (r : S -> T -> bool) s t :=
+Fixpoint all2 s t :=
match s, t with
| [::], [::] => true
- | x :: s, y :: t => r x y && all2 r s t
+ | x :: s, y :: t => r x y && all2 s t
| _, _ => false
end.
@@ -2696,8 +2696,8 @@ move: s t; apply: seq_ind2 => //= x y s t eq_sz IHs.
by rewrite !rev_cons IHs zip_rcons ?size_rev.
Qed.
-Lemma all2E r s t :
- all2 r s t = (size s == size t) && all [pred xy | r xy.1 xy.2] (zip s t).
+Lemma all2E s t :
+ all2 s t = (size s == size t) && all [pred xy | r xy.1 xy.2] (zip s t).
Proof. by elim: s t => [|x s IHs] [|y t] //=; rewrite IHs andbCA. Qed.
End Zip.
diff --git a/mathcomp/test_suite/test_guard.v b/mathcomp/test_suite/test_guard.v
new file mode 100644
index 0000000..1e93a2c
--- /dev/null
+++ b/mathcomp/test_suite/test_guard.v
@@ -0,0 +1,6 @@
+From mathcomp Require Import all_ssreflect.
+
+Inductive tree := Node { children : seq tree }.
+
+Fixpoint eq_tree (x y : tree) {struct x} : bool :=
+ all2 eq_tree (children x) (children y).