-
Notifications
You must be signed in to change notification settings - Fork 0
/
lemmas-subst-matching.agda
63 lines (61 loc) · 1.98 KB
/
lemmas-subst-matching.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
open import List
open import Nat
open import Prelude
open import constraints-core
open import contexts
open import core
open import dynamics-core
open import lemmas-satisfy
open import lemmas-subst-value
open import patterns-core
open import result-judgements
open import satisfy-decidable
open import statics-core
-- a given matching judgement still holds
-- after substituting a variable in the expression
module lemmas-subst-matching where
subst-mat : ∀{x e1 e2 τ p θ1} →
e1 ·: τ ▹ p ⊣ θ1 →
Σ[ θ2 ∈ subst-list ] (([ e2 / x ] e1) ·: τ ▹ p ⊣ θ2)
subst-mat MUnit = [] , MUnit
subst-mat MNum = [] , MNum
subst-mat {x = x} {e1 = e1} {e2 = e2} {τ = τ}
(MVar {x = y}) =
([ e2 / x ] e1 , τ , y) :: [] , MVar
subst-mat (MInl mat)
with subst-mat mat
... | θ1 , smat = θ1 , MInl smat
subst-mat (MInr mat)
with subst-mat mat
... | θ1 , smat = θ1 , MInr smat
subst-mat (MPair mat1 mat2)
with subst-mat mat1 | subst-mat mat2
... | θ1 , smat1 | θ2 , smat2 =
θ1 ++ θ2 , MPair smat1 smat2
subst-mat (MNotIntroPair ni mat1 mat2)
with subst-mat mat1 | subst-mat mat2
... | θ1 , smat1 | θ2 , smat2 =
θ1 ++ θ2 ,
MNotIntroPair (subst-notintro ni) smat1 smat2
subst-mat MWild = [] , MWild
subst-maymat : ∀{x e1 e2 τ p} →
e1 ·: τ ?▹ p →
([ e2 / x ] e1) ·: τ ?▹ p
subst-maymat (MMNotIntro ni ref) =
MMNotIntro (subst-notintro ni) ref
subst-maymat (MMInl mmat) =
MMInl (subst-maymat mmat)
subst-maymat (MMInr mmat) =
MMInr (subst-maymat mmat)
subst-maymat (MMPairL mmat1 mat2)
with subst-mat mat2
... | θ2 , smat2 =
MMPairL (subst-maymat mmat1) smat2
subst-maymat (MMPairR mat1 mmat2)
with subst-mat mat1
... | θ1 , smat1 =
MMPairR smat1 (subst-maymat mmat2)
subst-maymat (MMPair mmat1 mmat2) =
MMPair (subst-maymat mmat1) (subst-maymat mmat2)
subst-maymat MMEHole = MMEHole
subst-maymat MMHole = MMHole