Debian Codegraph @

src/Reflection/AST/Term.agda

raw
1 ------------------------------------------------------------------------
2 -- The Agda standard library
3 --
4 -- Terms used in the reflection machinery
5 ------------------------------------------------------------------------
6
7 {-# OPTIONS --cubical-compatible --safe #-}
8
9 module Reflection.AST.Term where
10
11 open import Data.List.Base as List hiding (_++_)
12 open import Data.List.Properties using (∷-dec)
13 open import Data.Nat.Base using (ℕ; zero; suc)
14 import Data.Nat.Properties as ℕ using (_≟_)
15 open import Data.Product.Base using (_×_; _,_; <_,_>; uncurry; map₁)
16 open import Data.Product.Properties using (,-injective)
17 open import Data.Maybe.Base using (Maybe; just; nothing)
18 open import Data.String.Base using (String)
19 open import Data.String.Properties as String hiding (_≟_)
20 open import Relation.Nullary.Decidable using (map′; _×-dec_; yes; no)
21 open import Relation.Binary.Definitions using (Decidable; DecidableEquality)
22 open import Relation.Binary.PropositionalEquality.Core using (_≡_; refl; cong; cong₂)
23 open import Reflection.AST.Abstraction using (Abs; abs; unAbs-dec)
24 open import Reflection.AST.Argument as Arg
25 open import Reflection.AST.Argument.Information using (visibility)
26 open import Reflection.AST.Argument.Visibility as Visibility hiding (_≟_)
27 import Reflection.AST.Literal as Literal using (Literal; _≟_)
28 import Reflection.AST.Meta as Meta using (Meta; _≟_)
29 open import Reflection.AST.Name as Name using (Name)
30
31 ------------------------------------------------------------------------
32 -- Re-exporting the builtin type and constructors
33
34 open import Agda.Builtin.Reflection as Builtin public
35 using (Sort; Type; Term; Clause; Pattern)
36
37 open Term public
38 renaming (agda-sort to sort)
39
40 open Sort public
41 open Clause public
42 open Pattern public
43
44 ------------------------------------------------------------------------
45 -- Handy synonyms
46
47 Clauses : Set
48 Clauses = List Clause
49
50 Telescope : Set
51 Telescope = List (String × Arg Type)
52
53 -- Pattern synonyms for more compact presentation
54
55 pattern vLam s t = lam visible (abs s t)
56 pattern hLam s t = lam hidden (abs s t)
57 pattern iLam s t = lam instance′ (abs s t)
58 pattern Π[_∶_]_ s a ty = pi a (abs s ty)
59 pattern vΠ[_∶_]_ s a ty = Π[ s ∶ (vArg a) ] ty
60 pattern hΠ[_∶_]_ s a ty = Π[ s ∶ (hArg a) ] ty
61 pattern iΠ[_∶_]_ s a ty = Π[ s ∶ (iArg a) ] ty
62
63 ------------------------------------------------------------------------
64 -- Utility functions
65
66 getName : Term → Maybe Name
67 getName (con c args) = just c
68 getName (def f args) = just f
69 getName _ = nothing
70
71 -- "n ⋯⟨∷⟩ xs" prepends "n" visible unknown arguments to the list of
72 -- arguments. Useful when constructing the list of arguments for a
73 -- function with initial inferrable arguments.
74 infixr 5 _⋯⟨∷⟩_
75 _⋯⟨∷⟩_ : ℕ → Args Term → Args Term
76 zero ⋯⟨∷⟩ xs = xs
77 suc i ⋯⟨∷⟩ xs = unknown ⟨∷⟩ (i ⋯⟨∷⟩ xs)
78 {-# INLINE _⋯⟨∷⟩_ #-}
79
80 -- "n ⋯⟅∷⟆ xs" prepends "n" hidden unknown arguments to the list of
81 -- arguments. Useful when constructing the list of arguments for a
82 -- function with initial implicit arguments.
83 infixr 5 _⋯⟅∷⟆_
84 _⋯⟅∷⟆_ : ℕ → Args Term → Args Term
85 zero ⋯⟅∷⟆ xs = xs
86 suc i ⋯⟅∷⟆ xs = unknown ⟅∷⟆ (i ⋯⟅∷⟆ xs)
87 {-# INLINE _⋯⟅∷⟆_ #-}
88
89 -- Strips off any pi bindings returning the list of variables removed
90 -- and the eventual body of the expression, e.g.
91 --
92 -- stripPis `∀ x {y} → f x y` = (["x", "y"], f x y)
93 stripPis : Term → List (String × Arg Type) × Term
94 stripPis (Π[ s ∶ t ] x) = map₁ ((s , t) ∷_) (stripPis x)
95 stripPis x = [] , x
96
97 prependLams : List (String × Visibility) → Term → Term
98 prependLams xs t = foldr (λ {(s , v) t → lam v (abs s t)}) t (reverse xs)
99
100 prependHLams : List String → Term → Term
101 prependHLams vs = prependLams (List.map (_, hidden) vs)
102
103 prependVLams : List String → Term → Term
104 prependVLams vs = prependLams (List.map (_, visible) vs)
105
106 ------------------------------------------------------------------------
107 -- Decidable equality
108
109 clause-injective₁ : ∀ {tel tel′ ps ps′ b b′} → clause tel ps b ≡ clause tel′ ps′ b′ → tel ≡ tel′
110 clause-injective₁ refl = refl
111
112 clause-injective₂ : ∀ {tel tel′ ps ps′ b b′} → clause tel ps b ≡ clause tel′ ps′ b′ → ps ≡ ps′
113 clause-injective₂ refl = refl
114
115 clause-injective₃ : ∀ {tel tel′ ps ps′ b b′} → clause tel ps b ≡ clause tel′ ps′ b′ → b ≡ b′
116 clause-injective₃ refl = refl
117
118 clause-injective : ∀ {tel tel′ ps ps′ b b′} → clause tel ps b ≡ clause tel′ ps′ b′ → tel ≡ tel′ × ps ≡ ps′ × b ≡ b′
119 clause-injective = < clause-injective₁ , < clause-injective₂ , clause-injective₃ > >
120
121 absurd-clause-injective₁ : ∀ {tel tel′ ps ps′} → absurd-clause tel ps ≡ absurd-clause tel′ ps′ → tel ≡ tel′
122 absurd-clause-injective₁ refl = refl
123
124 absurd-clause-injective₂ : ∀ {tel tel′ ps ps′} → absurd-clause tel ps ≡ absurd-clause tel′ ps′ → ps ≡ ps′
125 absurd-clause-injective₂ refl = refl
126
127 absurd-clause-injective : ∀ {tel tel′ ps ps′} → absurd-clause tel ps ≡ absurd-clause tel′ ps′ → tel ≡ tel′ × ps ≡ ps′
128 absurd-clause-injective = < absurd-clause-injective₁ , absurd-clause-injective₂ >
129
130 infix 4 _≟-AbsTerm_ _≟-AbsType_ _≟-ArgTerm_ _≟-ArgType_ _≟-Args_
131 _≟-Clause_ _≟-Clauses_ _≟_
132 _≟-Sort_ _≟-Pattern_ _≟-Patterns_ _≟-Telescope_
133
134 _≟-AbsTerm_ : DecidableEquality (Abs Term)
135 _≟-AbsType_ : DecidableEquality (Abs Type)
136 _≟-ArgTerm_ : DecidableEquality (Arg Term)
137 _≟-ArgType_ : DecidableEquality (Arg Type)
138 _≟-Args_ : DecidableEquality (Args Term)
139 _≟-Clause_ : DecidableEquality Clause
140 _≟-Clauses_ : DecidableEquality Clauses
141 _≟_ : DecidableEquality Term
142 _≟-Sort_ : DecidableEquality Sort
143 _≟-Patterns_ : DecidableEquality (Args Pattern)
144 _≟-Pattern_ : DecidableEquality Pattern
145
146 -- Decidable equality 'transformers'
147 -- We need to inline these because the terms are not sized so
148 -- termination would not obvious if we were to use higher-order
149 -- functions such as Data.List.Properties' ≡-dec
150
151 abs s a ≟-AbsTerm abs s′ a′ = unAbs-dec (a ≟ a′)
152 abs s a ≟-AbsType abs s′ a′ = unAbs-dec (a ≟ a′)
153 arg i a ≟-ArgTerm arg i′ a′ = unArg-dec (a ≟ a′)
154 arg i a ≟-ArgType arg i′ a′ = unArg-dec (a ≟ a′)
155
156 [] ≟-Args [] = yes refl
157 (x ∷ xs) ≟-Args (y ∷ ys) = ∷-dec (x ≟-ArgTerm y) (xs ≟-Args ys)
158 [] ≟-Args (_ ∷ _) = no λ()
159 (_ ∷ _) ≟-Args [] = no λ()
160
161 [] ≟-Clauses [] = yes refl
162 (x ∷ xs) ≟-Clauses (y ∷ ys) = ∷-dec (x ≟-Clause y) (xs ≟-Clauses ys)
163 [] ≟-Clauses (_ ∷ _) = no λ()
164 (_ ∷ _) ≟-Clauses [] = no λ()
165
166 _≟-Telescope_ : DecidableEquality Telescope
167 [] ≟-Telescope [] = yes refl
168 ((x , t) ∷ tel) ≟-Telescope ((x′ , t′) ∷ tel′) = ∷-dec
169 (map′ (uncurry (cong₂ _,_)) ,-injective ((x String.≟ x′) ×-dec (t ≟-ArgTerm t′)))
170 (tel ≟-Telescope tel′)
171 [] ≟-Telescope (_ ∷ _) = no λ ()
172 (_ ∷ _) ≟-Telescope [] = no λ ()
173
174 clause tel ps b ≟-Clause clause tel′ ps′ b′ =
175 map′ (λ (tel≡tel′ , ps≡ps′ , b≡b′) → cong₂ (uncurry clause) (cong₂ _,_ tel≡tel′ ps≡ps′) b≡b′)
176 clause-injective
177 (tel ≟-Telescope tel′ ×-dec ps ≟-Patterns ps′ ×-dec b ≟ b′)
178 absurd-clause tel ps ≟-Clause absurd-clause tel′ ps′ =
179 map′ (uncurry (cong₂ absurd-clause))
180 absurd-clause-injective
181 (tel ≟-Telescope tel′ ×-dec ps ≟-Patterns ps′)
182 clause _ _ _ ≟-Clause absurd-clause _ _ = no λ()
183 absurd-clause _ _ ≟-Clause clause _ _ _ = no λ()
184
185 var-injective₁ : ∀ {x x′ args args′} → Term.var x args ≡ var x′ args′ → x ≡ x′
186 var-injective₁ refl = refl
187
188 var-injective₂ : ∀ {x x′ args args′} → Term.var x args ≡ var x′ args′ → args ≡ args′
189 var-injective₂ refl = refl
190
191 var-injective : ∀ {x x′ args args′} → var x args ≡ var x′ args′ → x ≡ x′ × args ≡ args′
192 var-injective = < var-injective₁ , var-injective₂ >
193
194 con-injective₁ : ∀ {c c′ args args′} → Term.con c args ≡ con c′ args′ → c ≡ c′
195 con-injective₁ refl = refl
196
197 con-injective₂ : ∀ {c c′ args args′} → Term.con c args ≡ con c′ args′ → args ≡ args′
198 con-injective₂ refl = refl
199
200 con-injective : ∀ {c c′ args args′} → con c args ≡ con c′ args′ → c ≡ c′ × args ≡ args′
201 con-injective = < con-injective₁ , con-injective₂ >
202
203 def-injective₁ : ∀ {f f′ args args′} → def f args ≡ def f′ args′ → f ≡ f′
204 def-injective₁ refl = refl
205
206 def-injective₂ : ∀ {f f′ args args′} → def f args ≡ def f′ args′ → args ≡ args′
207 def-injective₂ refl = refl
208
209 def-injective : ∀ {f f′ args args′} → def f args ≡ def f′ args′ → f ≡ f′ × args ≡ args′
210 def-injective = < def-injective₁ , def-injective₂ >
211
212 meta-injective₁ : ∀ {x x′ args args′} → meta x args ≡ meta x′ args′ → x ≡ x′
213 meta-injective₁ refl = refl
214
215 meta-injective₂ : ∀ {x x′ args args′} → meta x args ≡ meta x′ args′ → args ≡ args′
216 meta-injective₂ refl = refl
217
218 meta-injective : ∀ {x x′ args args′} → meta x args ≡ meta x′ args′ → x ≡ x′ × args ≡ args′
219 meta-injective = < meta-injective₁ , meta-injective₂ >
220
221 lam-injective₁ : ∀ {v v′ t t′} → lam v t ≡ lam v′ t′ → v ≡ v′
222 lam-injective₁ refl = refl
223
224 lam-injective₂ : ∀ {v v′ t t′} → lam v t ≡ lam v′ t′ → t ≡ t′
225 lam-injective₂ refl = refl
226
227 lam-injective : ∀ {v v′ t t′} → lam v t ≡ lam v′ t′ → v ≡ v′ × t ≡ t′
228 lam-injective = < lam-injective₁ , lam-injective₂ >
229
230 pat-lam-injective₁ : ∀ {cs cs′ args args′} → pat-lam cs args ≡ pat-lam cs′ args′ → cs ≡ cs′
231 pat-lam-injective₁ refl = refl
232
233 pat-lam-injective₂ : ∀ {cs cs′ args args′} → pat-lam cs args ≡ pat-lam cs′ args′ → args ≡ args′
234 pat-lam-injective₂ refl = refl
235
236 pat-lam-injective : ∀ {cs cs′ args args′} → pat-lam cs args ≡ pat-lam cs′ args′ → cs ≡ cs′ × args ≡ args′
237 pat-lam-injective = < pat-lam-injective₁ , pat-lam-injective₂ >
238
239 pi-injective₁ : ∀ {t₁ t₁′ t₂ t₂′} → pi t₁ t₂ ≡ pi t₁′ t₂′ → t₁ ≡ t₁′
240 pi-injective₁ refl = refl
241
242 pi-injective₂ : ∀ {t₁ t₁′ t₂ t₂′} → pi t₁ t₂ ≡ pi t₁′ t₂′ → t₂ ≡ t₂′
243 pi-injective₂ refl = refl
244
245 pi-injective : ∀ {t₁ t₁′ t₂ t₂′} → pi t₁ t₂ ≡ pi t₁′ t₂′ → t₁ ≡ t₁′ × t₂ ≡ t₂′
246 pi-injective = < pi-injective₁ , pi-injective₂ >
247
248 sort-injective : ∀ {x y} → sort x ≡ sort y → x ≡ y
249 sort-injective refl = refl
250
251 lit-injective : ∀ {x y} → lit x ≡ lit y → x ≡ y
252 lit-injective refl = refl
253
254 set-injective : ∀ {x y} → set x ≡ set y → x ≡ y
255 set-injective refl = refl
256
257 slit-injective : ∀ {x y} → Sort.lit x ≡ lit y → x ≡ y
258 slit-injective refl = refl
259
260 prop-injective : ∀ {x y} → prop x ≡ prop y → x ≡ y
261 prop-injective refl = refl
262
263 propLit-injective : ∀ {x y} → propLit x ≡ propLit y → x ≡ y
264 propLit-injective refl = refl
265
266 inf-injective : ∀ {x y} → inf x ≡ inf y → x ≡ y
267 inf-injective refl = refl
268
269 var x args ≟ var x′ args′ =
270 map′ (uncurry (cong₂ var)) var-injective (x ℕ.≟ x′ ×-dec args ≟-Args args′)
271 con c args ≟ con c′ args′ =
272 map′ (uncurry (cong₂ con)) con-injective (c Name.≟ c′ ×-dec args ≟-Args args′)
273 def f args ≟ def f′ args′ =
274 map′ (uncurry (cong₂ def)) def-injective (f Name.≟ f′ ×-dec args ≟-Args args′)
275 meta x args ≟ meta x′ args′ =
276 map′ (uncurry (cong₂ meta)) meta-injective (x Meta.≟ x′ ×-dec args ≟-Args args′)
277 lam v t ≟ lam v′ t′ =
278 map′ (uncurry (cong₂ lam)) lam-injective (v Visibility.≟ v′ ×-dec t ≟-AbsTerm t′)
279 pat-lam cs args ≟ pat-lam cs′ args′ =
280 map′ (uncurry (cong₂ pat-lam)) pat-lam-injective (cs ≟-Clauses cs′ ×-dec args ≟-Args args′)
281 pi t₁ t₂ ≟ pi t₁′ t₂′ =
282 map′ (uncurry (cong₂ pi)) pi-injective (t₁ ≟-ArgType t₁′ ×-dec t₂ ≟-AbsType t₂′)
283 sort s ≟ sort s′ = map′ (cong sort) sort-injective (s ≟-Sort s′)
284 lit l ≟ lit l′ = map′ (cong lit) lit-injective (l Literal.≟ l′)
285 unknown ≟ unknown = yes refl
286
287 var x args ≟ con c args′ = no λ()
288 var x args ≟ def f args′ = no λ()
289 var x args ≟ lam v t = no λ()
290 var x args ≟ pi t₁ t₂ = no λ()
291 var x args ≟ sort _ = no λ()
292 var x args ≟ lit _ = no λ()
293 var x args ≟ meta _ _ = no λ()
294 var x args ≟ unknown = no λ()
295 con c args ≟ var x args′ = no λ()
296 con c args ≟ def f args′ = no λ()
297 con c args ≟ lam v t = no λ()
298 con c args ≟ pi t₁ t₂ = no λ()
299 con c args ≟ sort _ = no λ()
300 con c args ≟ lit _ = no λ()
301 con c args ≟ meta _ _ = no λ()
302 con c args ≟ unknown = no λ()
303 def f args ≟ var x args′ = no λ()
304 def f args ≟ con c args′ = no λ()
305 def f args ≟ lam v t = no λ()
306 def f args ≟ pi t₁ t₂ = no λ()
307 def f args ≟ sort _ = no λ()
308 def f args ≟ lit _ = no λ()
309 def f args ≟ meta _ _ = no λ()
310 def f args ≟ unknown = no λ()
311 lam v t ≟ var x args = no λ()
312 lam v t ≟ con c args = no λ()
313 lam v t ≟ def f args = no λ()
314 lam v t ≟ pi t₁ t₂ = no λ()
315 lam v t ≟ sort _ = no λ()
316 lam v t ≟ lit _ = no λ()
317 lam v t ≟ meta _ _ = no λ()
318 lam v t ≟ unknown = no λ()
319 pi t₁ t₂ ≟ var x args = no λ()
320 pi t₁ t₂ ≟ con c args = no λ()
321 pi t₁ t₂ ≟ def f args = no λ()
322 pi t₁ t₂ ≟ lam v t = no λ()
323 pi t₁ t₂ ≟ sort _ = no λ()
324 pi t₁ t₂ ≟ lit _ = no λ()
325 pi t₁ t₂ ≟ meta _ _ = no λ()
326 pi t₁ t₂ ≟ unknown = no λ()
327 sort _ ≟ var x args = no λ()
328 sort _ ≟ con c args = no λ()
329 sort _ ≟ def f args = no λ()
330 sort _ ≟ lam v t = no λ()
331 sort _ ≟ pi t₁ t₂ = no λ()
332 sort _ ≟ lit _ = no λ()
333 sort _ ≟ meta _ _ = no λ()
334 sort _ ≟ unknown = no λ()
335 lit _ ≟ var x args = no λ()
336 lit _ ≟ con c args = no λ()
337 lit _ ≟ def f args = no λ()
338 lit _ ≟ lam v t = no λ()
339 lit _ ≟ pi t₁ t₂ = no λ()
340 lit _ ≟ sort _ = no λ()
341 lit _ ≟ meta _ _ = no λ()
342 lit _ ≟ unknown = no λ()
343 meta _ _ ≟ var x args = no λ()
344 meta _ _ ≟ con c args = no λ()
345 meta _ _ ≟ def f args = no λ()
346 meta _ _ ≟ lam v t = no λ()
347 meta _ _ ≟ pi t₁ t₂ = no λ()
348 meta _ _ ≟ sort _ = no λ()
349 meta _ _ ≟ lit _ = no λ()
350 meta _ _ ≟ unknown = no λ()
351 unknown ≟ var x args = no λ()
352 unknown ≟ con c args = no λ()
353 unknown ≟ def f args = no λ()
354 unknown ≟ lam v t = no λ()
355 unknown ≟ pi t₁ t₂ = no λ()
356 unknown ≟ sort _ = no λ()
357 unknown ≟ lit _ = no λ()
358 unknown ≟ meta _ _ = no λ()
359 pat-lam _ _ ≟ var x args = no λ()
360 pat-lam _ _ ≟ con c args = no λ()
361 pat-lam _ _ ≟ def f args = no λ()
362 pat-lam _ _ ≟ lam v t = no λ()
363 pat-lam _ _ ≟ pi t₁ t₂ = no λ()
364 pat-lam _ _ ≟ sort _ = no λ()
365 pat-lam _ _ ≟ lit _ = no λ()
366 pat-lam _ _ ≟ meta _ _ = no λ()
367 pat-lam _ _ ≟ unknown = no λ()
368 var x args ≟ pat-lam _ _ = no λ()
369 con c args ≟ pat-lam _ _ = no λ()
370 def f args ≟ pat-lam _ _ = no λ()
371 lam v t ≟ pat-lam _ _ = no λ()
372 pi t₁ t₂ ≟ pat-lam _ _ = no λ()
373 sort _ ≟ pat-lam _ _ = no λ()
374 lit _ ≟ pat-lam _ _ = no λ()
375 meta _ _ ≟ pat-lam _ _ = no λ()
376 unknown ≟ pat-lam _ _ = no λ()
377
378 set t ≟-Sort set t′ = map′ (cong set) set-injective (t ≟ t′)
379 lit n ≟-Sort lit n′ = map′ (cong lit) slit-injective (n ℕ.≟ n′)
380 prop t ≟-Sort prop t′ = map′ (cong prop) prop-injective (t ≟ t′)
381 propLit n ≟-Sort propLit n′ = map′ (cong propLit) propLit-injective (n ℕ.≟ n′)
382 inf n ≟-Sort inf n′ = map′ (cong inf) inf-injective (n ℕ.≟ n′)
383 unknown ≟-Sort unknown = yes refl
384 set _ ≟-Sort lit _ = no λ()
385 set _ ≟-Sort prop _ = no λ()
386 set _ ≟-Sort propLit _ = no λ()
387 set _ ≟-Sort inf _ = no λ()
388 set _ ≟-Sort unknown = no λ()
389 lit _ ≟-Sort set _ = no λ()
390 lit _ ≟-Sort prop _ = no λ()
391 lit _ ≟-Sort propLit _ = no λ()
392 lit _ ≟-Sort inf _ = no λ()
393 lit _ ≟-Sort unknown = no λ()
394 prop _ ≟-Sort set _ = no λ()
395 prop _ ≟-Sort lit _ = no λ()
396 prop _ ≟-Sort propLit _ = no λ()
397 prop _ ≟-Sort inf _ = no λ()
398 prop _ ≟-Sort unknown = no λ()
399 propLit _ ≟-Sort set _ = no λ()
400 propLit _ ≟-Sort lit _ = no λ()
401 propLit _ ≟-Sort prop _ = no λ()
402 propLit _ ≟-Sort inf _ = no λ()
403 propLit _ ≟-Sort unknown = no λ()
404 inf _ ≟-Sort set _ = no λ()
405 inf _ ≟-Sort lit _ = no λ()
406 inf _ ≟-Sort prop _ = no λ()
407 inf _ ≟-Sort propLit _ = no λ()
408 inf _ ≟-Sort unknown = no λ()
409 unknown ≟-Sort set _ = no λ()
410 unknown ≟-Sort lit _ = no λ()
411 unknown ≟-Sort prop _ = no λ()
412 unknown ≟-Sort propLit _ = no λ()
413 unknown ≟-Sort inf _ = no λ()
414
415
416 pat-con-injective₁ : ∀ {c c′ args args′} → Pattern.con c args ≡ con c′ args′ → c ≡ c′
417 pat-con-injective₁ refl = refl
418
419 pat-con-injective₂ : ∀ {c c′ args args′} → Pattern.con c args ≡ con c′ args′ → args ≡ args′
420 pat-con-injective₂ refl = refl
421
422 pat-con-injective : ∀ {c c′ args args′} → Pattern.con c args ≡ con c′ args′ → c ≡ c′ × args ≡ args′
423 pat-con-injective = < pat-con-injective₁ , pat-con-injective₂ >
424
425 pat-var-injective : ∀ {x y} → var x ≡ var y → x ≡ y
426 pat-var-injective refl = refl
427
428 pat-lit-injective : ∀ {x y} → Pattern.lit x ≡ lit y → x ≡ y
429 pat-lit-injective refl = refl
430
431 proj-injective : ∀ {x y} → proj x ≡ proj y → x ≡ y
432 proj-injective refl = refl
433
434 dot-injective : ∀ {x y} → dot x ≡ dot y → x ≡ y
435 dot-injective refl = refl
436
437 absurd-injective : ∀ {x y} → absurd x ≡ absurd y → x ≡ y
438 absurd-injective refl = refl
439
440 con c ps ≟-Pattern con c′ ps′ = map′ (uncurry (cong₂ con)) pat-con-injective (c Name.≟ c′ ×-dec ps ≟-Patterns ps′)
441 var x ≟-Pattern var x′ = map′ (cong var) pat-var-injective (x ℕ.≟ x′)
442 lit l ≟-Pattern lit l′ = map′ (cong lit) pat-lit-injective (l Literal.≟ l′)
443 proj a ≟-Pattern proj a′ = map′ (cong proj) proj-injective (a Name.≟ a′)
444 dot t ≟-Pattern dot t′ = map′ (cong dot) dot-injective (t ≟ t′)
445 absurd x ≟-Pattern absurd x′ = map′ (cong absurd) absurd-injective (x ℕ.≟ x′)
446
447 con x x₁ ≟-Pattern dot x₂ = no (λ ())
448 con x x₁ ≟-Pattern var x₂ = no (λ ())
449 con x x₁ ≟-Pattern lit x₂ = no (λ ())
450 con x x₁ ≟-Pattern proj x₂ = no (λ ())
451 con x x₁ ≟-Pattern absurd x₂ = no (λ ())
452 dot x ≟-Pattern con x₁ x₂ = no (λ ())
453 dot x ≟-Pattern var x₁ = no (λ ())
454 dot x ≟-Pattern lit x₁ = no (λ ())
455 dot x ≟-Pattern proj x₁ = no (λ ())
456 dot x ≟-Pattern absurd x₁ = no (λ ())
457 var s ≟-Pattern con x x₁ = no (λ ())
458 var s ≟-Pattern dot x = no (λ ())
459 var s ≟-Pattern lit x = no (λ ())
460 var s ≟-Pattern proj x = no (λ ())
461 var s ≟-Pattern absurd x = no (λ ())
462 lit x ≟-Pattern con x₁ x₂ = no (λ ())
463 lit x ≟-Pattern dot x₁ = no (λ ())
464 lit x ≟-Pattern var _ = no (λ ())
465 lit x ≟-Pattern proj x₁ = no (λ ())
466 lit x ≟-Pattern absurd x₁ = no (λ ())
467 proj x ≟-Pattern con x₁ x₂ = no (λ ())
468 proj x ≟-Pattern dot x₁ = no (λ ())
469 proj x ≟-Pattern var _ = no (λ ())
470 proj x ≟-Pattern lit x₁ = no (λ ())
471 proj x ≟-Pattern absurd x₁ = no (λ ())
472 absurd x ≟-Pattern con x₁ x₂ = no (λ ())
473 absurd x ≟-Pattern dot x₁ = no (λ ())
474 absurd x ≟-Pattern var _ = no (λ ())
475 absurd x ≟-Pattern lit x₁ = no (λ ())
476 absurd x ≟-Pattern proj x₁ = no (λ ())
477
478 [] ≟-Patterns [] = yes refl
479 (arg i p ∷ xs) ≟-Patterns (arg j q ∷ ys) = ∷-dec (unArg-dec (p ≟-Pattern q)) (xs ≟-Patterns ys)
480
481 [] ≟-Patterns (_ ∷ _) = no λ()
482 (_ ∷ _) ≟-Patterns [] = no λ()