OAI/Computability/FiniteCompiler/Rewriting.lean
89 declarations, 0 contain sorry, 0 declared as axioms
Newman normalization, block coding, canonical representatives, and static tests.
- def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Irreducibleline 19 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.exists_irreducibleline 21 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.irreducible_reachesline 33 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.normal_uniqueline 40Source documentation
Newman's induction, with the terminal-descendant existence made explicit.
theorem normal_unique (wf : WellFounded (flip R)) (localJoin : ∀ a b c, R a b → R a c → Join (ReflTransGen R) b c) (a : α) : ∀ b c, ReflTransGen R a b → ReflTransGen R a c → Irreducible R b → Irreducible R c → b = c := by …Mentions: OAI.FiniteAlgebraicEnvelopes.Bootstrap.Irreducible
- theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.newmanline 56 - inductive
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Stepline 69Source documentation
One directed rule in an arbitrary two-sided context.
inductive Step (rules : List (List S × List S)) : List S → List S → Prop | apply {u v} (h : (u,v) ∈ rules) (x y) : Step rules (x++u++y) (x++v++y) - abbrev
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Stepsline 72 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.step_contextline 74 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.steps_contextline 79 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.lex_append_suffixline 83 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.shortlex_contextline 91 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.step_shortlexline 101 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.steps_lengthline 107 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.steps_wellFoundedline 116 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.step_stableline 122Source documentation
A bounded table sees precisely those rules whose left sides fit the bound.
theorem step_stable {rs rt : List (List S × List S)} {k : ℕ} (stable : ∀ p, p.1.length ≤ k → (p ∈ rs ↔ p ∈ rt)) {w v : List S} (hw : w.length ≤ k) : Step rs w v ↔ Step rt w v := by … - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.rootNextline 138Source documentation
The fixed choice of rule at the leftmost position, then table order.
def rootNext (w : List S) : List (List S × List S) → Option (List S) | [] => none | (u,v)::rs => if w.take u.length = u then some (v ++ w.drop u.length) else rootNext w rs
- def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.nextline 142 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.rootNext_soundline 146 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.rootNext_noneline 163 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.next_soundline 179 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.next_none_rootline 204 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.next_none_tailline 210 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.next_noneline 214 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.iterationline 225Source documentation
Fully specified finite-table reduction; divergence is retained for arbitrary (possibly nonterminating) tables.
def iteration (s : List (List S × List S) × List S) : List S ⊕ (List (List S × List S) × List S) := … - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.evaluateline 231 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.evaluate_soundline 234 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.evaluate_totalline 255 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.evaluate_unique_online 271Source documentation
Bounded local confluence is enough: every intervening reduction has nonincreasing length, so no confluence outside the source budget is used.
theorem evaluate_unique_on {r : S → S → Prop} {rules : List (List S × List S)} (wf : WellFounded r) (dec : ∀ p ∈ rules, List.Shortlex r p.2 p.1) (n : ℕ) (localJoin : ∀ a b c, a.length ≤ n → Step rules a b → Step rules a c → Join (Steps rules) b c) {a b c : List S} (ha : a.length ≤ n) (hab : Steps rules a b) (hac : Steps rules a c) (hb : Irreducible (Step rules) b) (hc : Irreducible (Step rules) c) : b = c := by …Mentions: OAI.FiniteAlgebraicEnvelopes.Bootstrap.Step, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Steps, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Irreducible
- theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.evaluate_context_online 290 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.primrec_rootNextline 307 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.primrec_nextline 327 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.primrec_iterationline 347 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.partrec_evaluateline 353 - structure
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCodeline 361 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.blockline 372 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.encodeline 374 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.block_lengthline 376 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.encode_nilline 379 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.encode_consline 380 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.encode_appendline 381 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.encode_lengthline 383 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.block_injectiveline 388 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.prefix_decodeline 392 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.encode_injectiveline 407 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.split_past_avoidingline 414 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.marker_alignmentline 429Source documentation
Every marker inside an encoded word starts a complete generator block.
theorem marker_alignment {v : List A} {x y : List S} (h : C.encode v = x ++ C.marker :: y) : ∃ u a w, v=u++a::w ∧ x=C.encode u ∧ y=C.tail a ++ C.encode w := by … - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.occurrence_decodeline 447Source documentation
A nonempty code occurrence in a code sequence has both boundaries aligned.
theorem occurrence_decode {v u : List A} (hu : u≠[]) {x y : List S} (h : C.encode v = x++C.encode u++y) : ∃ p q, v=p++u++q ∧ x=C.encode p ∧ y=C.encode q := by … - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.overlap_decodeline 465Source documentation
Overlapping code left sides have a union which is itself a full code; the common part is an entire (nonempty) code suffix/prefix.
theorem overlap_decode {u v : List A} {p middle q : List S} (hm : middle≠[]) (h₁ : C.encode u = p++middle) (h₂ : C.encode v = middle++q) : ∃ a b c, u=a++b ∧ v=b++c ∧ p=C.encode a ∧ middle=C.encode b ∧ q=C.encode c := by … - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.encode_avoidsline 484 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.lex_append_twoline 491 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.encode_lexline 500Source documentation
The chosen generator order is transported from the equal-width blocks.
theorem encode_lex {r : A → A → Prop} {s : S → S → Prop} (hblock : ∀ a b, r a b → List.Lex s (C.block a) (C.block b)) {u v : List A} (h : List.Lex r u v) : List.Lex s (C.encode u) (C.encode v) := by … - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.BlockCode.encode_shortlexline 508 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.binaryTailline 520Source documentation
An explicit computable constant-width binary tail family. Choosing the generator order by its lexicographic order implements the source convention. The generous width still obeys D₀>M=2, with no machine-size restriction.
def binaryTail {S : Type*} (a c : S) (m : ℕ) (i : Fin m) : List S := … - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.binaryTail_lengthline 523 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.binaryTail_injectiveline 529 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.binaryCodeline 538 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.candidatesline 552Source documentation
Exactly the bounded tested-class candidate set in the self-reference construction.
def candidates (w : List A) : Set (List A) := {v | v.length ≤ w.length ∧ q v=q w} - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.leastline 554 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.least_memline 557 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.least_lengthline 560 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.least_classline 563 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.least_minline 565 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.least_lt_or_eqline 569 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.least_global_minline 576 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.least_congrline 586Source documentation
Changing the finite search bound to that of another same-class candidate cannot change the result, including when the result is empty.
theorem least_congr [Std.Trichotomous r] {u v : List A} (hq : q u=q v) : least wf q u=least wf q v := by …Mentions: OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.least
- theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.least_idemline 592 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.least_nilline 596 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.eq_least_iffline 601Source documentation
Literal characterization which requires no class tests longer than w.
theorem eq_least_iff [Std.Trichotomous r] {w v : List A} : v=least wf q w ↔ v.length≤w.length ∧ q v=q w ∧ ∀ t, t.length≤w.length → q t=q w → ¬ List.Shortlex r t v := by …Mentions: OAI.FiniteAlgebraicEnvelopes.Bootstrap.Canonical.least
- theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.step_monoline 616 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.steps_monoline 621 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Absorbsline 629Source documentation
The absorbing equations, stated as finite-table membership, not as an additional computation oracle.
def Absorbs (rs : List (List S × List S)) (z : S) : Prop := …
- theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.absorbs_contextline 632 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.absorbs_memline 650 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.step_preserves_letterline 661 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.lettersline 676 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.wordsline 677 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.mem_wordsline 681 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.outputline 690 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.tableline 693 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.mem_tableline 697 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.output_congrline 704 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.output_nilline 709 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.whole_stepsline 712 - def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.Contextualline 722Source documentation
Precisely the bounded contextual tests used at source bootstrap:273–297.
def Contextual (n : ℕ) : Prop := …
- def
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.ZeroIdealline 726 - theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.branch_normalizesline 733Source documentation
A single contextual static replacement inside a full code reduces to the same literal whole-code output. Both endpoint bounds are proved separately.
theorem branch_normalizes {n : ℕ} {rs : List (List S × List S)} (hzero : q []≠none) (hz : Absorbs rs z) (ht : ∀ p∈table C wf q z n, p∈rs) (hc : Contextual q n) (hi : ZeroIdeal q n) {v : List A} {a b : List A} (hlen : (a++v++b).length≤n) : Steps rs (C.encode a++output C wf q z v++C.encode b) (output C wf q z (a++v++b)) := by …Mentions: OAI.FiniteAlgebraicEnvelopes.Bootstrap.Absorbs, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.table, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.Contextual, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.ZeroIdeal, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Steps, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.output
- theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.occurrence_normalizesline 757Source documentation
Contained code occurrences are aligned, so the preceding branch analysis applies at exactly the source code boundaries.
theorem occurrence_normalizes {n : ℕ} {rs : List (List S × List S)} (hzero : q []≠none) (hz : Absorbs rs z) (ht : ∀ p∈table C wf q z n, p∈rs) (hc : Contextual q n) (hi : ZeroIdeal q n) {w v : List A} {x y : List S} (hw : w.length≤n) (hv : v≠[]) (he : C.encode w=x++C.encode v++y) : Steps rs (x++output C wf q z v++y) (output C wf q z w) := by …Mentions: OAI.FiniteAlgebraicEnvelopes.Bootstrap.Absorbs, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.table, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.Contextual, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.ZeroIdeal, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Steps, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.output
- theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.critical_containmentline 768Source documentation
Static containment criticals join at the canonical output of the union.
theorem critical_containment {n k l : ℕ} {rs : List (List S × List S)} (hzero : q []≠none) (hz : Absorbs rs z) (ht : ∀ p∈table C wf q z n, p∈rs) (hc : Contextual q n) (hi : ZeroIdeal q n) {u u' v v' x y : List S} (hu : (u,u')∈table C wf q z k) (hv : (v,v')∈table C wf q z l) (he : u=x++v++y) (hlen : u.length≤(C.width+1)*n) : Join (Steps rs) u' (x++v'++y) := by …Mentions: OAI.FiniteAlgebraicEnvelopes.Bootstrap.Absorbs, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.table, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.Contextual, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.ZeroIdeal, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Steps
- theorem
OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.critical_overlapline 786Source documentation
Static boundary criticals have a full, aligned code union, and both contextual branches reach its same literal output.
theorem critical_overlap {n k l : ℕ} {rs : List (List S × List S)} (hzero : q []≠none) (hz : Absorbs rs z) (ht : ∀ p∈table C wf q z n, p∈rs) (hc : Contextual q n) (hi : ZeroIdeal q n) {u u' v v' x middle y : List S} (hu : (u,u')∈table C wf q z k) (hv : (v,v')∈table C wf q z l) (hm : middle≠[]) (he : u=x++middle) (hf : v=middle++y) (hlen : (x++middle++y).length≤(C.width+1)*n) : Join (Steps rs) (u'++y) (x++v') := by …Mentions: OAI.FiniteAlgebraicEnvelopes.Bootstrap.Absorbs, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.table, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.Contextual, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Static.ZeroIdeal, OAI.FiniteAlgebraicEnvelopes.Bootstrap.Steps