-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCastStructureWithPrecision.agda
72 lines (63 loc) · 3.12 KB
/
CastStructureWithPrecision.agda
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
open import Relation.Binary.PropositionalEquality using (_≡_;_≢_; refl; trans; sym; cong)
open import Data.Product using (_×_; proj₁; proj₂; ∃; ∃-syntax) renaming (_,_ to ⟨_,_⟩)
open import Types
open import Variables
open import PreCastStructureWithPrecision
open import CastStructure
import ParamCastCalculus
import ParamCastAux
import ParamCCPrecision
module CastStructureWithPrecision where
import ParamCastReduction
record CastStructWithPrecision : Set₁ where
field
pcsp : PreCastStructWithPrecision
open PreCastStructWithPrecision pcsp public
open ParamCastCalculus Cast Inert
open ParamCastAux precast
open ParamCCPrecision pcsp
field
applyCast : ∀{Γ A B} → (M : Γ ⊢ A) → Value M → (c : Cast (A ⇒ B))
→ ∀ {a : Active c} → Γ ⊢ B
cs : CastStruct
cs = record { precast = precast; applyCast = applyCast }
open ParamCastReduction cs
field
{- This field is for gradual guarantees.
Because the implementation of `applyCast` is unique to each cast representation,
we need to prove this lemma for each specific representation as well. -}
applyCast-catchup : ∀ {Γ Γ′ A A′ B} {V : Γ ⊢ A} {V′ : Γ′ ⊢ A′} {c : Cast (A ⇒ B)}
→ (a : Active c)
→ (vV : Value V) → Value V′
→ A ⊑ A′ → B ⊑ A′
→ Γ , Γ′ ⊢ V ⊑ᶜ V′
-----------------------------------------------------------------------
→ ∃[ W ] ((Value W) × (applyCast V vV c {a} —↠ W) × (Γ , Γ′ ⊢ W ⊑ᶜ V′))
sim-cast : ∀ {A A′ B B′} {V : ∅ ⊢ A} {V′ : ∅ ⊢ A′} {c : Cast (A ⇒ B)} {c′ : Cast (A′ ⇒ B′)}
→ Value V → (v′ : Value V′)
→ (a′ : Active c′)
→ A ⊑ A′ → B ⊑ B′
→ ∅ , ∅ ⊢ V ⊑ᶜ V′
------------------------------------------------------------
→ ∃[ N ] ((V ⟨ c ⟩ —↠ N) × (∅ , ∅ ⊢ N ⊑ᶜ applyCast V′ v′ c′ {a′}))
sim-wrap : ∀ {A A′ B B′} {V : ∅ ⊢ A} {V′ : ∅ ⊢ A′} {c : Cast (A ⇒ B)} {c′ : Cast (A′ ⇒ B′)}
→ Value V → (v′ : Value V′)
→ (i′ : Inert c′)
→ A ⊑ A′ → B ⊑ B′
→ ∅ , ∅ ⊢ V ⊑ᶜ V′
-----------------------------------------------------
→ ∃[ N ] ((V ⟨ c ⟩ —↠ N) × (∅ , ∅ ⊢ N ⊑ᶜ V′ ⟪ i′ ⟫))
castr-cast : ∀ {A A′ B′} {V : ∅ ⊢ A} {V′ : ∅ ⊢ A′} {c′ : Cast (A′ ⇒ B′)}
→ Value V → (v′ : Value V′)
→ (a′ : Active c′)
→ A ⊑ A′ → A ⊑ B′
→ ∅ , ∅ ⊢ V ⊑ᶜ V′
------------------------------------------------------------
→ ∅ , ∅ ⊢ V ⊑ᶜ applyCast V′ v′ c′ {a′}
castr-wrap : ∀ {A A′ B′} {V : ∅ ⊢ A} {V′ : ∅ ⊢ A′} {c′ : Cast (A′ ⇒ B′)}
→ Value V → (v′ : Value V′)
→ (i′ : Inert c′)
→ A ⊑ A′ → A ⊑ B′
→ ∅ , ∅ ⊢ V ⊑ᶜ V′
-----------------------------------------------------
→ ∅ , ∅ ⊢ V ⊑ᶜ V′ ⟪ i′ ⟫