Debian Codegraph @

test-suite/primitive/arrays/set.v

raw
1 From Corelib Require Import PrimInt63 PrimArray.
2
3 Open Scope array_scope.
4
5 Definition t : array nat := [| 1; 3; 2 | 4 |].
6 Definition t' : array nat := t.[1 <- 5].
7
8 Definition foo1 := (eq_refl : t'.[1] = 5).
9 Definition foo2 := (eq_refl 5 <: t'.[1] = 5).
10 Definition foo3 := (eq_refl 5 <<: t'.[1] = 5).
11 Definition x1 := Eval compute in t'.[1].
12 Definition foo4 := (eq_refl : x1 = 5).
13 Definition x2 := Eval cbn in t'.[1].
14 Definition foo5 := (eq_refl : x2 = 5).
15
16 Definition foo6 := (eq_refl : t.[1] = 3).
17 Definition foo7 := (eq_refl 3 <: t.[1] = 3).
18 Definition foo8 := (eq_refl 3 <<: t.[1] = 3).
19 Definition x3 := Eval compute in t.[1].
20 Definition foo9 := (eq_refl : x3 = 3).
21 Definition x4 := Eval cbn in t.[1].
22 Definition foo10 := (eq_refl : x4 = 3).
23
24 Ltac check_const_eq name constr :=
25 let v := (eval cbv delta [name] in name) in
26 tryif constr_eq v constr
27 then idtac
28 else fail 0 "Not syntactically equal:" name ":=" v "<>" constr.
29
30 Notation check_const_eq name constr := (ltac:(check_const_eq name constr; exact constr)) (only parsing).
31
32 (* Stuck primitive *)
33 Definition lazy_stuck_set := Eval lazy in (fun A (t : array A) v => t.[1 <- v]).
34 Definition vm_stuck_set := Eval vm_compute in (fun A (t : array A) v => t.[1 <- v]).
35 Definition native_stuck_set := Eval native_compute in (fun A (t : array A) v => t.[1 <- v]).
36 Definition compute_stuck_set := Eval compute in (fun A (t : array A) v => t.[1 <- v]).
37 Definition cbn_stuck_set := Eval cbn in (fun A (t : array A) v => t.[1 <- v]).
38
39 Check check_const_eq lazy_stuck_set (fun A (t : array A) v => t.[1 <- v]).
40 Check check_const_eq vm_stuck_set (fun A (t : array A) v => t.[1 <- v]).
41 Check check_const_eq native_stuck_set (fun A (t : array A) v => t.[1 <- v]).
42 Check check_const_eq compute_stuck_set (fun A (t : array A) v => t.[1 <- v]).
43 Check check_const_eq cbn_stuck_set (fun A (t : array A) v => t.[1 <- v]).
44
45 (* Not stuck primitive, but with an accumulator as last argument *)
46 Definition lazy_accu_set := Eval lazy in (fun v => t.[1 <- v]).
47 Definition vm_accu_set := Eval vm_compute in (fun v => t.[1 <- v]).
48 Definition native_accu_set := Eval native_compute in (fun v => t.[1 <- v]).
49 Definition compute_accu_set := Eval compute in (fun v => t.[1 <- v]).
50 Definition cbn_accu_set := Eval cbn in (fun v => t.[1 <- v]).
51
52 Check check_const_eq lazy_accu_set (fun v => [| 1; v; 2 | 4 |]).
53 Check check_const_eq vm_accu_set (fun v => [| 1; v; 2 | 4 |]).
54 Check check_const_eq native_accu_set (fun v => [| 1; v; 2 | 4 |]).
55 Check check_const_eq compute_accu_set (fun v => [| 1; v; 2 | 4 |]).
56 Check check_const_eq cbn_accu_set (fun v => [| 1; v; 2 | 4 |]).
57
58 (* Under-application *)
59 Definition lazy_set := Eval lazy in @PrimArray.set.
60 Definition vm_set := Eval vm_compute in @PrimArray.set.
61 Definition native_set := Eval native_compute in @PrimArray.set.
62 Definition compute_set := Eval compute in @PrimArray.set.
63 Definition cbn_set := Eval cbn in @PrimArray.set.
64
65 Check check_const_eq lazy_set (@PrimArray.set).
66 Check check_const_eq vm_set (fun A (t : array A) i v => t.[i <- v]).
67 Check check_const_eq native_set (fun A (t : array A) i v => t.[i <- v]).
68 Check check_const_eq compute_set (@PrimArray.set).
69 Check check_const_eq cbn_set (@PrimArray.set).