@@ -86,8 +86,7 @@ wfInd : WellFounded rel => {P : a -> Type} ->
86wfInd {rel} step x = accInd step x (wellFounded {rel} x)
86wfInd {rel} step x = accInd step x (wellFounded {rel} x)
88||| Interface of types with sized values.
88||| Interface of types with sized values.
90−||| The sizes are used for proofs of termination via accessibility.
89+||| The size is used for proofs of termination via accessibility.
92||| @ a the type whose elements can be mapped to Nat
91||| @ a the type whose elements can be mapped to Nat
93interface Sized a where
92interface Sized a where
@@ -96,16 +95,17 @@ interface Sized a where
96Smaller : Sized a => a -> a -> Type
95Smaller : Sized a => a -> a -> Type
97Smaller x y = size x `LT` size y
96Smaller x y = size x `LT` size y
99−SizeAcc : Sized a => a -> Type
98+SizeAccessible : Sized a => a -> Type
100−SizeAcc = Accessible Smaller
99+SizeAccessible = Accessible Smaller
102||| Proof of well-foundedness of `Smaller`.
101||| Proof of well-foundedness of `Smaller`.
103||| Constructs accessibility for any given element of `a`, provided `Sized a`.
102||| Constructs accessibility for any given element of `a`, provided `Sized a`.
104−sizeAcc : Sized a => (x : a) -> SizeAcc x
103+sizeAccessible : Sized a => (x : a) -> SizeAccessible x
105−sizeAcc x = Access $ f (size x) (ltAccessible $ size x)
104+sizeAccessible x = Access $ f (size x) (ltAccessible $ size x)
106+ -- prove well-foundedness of `Smaller` from well-foundedness of `LT`
107 f : (sizeX : Nat) -> (acc : Accessible LT sizeX)
107 f : (sizeX : Nat) -> (acc : Accessible LT sizeX)
108− -> (y : a) -> (size y `LT` sizeX) -> Accessible Smaller y
108+ -> (y : a) -> (size y `LT` sizeX) -> SizeAccessible y
109 f Z acc y pf = absurd pf
109 f Z acc y pf = absurd pf
110 f (S n) (Access acc) y (LTESucc yLEx)
110 f (S n) (Access acc) y (LTESucc yLEx)
111 = Access (\z, zLTy =>
111 = Access (\z, zLTy =>
@@ -127,14 +127,14 @@ sizeInd : Sized a
127 -> (step : (x : a) -> ((y : a) -> Smaller y x -> P y) -> P x)
127 -> (step : (x : a) -> ((y : a) -> Smaller y x -> P y) -> P x)
128 -> (z : a)
128 -> (z : a)
130−sizeInd step z = accInd step z (sizeAcc z)
130+sizeInd step z = accInd step z (sizeAccessible z)
132||| Strong recursion principle for sized types.
132||| Strong recursion principle for sized types.
133sizeRec : Sized a
133sizeRec : Sized a
134 => (step : (x : a) -> ((y : a) -> Smaller y x -> b) -> b)
134 => (step : (x : a) -> ((y : a) -> Smaller y x -> b) -> b)
135 -> (z : a)
135 -> (z : a)
137−sizeRec step z = accRec step z (sizeAcc z)
137+sizeRec step z = accRec step z (sizeAccessible z)
140implementation Sized Nat where
140implementation Sized Nat where