Draft — mutable and not usable as a dependency; its citation marks the draft state.

Lax53.TreeStructure

Ranked trees as finite relational structures

concepts/Lax53/TreeStructure.lean · lax-53

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Concept map

    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Definition

    A ranked tree is viewed as a relational structure on its nodes. For every alphabet symbol there is a unary predicate selecting the nodes carrying that symbol. For every child slot up to the maximum rank of the alphabet there is a binary relation connecting a node to its child in that slot.

    The label and child relations directly define the canonical structure of each tree. An MSO sentence defines the language of all ranked trees whose canonical structure satisfies it.

    Lean source view on GitHub

    1import Lax52.MSOSyntax
    2import Lax52.MSOSemantics
    3import Lax53.RankedTree
    4
    5/-!
    6---
    7title: Ranked trees as finite relational structures
    8type: definition
    9---
    10
    11A ranked tree is viewed as a relational structure on its nodes. For every
    12alphabet symbol there is a unary predicate selecting the nodes carrying that
    13symbol. For every child slot up to the maximum rank of the alphabet there is a
    14binary relation connecting a node to its child in that slot.
    15
    16The label and child relations directly define the canonical structure of each
    17tree. An MSO sentence defines the language of all ranked trees whose canonical
    18structure satisfies it.
    19-/
    20
    21namespace Lax53.TreeStructure
    22
    23open FirstOrder
    24open FirstOrder.Language
    25open Lax53.RankedTree
    26
    27universe u
    28
    29/-- Relation symbols for ranked trees. -/
    30inductive TreeRelation (A : RankedAlphabet.{u}) : Nat → Type u
    31 | label (a : A.Symbol) : TreeRelation A 1
    32 | child (i : ChildIndex A) : TreeRelation A 2
    33
    34/-- The first-order language of ranked trees over `A`. -/
    35def treeSignature (A : RankedAlphabet.{u}) : FirstOrder.Language.{0, u} where
    36 Functions := fun _ => Empty
    37 Relations := TreeRelation A
    38
    39/-- The canonical first-order structure of a ranked tree. -/
    40@[implicit_reducible]
    41def treeStructure {A : RankedAlphabet.{u}} (t : Tree A) :
    42 (treeSignature A).Structure (Node t) where
    43 funMap f := nomatch f
    44 RelMap
    45 | .label a, xs => Node.label (xs 0) = a
    46 | .child i, xs => Node.ChildAt i (xs 0) (xs 1)
    47
    48/-- Satisfaction of a closed MSO sentence by the canonical structure of a
    49ranked tree. -/
    50def TreeModels {A : RankedAlphabet.{u}} (t : Tree A)
    51 (phi : Lax52.MSOSyntax.Sentence (treeSignature A)) : Prop :=
    52 @Lax52.MSOSemantics.Realize (treeSignature A) (Node t) (treeStructure t) 0 0 phi
    53 (fun i : Fin 0 => Fin.elim0 i) (fun i : Fin 0 => Fin.elim0 i)
    54
    55/-- The ranked-tree language defined by an MSO sentence. -/
    56def sentenceLanguage {A : RankedAlphabet.{u}}
    57 (phi : Lax52.MSOSyntax.Sentence (treeSignature A)) : TreeLanguage A :=
    58 {t | TreeModels t phi}
    59
    60end Lax53.TreeStructure
    61

    Community review

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.

    0 comments

    Loading discussion…