From dd2efcbf57dd85e6a07f454ab1f29b93babc32c0 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Filliatre Date: Fri, 1 Jun 2018 09:05:31 +0200 Subject: [PATCH] a more general pigeon hole principle --- examples/bellman_ford.mlw | 2 +- examples/bellman_ford/why3session.xml | 8 ++++---- stdlib/pigeon.mlw | 20 +++++++++++++++++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/examples/bellman_ford.mlw b/examples/bellman_ford.mlw index a9c57602f..5aa1ce988 100644 --- a/examples/bellman_ford.mlw +++ b/examples/bellman_ford.mlw @@ -61,7 +61,7 @@ theory Graph Two cases depending on l3=[] (and thus u=v) conclude the proof. Qed. *) - clone pigeon.Pigeonhole with type t = vertex + clone pigeon.ListAndSet with type t = vertex predicate cyc_decomp (v: vertex) (l: list vertex) (vi: vertex) (l1 l2 l3: list vertex) = diff --git a/examples/bellman_ford/why3session.xml b/examples/bellman_ford/why3session.xml index e564f9bef..9bdd9ce6f 100644 --- a/examples/bellman_ford/why3session.xml +++ b/examples/bellman_ford/why3session.xml @@ -174,7 +174,7 @@ - + @@ -335,15 +335,15 @@ - + - + - + diff --git a/stdlib/pigeon.mlw b/stdlib/pigeon.mlw index e59502cef..1fde34cf7 100644 --- a/stdlib/pigeon.mlw +++ b/stdlib/pigeon.mlw @@ -1,10 +1,24 @@ -(** {1 Pigeon hole principle} - - Contributed by Yuto Takei (University of Tokyo) *) +(** {1 Pigeon hole principle} *) module Pigeonhole + use import int.Int + use import map.Map + + val lemma pigeonhole (n m: int) (f: int -> int) + requires { 0 <= m < n } + requires { forall i. 0 <= i < n -> 0 <= f i < m } + ensures { exists i1, i2. 0 <= i1 < i2 < n /\ f i1 = f i2 } + +end + +(* An instance where a list is included into a set with fewer elements. + + Contributed by Yuto Takei (University of Tokyo) *) + +module ListAndSet + use import int.Int use import list.List use import list.Length -- GitLab