While this submission is a draft, it cannot be used by other submissions.

Rational functions

Lax149335.RationalFunctions · concepts/Lax149335/RationalFunctions.lean · lax-149335

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.

    Natural Language Statement

    Definition

    A rational relation R⊆A∗×B∗R \subseteq A^* \times B^* between strings over alphabets AA and BB is a subset of the monoid A∗×B∗A^* \times B^* defined by a regular expression: the atoms are pairs of strings, and the operations are union, concatenation (componentwise) and Kleene star.

    Definition 2.1 (Rational function). A function f:A∗→B∗f : A^* \to B^* is rational if its graph is a rational relation.

    Definition 2.3 (Rational functions on types). A function f:A→Bf : A \to B between types is rational if there is a rational function f′:8∗→8∗f' : \mathbb{8}^* \to \mathbb{8}^* that agrees with ff on the string representations of elements, i.e. the string representation of f(a)f(a) is f′f' applied to the string representation of aa.

    Concept map
    2 concepts; 1 descendant hidden
    100%
    Open claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Lax149335.Types
    2import Mathlib.Data.Set.Defs
    3
    4/-!
    5---
    6title: Rational functions
    7type: definition
    8---
    9A *rational relation* R⊆A∗×B∗R \subseteq A^* \times B^* between strings over alphabets AA and
    10BB is a subset of the monoid A∗×B∗A^* \times B^* defined by a regular expression: the atoms
    11are pairs of strings, and the operations are union, concatenation (componentwise) and Kleene
    12star.
    13
    14**Definition 2.1 (Rational function).** A function f:A∗→B∗f : A^* \to B^* is *rational* if its
    15graph is a rational relation.
    16
    17**Definition 2.3 (Rational functions on types).** A function f:A→Bf : A \to B between types is
    18*rational* if there is a rational function f′:8∗→8∗f' : \mathbb{8}^* \to \mathbb{8}^* that agrees
    19with ff on the string representations of elements, i.e. the string representation of
    20f(a)f(a) is f′f' applied to the string representation of aa.
    21-/
    22
    23namespace Lax149335.RationalFunctions
    24
    25open Lax149335.Types
    26
    27variable {α β : Type}
    28
    29/-- Regular expressions over the product monoid `α* × β*`. -/
    30inductive RatExp (α β : Type) : Type
    31 | zero : RatExp α β
    32 | atom : List α → List β → RatExp α β
    33 | plus : RatExp α β → RatExp α β → RatExp α β
    34 | cat : RatExp α β → RatExp α β → RatExp α β
    35 | star : RatExp α β → RatExp α β
    36
    37/-- The submonoid of `α* × β*` generated by a set `S`: all finite products of elements of
    38`S`. -/
    39inductive StarSet (S : Set (List α × List β)) : List α × List β → Prop
    40 | nil : StarSet S ([], [])
    41 | cons {x y : List α × List β} : x ∈ S → StarSet S y → StarSet S (x.1 ++ y.1, x.2 ++ y.2)
    42
    43/-- The relation defined by a regular expression. -/
    44def RatExp.lang : RatExp α β → Set (List α × List β)
    45 | .zero => ∅
    46 | .atom u v => {(u, v)}
    47 | .plus e f => e.lang ∪ f.lang
    48 | .cat e f => {p | ∃ x ∈ e.lang, ∃ y ∈ f.lang, p = (x.1 ++ y.1, x.2 ++ y.2)}
    49 | .star e => {p | StarSet e.lang p}
    50
    51/-- A relation between strings is rational if it is defined by a regular expression. -/
    52def IsRationalRel (R : Set (List α × List β)) : Prop := ∃ e : RatExp α β, e.lang = R
    53
    54/-- **Definition 2.1.** A function `f : α* → β*` is rational if its graph is a rational
    55relation. -/
    56def IsRationalFun (f : List α → List β) : Prop :=
    57 IsRationalRel {p : List α × List β | p.2 = f p.1}
    58
    59/-- **Definition 2.3.** A function between types is rational if, on string representations,
    60it is computed by a rational function `𝟖* → 𝟖*`. -/
    61def IsRationalTypeFun {A B : Ty} (f : ⟦A⟧ → ⟦B⟧) : Prop :=
    62 ∃ f' : List Ty.Sym → List Ty.Sym,
    63 IsRationalFun f' ∧ ∀ a : ⟦A⟧, Ty.repr B (f a) = f' (Ty.repr A a)
    64
    65end Lax149335.RationalFunctions
    66

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…