From 378422bcb7de688ac201a70668a3e33b88bdae42 Mon Sep 17 00:00:00 2001 From: Cyril Cohen Date: Mon, 6 Apr 2020 01:03:15 +0200 Subject: Make `all2` better wrt the guard condition fixes #469 --- CHANGELOG_UNRELEASED.md | 3 +++ mathcomp/ssreflect/seq.v | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG_UNRELEASED.md b/CHANGELOG_UNRELEASED.md index 96ec16c..aa3983e 100644 --- a/CHANGELOG_UNRELEASED.md +++ b/CHANGELOG_UNRELEASED.md @@ -143,6 +143,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). `ssrnat.mc_1_10` module. One may compile proofs compatible with the version 1.10 in newer versions by using this module. +- The definition of `all2` was slightly altered for a better interaction with + the guard condition (#469) + ### Renamed - `real_lerP` -> `real_leP` 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. -- cgit v1.2.3 From b4673a3f6d06a4ff38789fd82f33dd517186eb44 Mon Sep 17 00:00:00 2001 From: Cyril Cohen Date: Fri, 10 Apr 2020 10:55:30 +0200 Subject: adding guard conditions check to the test_suite --- mathcomp/Make.test-suite | 1 + mathcomp/test_suite/test_guard.v | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 mathcomp/test_suite/test_guard.v 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/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). -- cgit v1.2.3