(***********************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* Set -> Set. (* Functions to create, access and modify arrays *) Parameter new : (n:Z)(T:Set) T -> (array n T). Parameter access : (n:Z)(T:Set) (array n T) -> Z -> T. Parameter store : (n:Z)(T:Set) (array n T) -> Z -> T -> (array n T). (* Axioms *) Axiom new_def : (n:Z)(T:Set)(v0:T) (i:Z) `0<=i (access (new n v0) i) = v0. Axiom store_def_1 : (n:Z)(T:Set)(t:(array n T))(v:T) (i:Z) `0<=i (access (store t i v) i) = v. Axiom store_def_2 : (n:Z)(T:Set)(t:(array n T))(v:T) (i:Z)(j:Z) `0<=i `0<=j `i <> j` -> (access (store t i v) j) = (access t j). Hints Resolve new_def store_def_1 store_def_2 : datatypes v62. (* A tactic to simplify access in arrays *) Tactic Definition ArrayAccess [$i $j $H] := [<:tactic: < Elim (Z_eq_dec $i $j); [ Intro $H; Rewrite $H; Rewrite store_def_1 | Intro $H; Rewrite store_def_2; [ Idtac | Idtac | Idtac | Exact $H ] ] >>]. (* Syntax and pretty-print for arrays *) Grammar command command0 := array_access [ ident($t) "#" "[" command($c) "]" ] -> [ <<(access $t $c)>> ]. Syntax constr level 0 : array_access [ (APPLIST <> ($VAR $t) $c) ] -> [ $t "#[" $c:L "]" ].