Append.v 2.76 KB
Newer Older
1 2 3
(********************************************************************)
(*                                                                  *)
(*  The Why3 Verification Platform   /   The Why3 Development Team  *)
Guillaume Melquiond's avatar
Guillaume Melquiond committed
4
(*  Copyright 2010-2019   --   Inria - CNRS - Paris-Sud University  *)
5 6 7 8 9 10 11
(*                                                                  *)
(*  This software is distributed under the terms of the GNU Lesser  *)
(*  General Public License version 2.1, with the special exception  *)
(*  on linking described in file LICENSE.                           *)
(*                                                                  *)
(********************************************************************)

12 13 14 15
(* This file is generated by Why3's Coq-realize driver *)
(* Beware! Only edit allowed sections below    *)
Require Import BuiltIn.
Require BuiltIn.
16 17 18 19 20 21
Require int.Int.
Require list.List.
Require list.Length.
Require list.Mem.

(* Why3 goal *)
22
Lemma infix_plpl_def {a:Type} {a_WT:WhyType a} :
23 24 25 26 27 28 29
  forall (l1:(list a)) (l2:(list a)),
  ((Init.Datatypes.app l1 l2) =
   match l1 with
   | Init.Datatypes.nil => l2
   | (Init.Datatypes.cons x1 r1) =>
       (Init.Datatypes.cons x1 (Init.Datatypes.app r1 l2))
   end).
30
Proof.
31
now intros [|h1 q1] l2.
32 33 34 35 36
Qed.

Require Import Lists.List.

(* Why3 goal *)
37
Lemma Append_assoc {a:Type} {a_WT:WhyType a} :
38 39 40
  forall (l1:(list a)) (l2:(list a)) (l3:(list a)),
  ((Init.Datatypes.app l1 (Init.Datatypes.app l2 l3)) =
   (Init.Datatypes.app (Init.Datatypes.app l1 l2) l3)).
41
Proof.
42
intros l1 l2 l3.
43 44 45 46
apply app_assoc.
Qed.

(* Why3 goal *)
47 48
Lemma Append_l_nil {a:Type} {a_WT:WhyType a} :
  forall (l:(list a)), ((Init.Datatypes.app l Init.Datatypes.nil) = l).
49
Proof.
50
intros l.
51 52 53 54
apply app_nil_r.
Qed.

(* Why3 goal *)
55
Lemma Append_length {a:Type} {a_WT:WhyType a} :
56 57 58
  forall (l1:(list a)) (l2:(list a)),
  ((list.Length.length (Init.Datatypes.app l1 l2)) =
   ((list.Length.length l1) + (list.Length.length l2))%Z).
59
Proof.
60
intros l1 l2.
61 62 63 64 65
rewrite 3!Length.length_std.
now rewrite app_length, inj_plus.
Qed.

(* Why3 goal *)
66
Lemma mem_append {a:Type} {a_WT:WhyType a} :
67 68 69
  forall (x:a) (l1:(list a)) (l2:(list a)),
  (list.Mem.mem x (Init.Datatypes.app l1 l2)) <->
  ((list.Mem.mem x l1) \/ (list.Mem.mem x l2)).
70
Proof.
71
intros x l1 l2.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
split.
intros H.
apply Mem.mem_std in H.
apply in_app_or in H.
destruct H as [H|H].
left.
now apply Mem.mem_std.
right.
now apply Mem.mem_std.
intros H.
apply Mem.mem_std.
apply in_or_app.
destruct H as [H|H].
left.
now apply Mem.mem_std.
right.
now apply Mem.mem_std.
Qed.

(* Why3 goal *)
92 93 94
Lemma mem_decomp {a:Type} {a_WT:WhyType a} :
  forall (x:a) (l:(list a)), (list.Mem.mem x l) ->
  exists l1:(list a), exists l2:(list a),
95
  (l = (Init.Datatypes.app l1 (Init.Datatypes.cons x l2))).
96
Proof.
97
intros x l h1.
98 99 100 101
apply in_split.
now apply Mem.mem_std.
Qed.