Simple rational terms
Lax149335.SimpleRationalTerms · concepts/Lax149335/SimpleRationalTerms.lean · lax-149335
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
Definition 2.5 (Simple rational terms). Let be a finite alphabet. The simple rational terms with outputs in are the terms generated from the term , which produces the empty string, by the following combinators:
- co-pairing: for and , the term that applies or depending on the summand;
- concatenation: for and , the term that maps to ;
- homomorphism: for , the term that maps to ;
- constants: for and a string , the terms and , which prepend or append to the output.
A function is represented by a simple rational term if it is the function that the term defines.
Concept map
Lean source view on GitHub
| 1 | import Lax149335.Types |
| 2 | |
| 3 | /-! |
| 4 | --- |
| 5 | title: Simple rational terms |
| 6 | type: definition |
| 7 | --- |
| 8 | **Definition 2.5 (Simple rational terms).** Let be a finite alphabet. The *simple |
| 9 | rational terms* with outputs in are the terms generated from the term |
| 10 | , which produces the empty string, by the following combinators: |
| 11 | |
| 12 | - *co-pairing*: for and , the term |
| 13 | that applies or depending on |
| 14 | the summand; |
| 15 | - *concatenation*: for and , the term |
| 16 | that maps to ; |
| 17 | - *homomorphism*: for , the term that maps |
| 18 | to ; |
| 19 | - *constants*: for and a string , the terms and |
| 20 | , which prepend or append to the output. |
| 21 | |
| 22 | A function is *represented* by a simple rational term if it is the function that the term |
| 23 | defines. |
| 24 | |
| 25 | # Formalization notes |
| 26 | |
| 27 | The output alphabet is an arbitrary Lean type `Bs`; the statements that need it to be |
| 28 | finite say so. |
| 29 | -/ |
| 30 | |
| 31 | namespace Lax149335.SimpleRationalTerms |
| 32 | |
| 33 | open Lax149335.Types |
| 34 | |
| 35 | /-- Simple rational terms `A → Bs*`. -/ |
| 36 | inductive SimpleTerm (Bs : Type) : Ty → Type |
| 37 | /-- The term `[] : 1 → Bs*` with empty output. -/ |
| 38 | | empty : SimpleTerm Bs Ty.unit |
| 39 | /-- Co-pairing `⟨f₁, f₂⟩ : A₁ + A₂ → Bs*`. -/ |
| 40 | | either {A₁ A₂ : Ty} : SimpleTerm Bs A₁ → SimpleTerm Bs A₂ → SimpleTerm Bs (A₁ ⊕' A₂) |
| 41 | /-- Concatenation `f₁ ⊙ f₂ : A₁ × A₂ → Bs*`. -/ |
| 42 | | conc {A₁ A₂ : Ty} : SimpleTerm Bs A₁ → SimpleTerm Bs A₂ → SimpleTerm Bs (A₁ ⊗ A₂) |
| 43 | /-- Homomorphism `hom f : A* → Bs*`. -/ |
| 44 | | hom {A : Ty} : SimpleTerm Bs A → SimpleTerm Bs A⋆ |
| 45 | /-- Prepending a string constant, `w · f`. -/ |
| 46 | | pre {A : Ty} : List Bs → SimpleTerm Bs A → SimpleTerm Bs A |
| 47 | /-- Appending a string constant, `f · w`. -/ |
| 48 | | post {A : Ty} : SimpleTerm Bs A → List Bs → SimpleTerm Bs A |
| 49 | |
| 50 | namespace SimpleTerm |
| 51 | |
| 52 | variable {Bs : Type} |
| 53 | |
| 54 | /-- The function defined by a simple rational term. -/ |
| 55 | def den : {A : Ty} → SimpleTerm Bs A → ⟦A⟧ → List Bs |
| 56 | | _, .empty, _ => [] |
| 57 | | _, .either f _, .inl a => den f a |
| 58 | | _, .either _ g, .inr b => den g b |
| 59 | | _, .conc f g, (a, b) => den f a ++ den g b |
| 60 | | _, .hom f, l => (l.map (den f)).flatten |
| 61 | | _, .pre w f, a => w ++ den f a |
| 62 | | _, .post f w, a => den f a ++ w |
| 63 | |
| 64 | /-- A function is represented by a simple rational term if it is the function that the term |
| 65 | defines. -/ |
| 66 | def IsSimpleFun {A : Ty} (f : ⟦A⟧ → List Bs) : Prop := ∃ t : SimpleTerm Bs A, t.den = f |
| 67 | |
| 68 | end SimpleTerm |
| 69 | |
| 70 | end Lax149335.SimpleRationalTerms |
| 71 |
Formalization notes
The output alphabet is an arbitrary Lean type ; the statements that need it to be finite say so.
Builds on
Used by
From Mathlib
none
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments