Created
June 28, 2016 14:00
-
-
Save gallais/3564c895fa05b14b641233ab2bb7d3ea to your computer and use it in GitHub Desktop.
Induction principle for RoseTrees
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RoseTree where | |
open import Level | |
open import Data.List as List | |
open import Data.Unit | |
open import Data.Product | |
data RoseTree {ℓ : Level} (A : Set ℓ) : Set ℓ where | |
node : (a : A) (ts : List (RoseTree A)) → RoseTree A | |
All : {ℓ ℓ′ : Level} {A : Set ℓ} (P : A → Set ℓ′) → List A → Set ℓ′ | |
All P [] = Lift ⊤ | |
All P (t ∷ ts) = P t × All P ts | |
module Induction | |
{ℓ ℓ′ : Level} | |
{A : Set ℓ} | |
(P : RoseTree A → Set ℓ′) | |
(ih : (a : A) {ts : List (RoseTree A)} → All P ts → P (node a ts)) | |
where | |
mutual | |
induction : (t : RoseTree A) → P t | |
induction (node a ts) = ih a (inductions ts) | |
inductions : (ts : List (RoseTree A)) → All P ts | |
inductions [] = lift tt | |
inductions (t ∷ ts) = induction t , inductions ts | |
module Induction′ | |
{ℓ ℓ′ ℓ′′ : Level} | |
{A : Set ℓ} | |
(P : RoseTree A → Set ℓ′) | |
(Q : List (RoseTree A) → Set ℓ′′) | |
(Q[] : Q []) | |
(Q∷ : {t : RoseTree A} {ts : List (RoseTree A)} → P t → Q ts → Q (t ∷ ts)) | |
(ih : (a : A) {ts : List (RoseTree A)} → Q ts → P (node a ts)) | |
where | |
mutual | |
induction : (t : RoseTree A) → P t | |
induction (node a ts) = ih a (inductions ts) | |
inductions : (ts : List (RoseTree A)) → Q ts | |
inductions [] = Q[] | |
inductions (t ∷ ts) = Q∷ (induction t) (inductions ts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment