Skip to content

Commit 662cc67

Browse files
jamesmckinnaandreasabel
authored andcommitted
Predicate transformers: Reconciling Induction.RecStruct with Relation.Unary.PredicateTransformer.PT (#2140)
* reconciling `Induction.RecStruct` with `Relation.Unary.PredicateTransformer.PT` * relaxing `PredicateTransformer` levels * `CHANGELOG`; `fix-whitespace` * added `variable`s; plus tweaked comments` * restored `FreeMonad` * restored `Predicate` * removed linebreaks
1 parent ec51abf commit 662cc67

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/Induction.agda

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,48 @@ module Induction where
1717

1818
open import Level
1919
open import Relation.Unary
20+
open import Relation.Unary.PredicateTransformer using (PT)
2021

22+
private
23+
variable
24+
a ℓ ℓ₁ ℓ₂ : Level
25+
A : Set a
26+
Q : Pred A ℓ
27+
Rec : PT A A ℓ₁ ℓ₂
28+
29+
30+
------------------------------------------------------------------------
2131
-- A RecStruct describes the allowed structure of recursion. The
2232
-- examples in Data.Nat.Induction should explain what this is all
2333
-- about.
2434

25-
RecStruct : {a} Set a (ℓ₁ ℓ₂ : Level) Set _
26-
RecStruct A ℓ₁ ℓ₂ = Pred A ℓ₁ Pred A ℓ₂
35+
RecStruct : Set a (ℓ₁ ℓ₂ : Level) Set _
36+
RecStruct A = PT A A
2737

2838
-- A recursor builder constructs an instance of a recursion structure
2939
-- for a given input.
3040

31-
RecursorBuilder : {a ℓ₁ ℓ₂} {A : Set a} RecStruct A ℓ₁ ℓ₂ Set _
41+
RecursorBuilder : RecStruct A ℓ₁ ℓ₂ Set _
3242
RecursorBuilder Rec = P Rec P ⊆′ P Universal (Rec P)
3343

3444
-- A recursor can be used to actually compute/prove something useful.
3545

36-
Recursor : {a ℓ₁ ℓ₂} {A : Set a} RecStruct A ℓ₁ ℓ₂ Set _
46+
Recursor : RecStruct A ℓ₁ ℓ₂ Set _
3747
Recursor Rec = P Rec P ⊆′ P Universal P
3848

3949
-- And recursors can be constructed from recursor builders.
4050

41-
build : {a ℓ₁ ℓ₂} {A : Set a} {Rec : RecStruct A ℓ₁ ℓ₂}
42-
RecursorBuilder Rec
43-
Recursor Rec
51+
build : RecursorBuilder Rec Recursor Rec
4452
build builder P f x = f x (builder P f x)
4553

4654
-- We can repeat the exercise above for subsets of the type we are
4755
-- recursing over.
4856

49-
SubsetRecursorBuilder : {a ℓ₁ ℓ₂ ℓ₃} {A : Set a}
50-
Pred A ℓ₁ RecStruct A ℓ₂ ℓ₃ Set _
57+
SubsetRecursorBuilder : Pred A ℓ RecStruct A ℓ₁ ℓ₂ Set _
5158
SubsetRecursorBuilder Q Rec = P Rec P ⊆′ P Q ⊆′ Rec P
5259

53-
SubsetRecursor : {a ℓ₁ ℓ₂ ℓ₃} {A : Set a}
54-
Pred A ℓ₁ RecStruct A ℓ₂ ℓ₃ Set _
60+
SubsetRecursor : Pred A ℓ RecStruct A ℓ₁ ℓ₂ Set _
5561
SubsetRecursor Q Rec = P Rec P ⊆′ P Q ⊆′ P
5662

57-
subsetBuild : {a ℓ₁ ℓ₂ ℓ₃}
58-
{A : Set a} {Q : Pred A ℓ₁} {Rec : RecStruct A ℓ₂ ℓ₃}
59-
SubsetRecursorBuilder Q Rec
60-
SubsetRecursor Q Rec
63+
subsetBuild : SubsetRecursorBuilder Q Rec SubsetRecursor Q Rec
6164
subsetBuild builder P f x q = f x (builder P f x q)

0 commit comments

Comments
 (0)