{"id":16312893,"url":"https://github.com/dmxlarchey/friedman-tree","last_synced_at":"2025-04-22T12:03:43.635Z","repository":{"id":235750494,"uuid":"791161496","full_name":"DmxLarchey/Friedman-TREE","owner":"DmxLarchey","description":"Construction of Friedman's tree(n) and TREE(n) in Coq","archived":false,"fork":false,"pushed_at":"2024-05-17T13:29:42.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-18T10:58:25.820Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Coq","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DmxLarchey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-24T07:53:34.000Z","updated_at":"2024-06-07T15:12:38.120Z","dependencies_parsed_at":"2024-06-07T15:12:35.565Z","dependency_job_id":"827335c3-8b48-4fbf-b30d-796d49364a32","html_url":"https://github.com/DmxLarchey/Friedman-TREE","commit_stats":null,"previous_names":["dmxlarchey/friedman-tree"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmxLarchey%2FFriedman-TREE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmxLarchey%2FFriedman-TREE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmxLarchey%2FFriedman-TREE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DmxLarchey%2FFriedman-TREE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DmxLarchey","download_url":"https://codeload.github.com/DmxLarchey/Friedman-TREE/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250237833,"owners_count":21397401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T21:49:26.402Z","updated_at":"2025-04-22T12:03:43.612Z","avatar_url":"https://github.com/DmxLarchey.png","language":"Coq","funding_links":[],"categories":[],"sub_categories":[],"readme":"```\n(**************************************************************)\n(*   Copyright Dominique Larchey-Wendling [*]                 *)\n(*                                                            *)\n(*                             [*] Affiliation LORIA -- CNRS  *)\n(**************************************************************)\n(*      This file is distributed under the terms of the       *)\n(*        Mozilla Public License Version 2.0, MPL-2.0         *)\n(**************************************************************)\n```\n# Friedman-TREE\n\nIn this small project, depending on [`Coq-Kruskal`](https://github.com/DmxLarchey/Coq-Kruskal) in an essential way,\nwe build [Harvey Friedman](https://en.wikipedia.org/wiki/Harvey_Friedman)'s `tree(n)` and `TREE(n)` fast growing functions.\n\n## Reminders:\n\n```coq\n\nFixpoint list_sum {X} (f : X → nat) l :=\n  match l with\n  | [] =\u003e 0\n  | x :: l =\u003e f x + list_sum l\n  end.\n\n(** Reminder:\n    idx m ≃ {0,...,m-1}.\n    vec X m are vectors of carrier type X and length m\n    If v : vec X m and i : idx m, then vᵢ is the i-th component of v *)\n\nInductive idx : nat → Type.\nInductive vec : Type → nat → Type.\n```\n\n## The Friedman `tree(n)` function\n\nThe Friedman `tree(n)` function is [informally defined](https://en.wikipedia.org/wiki/Kruskal%27s_tree_theorem)\nas the largest natural number `m` for which there is a sequence of length `m` of undecorated\nrose trees `[t₁;...;tₘ]` such that:\n1. the number of nodes of those trees are `1+n,...,m+n` respectivelly; \n2. the sequence is bad for the homeomorphic embedding `≤ₕ`.\n\nFormally in Coq, this gives the following specification and the theorem `Friedman_tree_spec` established in [`tree.v`](theories/tree.v):\n```coq\nInductive rtree : Type :=  ⟨ _ ⟩ᵣ : list rtree → rtree.\n\nInductive rtree_homeo_embed : rtree → rtree → Prop :=\n  | rtree_homeo_embed_subt s t l : t ∈ l → s ≤ₕ t → s ≤ₕ ⟨l⟩ᵣ\n  | rtree_homeo_embed_root l m : list_embed rtree_homeo_embed l m → ⟨l⟩ᵣ ≤ₕ ⟨m⟩ᵣ\nwhere \"s ≤ₕ t\" := (rtree_homeo_embed s t).\n\nDefinition rtree_size : rtree → nat.\nNotation \"⌊ t ⌋ᵣ\" := (rtree_size t).\n\nFact rtree_size_fix l : ⌊⟨l⟩ᵣ⌋ᵣ = 1 + list_sum rtree_size l.\n\nDefinition Friedman_tree : nat → nat.\n\nTheorem Friedman_tree_spec n :\n ∀m, m ≤ Friedman_tree n\n   ↔ ∃ t : vec rtree m, (∀i, ⌊tᵢ⌋ᵣ = 1+i+n) ∧ (∀ i j, i \u003c j → ¬ tᵢ ≤ₕ tⱼ).\n```\n\nThe essential argument to built the value `Friedman_tree n` is to show that there is a length `m` such that any sequence\nof trees `[t₁;...;tₘ]` of increasing sizes (as specified above) is good for the homeomorphic embedding `≤ₕ`:\n- first, using Kruskal's theorem in its (equivalent) formulation using inductive bars, any (ever expending)\n  sequence of trees is bound to become `≤ₕ`-good;\n- second, at any given value `s`, the trees which have size `s` are finitely many;\n- hence, we build the \"set\" of size increasing sequences of trees as a _finitary FAN_, ie a\n  finite collection of choice sequences;\n- then, applying the FAN theorem for inductive bars, all the size increasing sequences are bound to\n  become `≤ₕ`-good _uniformly_, ie all simultaneously;\n- the point `m` where all the size increasing sequences of length `m` become `≤ₕ`-good is the needed value.\n \nSince, the spec of `Friedman_tree n` is decidable, anti-monotonic and bounded (by the above `m`), \nthe value `Friedman_tree n` can be computed by linear search using a variant of Constructive Epsilon.\n\nNotice that our implementation is _axiom free_, hence purely constructive. Compared to the argument developed in [Wikipedia](https://en.wikipedia.org/wiki/Kruskal%27s_tree_theorem), we here use a _constructive version of Kruskal's theorem_ from [`Kruskal-Theorems`](https://github.com/DmxLarchey/Kruskal-Theorems), and we replace _Koenig's lemma_ with the FAN theorem for inductive bars as established constructivelly also in [`Kruskal-FAN`](https://github.com/DmxLarchey/Kruskal-FAN).\n\n## The Friedman `TREE(n)` function\n\nThe Friedman `TREE(n)` function is [insanely fast growing function](https://en.wikipedia.org/wiki/Kruskal%27s_tree_theorem) of which the termination proof depends on the proof of Kruskal's tree theorem itself. The construction we perfom in Coq is similar to the previous one but operates on rose trees decorated with the finite type `idx n ≃ [1,...,n]` where `n` is the parameter of `Friedman_TREE n`. The construction of `Friedman_TREE` and the theorem `Friedman_TREE_spec` are performed in [`TREE.v`](theories/TREE.v):\n\n```coq\nDefinition ntree (n : nat) := ltree (idx n).\nNotation \"⟨i|l⟩ₗ\" := (ltree_node i l).\n\nDefinition ntree_size {n} : ntree n → nat := @ltree_size _.\nNotation \"⌊ t ⌋ₙ\" := (ntree_size t).\nFact ntree_size_fix i l : ⌊⟨i,l⟩ₗ⌋ₙ = 1 + list_sum ntree_size l.\n\nDefinition ntree_embed {n} : rel₂ (ntree n) := ltree_homeo_embed (@eq _).\nNotation \"l ≤ₕ m\" := (ntree_homeo_embed l m).\n\nDefinition Friedman_TREE : nat → nat.\n\nTheorem Friedman_TREE_spec n :\n ∀m, m ≤ Friedman_TREE n\n   ↔ ∃ t : vec (ntree n) m, (∀i, ⌊tᵢ⌋ₙ ≤ 1+i) ∧ (∀ i j, i \u003c j → ¬ tᵢ ≤ₕ tⱼ).\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmxlarchey%2Ffriedman-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmxlarchey%2Ffriedman-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmxlarchey%2Ffriedman-tree/lists"}