Martin Escardo 1st May 2020. This is ported from the Midlands Graduate School 2019 lecture notes https://www.cs.bham.ac.uk/~mhe/HoTT-UF.in-Agda-Lecture-Notes/HoTT-UF-Agda.html https://github.com/martinescardo/HoTT-UF.Agda-Lecture-Notes \begin{code} {-# OPTIONS --safe --without-K #-} module MGS.Partial-Functions where open import MGS.More-FunExt-Consequences public Ξ β : {X : π€ Μ } β (X β π₯ Μ ) β π€ β (π₯ βΊ) Μ Ξ β {π€} {π₯} {X} A = Ξ£ R κ ((x : X) β A x β π₯ Μ ) , ((x : X) β is-subsingleton (Ξ£ a κ A x , R x a)) _β_ : π€ Μ β π₯ Μ β π€ β (π₯ βΊ) Μ X β Y = Ξ β (Ξ» (_ : X) β Y) is-defined : {X : π€ Μ } {A : X β π₯ Μ } β Ξ β A β X β π₯ Μ is-defined (R , Ο) x = Ξ£ a κ _ , R x a being-defined-is-subsingleton : {X : π€ Μ } {A : X β π₯ Μ } (f : Ξ β A) (x : X) β is-subsingleton (is-defined f x) being-defined-is-subsingleton (R , Ο) x = Ο x _[_,_] : {X : π€ Μ } {A : X β π₯ Μ } (f : Ξ β A) (x : X) β is-defined f x β A x (R , s) [ x , (a , r)] = a _οΌβ_ : {X : π€ Μ } {A : X β π₯ Μ } β Ξ β A β Ξ β A β π€ β π₯ Μ f οΌβ g = β x β (is-defined f x β is-defined g x) Γ ((i : is-defined f x) (j : is-defined g x) β f [ x , i ] οΌ g [ x , j ]) module ΞΌ-operator (fe : dfunext π€β π€β) where open basic-arithmetic-and-order being-minimal-root-is-subsingleton : (f : β β β) (m : β) β is-subsingleton (is-minimal-root f m) being-minimal-root-is-subsingleton f m = Γ-is-subsingleton (β-is-set (f m) 0) (Ξ -is-subsingleton fe (Ξ» _ β Ξ -is-subsingleton fe (Ξ» _ β Ξ -is-subsingleton fe (Ξ» _ β π-is-subsingleton)))) minimal-root-is-subsingleton : (f : β β β) β is-subsingleton (minimal-root f) minimal-root-is-subsingleton f (m , p , Ο) (m' , p' , Ο') = to-subtype-οΌ (being-minimal-root-is-subsingleton f) (at-most-one-minimal-root f m m' (p , Ο) (p' , Ο')) ΞΌ : (β β β) β β ΞΌ = is-minimal-root , minimal-root-is-subsingleton ΞΌ-propertyβ : (f : β β β) β (Ξ£ n κ β , f n οΌ 0) β is-defined ΞΌ f ΞΌ-propertyβ = root-gives-minimal-root ΞΌ-propertyβ : (f : β β β) (i : is-defined ΞΌ f) β (f (ΞΌ [ f , i ]) οΌ 0) Γ ((n : β) β n < ΞΌ [ f , i ] β f n β 0) ΞΌ-propertyβ f = prβ is-total : {X : π€ Μ } {A : X β π₯ Μ } β Ξ β A β π€ β π₯ Μ is-total f = β x β is-defined f x infix 30 _[_,_] \end{code}