| 1 |
Axiom proof_admitted : False. |
| 2 |
Tactic Notation "admit" := abstract case proof_admitted. |
| 3 |
|
| 4 |
Definition relation := fun A : Type => A -> A -> Prop. |
| 5 |
|
| 6 |
Class Decision (P : Prop) := decide : {P} + {not P}. |
| 7 |
Global Arguments decide _ {_} : simpl never, assert. |
| 8 |
|
| 9 |
Class Inj {A B} (R : relation A) (S : relation B) (f : A -> B) : Prop := |
| 10 |
inj x y : S (f x) (f y) -> R x y. |
| 11 |
|
| 12 |
Definition kmap {K1} {K2} {M1} {M2 : Type -> Type} {A} (f : K1 -> K2) (m : M1 A) : M2 A. |
| 13 |
admit. |
| 14 |
Defined. |
| 15 |
Definition kmap_inj {K1} {K2} {M1} {M2 : Type -> Type} {A} (f : K1 -> K2) (m : M1 A) : Inj (@eq (M1 A)) (eq) (@kmap K1 K2 M1 M2 A f). |
| 16 |
Admitted. |
| 17 |
|
| 18 |
Module Export functions. |
| 19 |
|
| 20 |
Section dep_fn_insert. |
| 21 |
Context {A : Type} `{forall x y:A, Decision (eq x y)} {T : A -> Type}. |
| 22 |
|
| 23 |
Import EqNotations. |
| 24 |
Definition dep_fn_insert a0 (t : T a0) (f : forall a : A, T a) : forall a : A, T a. |
| 25 |
exact (fun a => |
| 26 |
match decide (a0 = a) with |
| 27 |
| left E => rew E in t |
| 28 |
| right _ => f a |
| 29 |
end). |
| 30 |
Defined. |
| 31 |
End dep_fn_insert. |
| 32 |
|
| 33 |
End functions. |
| 34 |
|
| 35 |
Module Export Sts. |
| 36 |
|
| 37 |
Record sts {Label : Type} : Type := |
| 38 |
{ _state :> Type }. |
| 39 |
#[global] Arguments sts _ : clear implicits. |
| 40 |
|
| 41 |
Record t := |
| 42 |
{ Label : Type |
| 43 |
; _sts :> sts Label }. |
| 44 |
#[global] Arguments Build_t {_} _. |
| 45 |
Definition State (x : t) := x.(_sts).(_state). |
| 46 |
End Sts. |
| 47 |
|
| 48 |
Module Export Compose. |
| 49 |
|
| 50 |
Record config := { |
| 51 |
name : Set; |
| 52 |
external_event : Set; |
| 53 |
sts_name : name -> Sts.t; |
| 54 |
}. |
| 55 |
End Compose. |
| 56 |
|
| 57 |
Section Compose. |
| 58 |
Context (sf: config). |
| 59 |
Definition State : Type. |
| 60 |
exact (forall n, Sts.State (sts_name sf n)). |
| 61 |
Defined. |
| 62 |
Definition compose_lts : Sts.sts (external_event sf). |
| 63 |
exact ({| |
| 64 |
Sts._state := State; |
| 65 |
|}). |
| 66 |
Defined. |
| 67 |
End Compose. |
| 68 |
Variant guestT := guest | host. |
| 69 |
|
| 70 |
Variant t : Set := A. |
| 71 |
|
| 72 |
Class Types {arch : t} := MKTYPES { |
| 73 |
regs_t : guestT -> Type; |
| 74 |
}. |
| 75 |
|
| 76 |
Module Export isa. |
| 77 |
|
| 78 |
Module Type OPSEM_ISA. |
| 79 |
End OPSEM_ISA. |
| 80 |
|
| 81 |
End isa. |
| 82 |
|
| 83 |
Module Export nova. |
| 84 |
|
| 85 |
Module Type NOVA_ISA. |
| 86 |
Module Export opsem_isa. |
| 87 |
End opsem_isa. |
| 88 |
End NOVA_ISA. |
| 89 |
|
| 90 |
End nova. |
| 91 |
|
| 92 |
Module Export aarch64. |
| 93 |
|
| 94 |
Module Import isa. |
| 95 |
|
| 96 |
Module Type aarch64. |
| 97 |
|
| 98 |
Definition the_arch := A. |
| 99 |
End aarch64. |
| 100 |
End isa. |
| 101 |
|
| 102 |
Module Export nova. |
| 103 |
|
| 104 |
Module Export Nova_aarch64. |
| 105 |
Module Export opsem_isa. |
| 106 |
Include aarch64. |
| 107 |
End opsem_isa. |
| 108 |
|
| 109 |
End Nova_aarch64. |
| 110 |
|
| 111 |
Implicit Types (is_guest : guestT). |
| 112 |
|
| 113 |
Module Type CPU_STS_BASE. |
| 114 |
Parameter cpu_sts : forall is_guest, Sts.t. |
| 115 |
|
| 116 |
End CPU_STS_BASE. |
| 117 |
|
| 118 |
Module Type CPU_STS_DERIVED (Import cpu_sts_base : CPU_STS_BASE). |
| 119 |
|
| 120 |
Module Export regs. |
| 121 |
Definition t is_guest : Type. |
| 122 |
exact (Sts.State (cpu_sts is_guest)). |
| 123 |
Defined. |
| 124 |
End regs. |
| 125 |
End CPU_STS_DERIVED. |
| 126 |
|
| 127 |
Module Type CPU_STS := CPU_STS_BASE <+ CPU_STS_DERIVED. |
| 128 |
|
| 129 |
Module Type CPU_REGS (isa_regs : OPSEM_ISA) := |
| 130 |
CPU_STS. |
| 131 |
|
| 132 |
Section cpuid. |
| 133 |
Definition gicv : Sts.t. |
| 134 |
Admitted. |
| 135 |
End cpuid. |
| 136 |
|
| 137 |
Module Export cpu_regs. |
| 138 |
|
| 139 |
Module Export guest. |
| 140 |
Variant name : Set := | NAME. |
| 141 |
Definition sts_config : Compose.config. |
| 142 |
exact ({| Compose.name := name |
| 143 |
; Compose.external_event := False |
| 144 |
; Compose.sts_name nm := |
| 145 |
match nm with |
| 146 |
| NAME => gicv |
| 147 |
end |
| 148 |
|}). |
| 149 |
Defined. |
| 150 |
Definition sts : Sts.sts False. |
| 151 |
exact (compose_lts sts_config). |
| 152 |
Defined. |
| 153 |
End guest. |
| 154 |
|
| 155 |
Definition cpu_sts (is_guest : guestT) : Sts.t. |
| 156 |
exact (if is_guest |
| 157 |
then Sts.Build_t guest.sts |
| 158 |
else Sts.Build_t guest.sts). |
| 159 |
Defined. |
| 160 |
|
| 161 |
Include CPU_STS_DERIVED. |
| 162 |
|
| 163 |
End cpu_regs. |
| 164 |
|
| 165 |
Module NOVA_STATE_DEFS (Import nova_isa : NOVA_ISA) (Import opsem_cpu : CPU_REGS nova_isa.opsem_isa). |
| 166 |
|
| 167 |
#[global] Instance nova_arch_types : @Types the_arch. |
| 168 |
exact ({| |
| 169 |
regs_t := opsem_cpu.regs.t ; |
| 170 |
|}). |
| 171 |
Defined. |
| 172 |
|
| 173 |
End NOVA_STATE_DEFS. |
| 174 |
Module Import M := NOVA_STATE_DEFS aarch64.nova.Nova_aarch64 cpu_regs. |
| 175 |
Create HintDb empty. |
| 176 |
|
| 177 |
Goal forall eqdec v (vRegs : @Sts._state False cpu_regs.guest.sts), |
| 178 |
(@Inj (@Sts._state False cpu_regs.guest.sts) (@regs_t _ nova_arch_types guest) |
| 179 |
(@eq (@Sts._state False cpu_regs.guest.sts)) (@eq (@regs_t _ nova_arch_types guest)) |
| 180 |
(@functions.dep_fn_insert cpu_regs.guest.name eqdec |
| 181 |
(fun x : cpu_regs.guest.name => |
| 182 |
Sts.State |
| 183 |
match x return Sts.t with |
| 184 |
| cpu_regs.guest.NAME => gicv |
| 185 |
end) cpu_regs.guest.NAME (v (vRegs cpu_regs.guest.NAME)))). |
| 186 |
Proof. |
| 187 |
intros. |
| 188 |
Fail autoapply @kmap_inj with empty. |
| 189 |
Abort. |
| 190 |
End nova. |
| 191 |
End aarch64. |