Skip to content

Commit

Permalink
Reverse the index of ReflexiveTransitiveClosureᵢ
Browse files Browse the repository at this point in the history
  • Loading branch information
WhatisRT authored and Soupstraw committed Apr 29, 2024
1 parent ed315b0 commit 42bca56
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions src/Interface/STS.agda
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private
s s' s'' : S
sig : Sig
sigs : List Sig
n :

-- small-step to big-step transformer

Expand All @@ -50,21 +51,24 @@ module _ (_⊢_⇀⟦_⟧ᵇ_ : C → S → ⊤ → S → Set) (_⊢_⇀⟦_⟧_
Γ ⊢ s ⇀⟦ sig ⟧ s'
Γ ⊢ s' ⇀⟦ sigs ⟧* s''
───────────────────────────────────────
Γ ⊢ s ⇀⟦ sig ∷ sigs ⟧* s''
Γ ⊢ s ⇀⟦ sig ∷ sigs ⟧* s''

module _ (_⊢_⇀⟦_⟧ᵇ_ : C S S Set) (_⊢_⇀⟦_⟧_ : C × ℕ S Sig S Set) where
data _⊢_⇀⟦_⟧ᵢ*_ : C S List Sig S Set where
data _⊢_⇀⟦_⟧ᵢ*'_ : C × ℕ S List Sig S Set where

BS-base :
Γ ⊢ s ⇀⟦ _ ⟧ᵇ s'
───────────────────────────────────────
Γ ⊢ s ⇀⟦ [] ⟧ᵢ* s'
(Γ , n) ⊢ s ⇀⟦ [] ⟧ᵢ*' s'

BS-ind :
(Γ , length sigs) ⊢ s ⇀⟦ sig ⟧ s'
Γ ⊢ s' ⇀⟦ sigs ⟧ᵢ* s''
(Γ , n) ⊢ s ⇀⟦ sig ⟧ s'
(Γ , suc n) ⊢ s' ⇀⟦ sigs ⟧ᵢ*' s''
───────────────────────────────────────
Γ ⊢ s ⇀⟦ sig ∷ sigs ⟧ᵢ* s''
(Γ , n) ⊢ s ⇀⟦ sig ∷ sigs ⟧ᵢ*' s''

_⊢_⇀⟦_⟧ᵢ*_ : C S List Sig S Set
_⊢_⇀⟦_⟧ᵢ*_ Γ = _⊢_⇀⟦_⟧ᵢ*'_ (Γ , 0)

data IdSTS {C S} : C S S Set where
Id-nop : IdSTS Γ s _ s
Expand All @@ -73,9 +77,11 @@ data IdSTS {C S} : C → S → ⊤ → S → Set where
ReflexiveTransitiveClosure : (C S Sig S Set) C S List Sig S Set
ReflexiveTransitiveClosure = _⊢_⇀⟦_⟧*_ IdSTS

STS-total : (C S Sig S Set) Set
STS-total _⊢_⇀⟦_⟧_ = {Γ s sig} ∃[ s' ] Γ ⊢ s ⇀⟦ sig ⟧ s'

ReflexiveTransitiveClosure-total : {_⊢_⇀⟦_⟧_ : C S Sig S Set}
( {Γ s sig} ∃[ s' ] Γ ⊢ s ⇀⟦ sig ⟧ s')
( {Γ s sig} ∃[ s' ] ReflexiveTransitiveClosure _⊢_⇀⟦_⟧_ Γ s sig s')
STS-total _⊢_⇀⟦_⟧_ STS-total (ReflexiveTransitiveClosure _⊢_⇀⟦_⟧_)
ReflexiveTransitiveClosure-total SS-total {Γ} {s} {[]} = s , BS-base Id-nop
ReflexiveTransitiveClosure-total SS-total {Γ} {s} {x ∷ sig} =
case SS-total of λ where
Expand All @@ -85,12 +91,15 @@ ReflexiveTransitiveClosureᵢ : (C × ℕ → S → Sig → S → Set) → C →
ReflexiveTransitiveClosureᵢ = _⊢_⇀⟦_⟧ᵢ*_ IdSTS

ReflexiveTransitiveClosureᵢ-total : {_⊢_⇀⟦_⟧_ : C × ℕ S Sig S Set}
( {Γ s sig} ∃[ s' ] Γ ⊢ s ⇀⟦ sig ⟧ s')
( {Γ s sig} ∃[ s' ] ReflexiveTransitiveClosureᵢ _⊢_⇀⟦_⟧_ Γ s sig s')
ReflexiveTransitiveClosureᵢ-total SS-total {s = s} {[]} = s , BS-base Id-nop
ReflexiveTransitiveClosureᵢ-total SS-total {s = s} {x ∷ sig} =
case SS-total of λ where
(s' , Ps') map₂′ (BS-ind Ps') $ ReflexiveTransitiveClosureᵢ-total SS-total
STS-total _⊢_⇀⟦_⟧_ STS-total (ReflexiveTransitiveClosureᵢ _⊢_⇀⟦_⟧_)
ReflexiveTransitiveClosureᵢ-total SS-total = helper SS-total
where
helper : {_⊢_⇀⟦_⟧_ : C × ℕ S Sig S Set}
STS-total _⊢_⇀⟦_⟧_ STS-total (_⊢_⇀⟦_⟧ᵢ*'_ IdSTS _⊢_⇀⟦_⟧_)
helper SS-total {s = s} {[]} = s , BS-base Id-nop
helper SS-total {s = s} {x ∷ sig} =
case SS-total of λ where
(s' , Ps') map₂′ (BS-ind Ps') $ helper SS-total

-- with a given base case
ReflexiveTransitiveClosureᵢᵇ = _⊢_⇀⟦_⟧ᵢ*_
Expand Down

0 comments on commit 42bca56

Please sign in to comment.