1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(* Certification of Imperative Programs / Jean-Christophe Filli�tre *)
11
(* $Id: Arrays.v 5920 2004-07-16 20:01:26Z herbelin $ *)
13
(**********************************************)
14
(* Functional arrays, for use in Correctness. *)
15
(**********************************************)
17
(* This is an axiomatization of arrays.
19
* The type (array N T) is the type of arrays ranging from 0 to N-1
20
* which elements are of type T.
22
* Arrays are created with new, accessed with access and modified with store.
24
* Operations of accessing and storing are not guarded, but axioms are.
25
* So these arrays can be viewed as arrays where accessing and storing
26
* out of the bounds has no effect.
30
Require Export ProgInt.
32
Set Implicit Arguments.
35
(* The type of arrays *)
37
Parameter array : Z -> Set -> Set.
40
(* Functions to create, access and modify arrays *)
42
Parameter new : forall (n:Z) (T:Set), T -> array n T.
44
Parameter access : forall (n:Z) (T:Set), array n T -> Z -> T.
46
Parameter store : forall (n:Z) (T:Set), array n T -> Z -> T -> array n T.
53
forall (n:Z) (T:Set) (v0:T) (i:Z),
54
(0 <= i < n)%Z -> access (new n v0) i = v0.
58
forall (n:Z) (T:Set) (t:array n T) (v:T) (i:Z),
59
(0 <= i < n)%Z -> access (store t i v) i = v.
63
forall (n:Z) (T:Set) (t:array n T) (v:T) (i j:Z),
65
(0 <= j < n)%Z -> i <> j -> access (store t i v) j = access t j.
67
Hint Resolve new_def store_def_1 store_def_2: datatypes v62.
69
(* A tactic to simplify access in arrays *)
71
Ltac array_access i j H :=
73
[ intro H; rewrite H; rewrite store_def_1
74
| intro H; rewrite store_def_2; [ idtac | idtac | idtac | exact H ] ].
76
(* Symbolic notation for access *)
78
Notation "# t [ c ]" := (access t c) (at level 0, t at level 0).
b'\\ No newline at end of file'