8
8
9
9
open import Data.Fin.Base
10
10
open import Data.Fin.Properties
11
- open import Data.Nat.Base as ℕ using (ℕ; zero; suc; _∸_)
12
- open import Data.Nat.Properties using (n<1+n)
11
+ open import Data.Nat.Base as ℕ using (ℕ; zero; suc; _∸_; s≤s )
12
+ open import Data.Nat.Properties using (n<1+n; ≤⇒≯ )
13
13
import Data.Nat.Induction as ℕ
14
14
import Data.Nat.Properties as ℕ
15
15
open import Data.Product using (_,_)
@@ -25,6 +25,7 @@ import Relation.Binary.Construct.Converse as Converse
25
25
import Relation.Binary.Construct.Flip as Flip
26
26
import Relation.Binary.Construct.NonStrictToStrict as ToStrict
27
27
import Relation.Binary.Construct.On as On
28
+ open import Relation.Binary.Definitions using (Tri; tri<; tri≈; tri>)
28
29
open import Relation.Binary.PropositionalEquality
29
30
open import Relation.Nullary using (yes; no)
30
31
open import Relation.Nullary.Negation using (contradiction)
@@ -48,16 +49,27 @@ open WF public using (Acc; acc)
48
49
<-wellFounded : WellFounded {A = Fin n} _<_
49
50
<-wellFounded = On.wellFounded toℕ ℕ.<-wellFounded
50
51
52
+ <-weakInduction-startingFrom : ∀ (P : Pred (Fin (suc n)) ℓ) →
53
+ ∀ {i} → P i →
54
+ (∀ j → P (inject₁ j) → P (suc j)) →
55
+ ∀ {j} → j ≥ i → P j
56
+ <-weakInduction-startingFrom P {i} Pi Pᵢ⇒Pᵢ₊₁ {j} j≥i = induct (<-wellFounded _) (<-cmp i j) j≥i
57
+ where
58
+ induct : ∀ {j} → Acc _<_ j → Tri (i < j) (i ≡ j) (i > j) → j ≥ i → P j
59
+ induct (acc rs) (tri≈ _ refl _) i≤j = Pi
60
+ induct (acc rs) (tri> _ _ i>sj) i≤j with () ← ≤⇒≯ i≤j i>sj
61
+ induct {suc j} (acc rs) (tri< (s≤s i≤j) _ _) _ = Pᵢ⇒Pᵢ₊₁ j P[1+j]
62
+ where
63
+ toℕj≡toℕinjJ = sym $ toℕ-inject₁ j
64
+ P[1+j] = induct (rs _ (s≤s (subst (ℕ._≤ toℕ j) toℕj≡toℕinjJ ≤-refl)))
65
+ (<-cmp i $ inject₁ j) (subst (toℕ i ℕ.≤_) toℕj≡toℕinjJ i≤j)
66
+
51
67
<-weakInduction : (P : Pred (Fin (suc n)) ℓ) →
52
68
P zero →
53
69
(∀ i → P (inject₁ i) → P (suc i)) →
54
70
∀ i → P i
55
- <-weakInduction P P₀ Pᵢ⇒Pᵢ₊₁ i = induct (<-wellFounded i)
56
- where
57
- induct : ∀ {i} → Acc _<_ i → P i
58
- induct {zero} _ = P₀
59
- induct {suc i} (acc rec) = Pᵢ⇒Pᵢ₊₁ i (induct (rec (inject₁ i) i<i+1))
60
- where i<i+1 = ℕ<⇒inject₁< (i<1+i i)
71
+ <-weakInduction P P₀ Pᵢ⇒Pᵢ₊₁ i = <-weakInduction-startingFrom P P₀ Pᵢ⇒Pᵢ₊₁ ℕ.z≤n
72
+
61
73
62
74
------------------------------------------------------------------------
63
75
-- Induction over _>_
0 commit comments