@@ -85,7 +85,6 @@ wfInd : WellFounded rel => {P : a -> Type} ->
85 (x : a) -> P x
85 (x : a) -> P x
86wfInd {rel} step x = accInd step x (wellFounded {rel} x)
86wfInd {rel} step x = accInd step x (wellFounded {rel} x)
89||| Interface of types with sized values.
88||| Interface of types with sized values.
91||| The sizes are used for proofs of termination via accessibility.
90||| The sizes are used for proofs of termination via accessibility.
@@ -97,10 +96,13 @@ interface Sized a where
97Smaller : Sized a => a -> a -> Type
96Smaller : Sized a => a -> a -> Type
98Smaller x y = size x `LT` size y
97Smaller x y = size x `LT` size y
99+SizeAcc : Sized a => a -> Type
100+SizeAcc = Accessible Smaller
100||| Proof of well-foundedness of `Smaller`.
102||| Proof of well-foundedness of `Smaller`.
101||| Constructs accessibility for any given element of `a`, provided `Sized a`.
103||| Constructs accessibility for any given element of `a`, provided `Sized a`.
102−accessible : Sized a => (x : a) -> Accessible Smaller x
104+sizeAcc : Sized a => (x : a) -> SizeAcc x
103−accessible x = Access $ f (size x) (ltAccessible $ size x)
105+sizeAcc x = Access $ f (size x) (ltAccessible $ size x)
105 f : (sizeX : Nat) -> (acc : Accessible LT sizeX)
107 f : (sizeX : Nat) -> (acc : Accessible LT sizeX)
106 -> (y : a) -> (size y `LT` sizeX) -> Accessible Smaller y
108 -> (y : a) -> (size y `LT` sizeX) -> Accessible Smaller y
@@ -125,14 +127,14 @@ sizeInd : Sized a
125 -> (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)
126 -> (z : a)
128 -> (z : a)
128−sizeInd step z = accInd step z (accessible z)
130+sizeInd step z = accInd step z (sizeAcc z)
130||| Strong recursion principle for sized types.
132||| Strong recursion principle for sized types.
131sizeRec : Sized a
133sizeRec : Sized a
132 => (step : (x : a) -> ((y : a) -> Smaller y x -> b) -> b)
134 => (step : (x : a) -> ((y : a) -> Smaller y x -> b) -> b)
133 -> (z : a)
135 -> (z : a)
135−sizeRec step z = accRec step z (accessible z)
137+sizeRec step z = accRec step z (sizeAcc z)
138implementation Sized Nat where
140implementation Sized Nat where