Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 7ce4717

Browse files
committed
refactor(computability/reduce): define many-one degrees without parameter (#2630)
The file `reduce.lean` defines many-one degrees for computable reductions. At the moment every primcodable type `α` has a separate type of degrees `many_one_degree α`. This is completely antithetical to the notion of degrees, which are introduced to classify problems up to many-one equivalence. This PR defines a single `many_one_degree` type that lives in `Type 0`. We use the `ulower` infrastructure from #2574 which shows that every type is computably equivalent to a subset of natural numbers. The function `many_one_degree.of` which assigns to every set of a primcodable type a degree is still universe polymorphic. In particular, we show that `of p = of q ↔ many_one_equiv p q`, etc. in maximal generality, where `p` and `q` are subsets of different types in different universes. See previous discussion at #1203.
1 parent d533fbb commit 7ce4717

File tree

2 files changed

+202
-116
lines changed

2 files changed

+202
-116
lines changed

src/computability/partrec.lean

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,17 @@ theorem option_map {f : α → option β} {g : α → β → σ}
564564
(hf : computable f) (hg : computable₂ g) : computable (λ a, (f a).map (g a)) :=
565565
option_bind hf (option_some.comp₂ hg)
566566

567+
theorem option_get_or_else {f : α → option β} {g : α → β}
568+
(hf : computable f) (hg : computable g) :
569+
computable (λ a, (f a).get_or_else (g a)) :=
570+
(computable.option_cases hf hg (show computable₂ (λ a b, b), from computable.snd)).of_eq $
571+
λ a, by cases f a; refl
572+
573+
theorem subtype_mk {f : α → β} {p : β → Prop} [decidable_pred p] {h : ∀ a, p (f a)}
574+
(hp : primrec_pred p) (hf : computable f) :
575+
@computable _ _ _ (primcodable.subtype hp) (λ a, (⟨f a, h a⟩ : subtype p)) :=
576+
nat.partrec.of_eq hf $ λ n, by cases decode α n; simp [subtype.encode_eq]
577+
567578
theorem sum_cases
568579
{f : α → β ⊕ γ} {g : α → β → σ} {h : α → γ → σ}
569580
(hf : computable f) (hg : computable₂ g) (hh : computable₂ h) :

0 commit comments

Comments
 (0)