Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Natural Order definition utilizing an identity type #215

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lane-core
Copy link
Contributor

@lane-core lane-core commented Oct 17, 2023

Quoting from the preamble:

Following the equality case of the triangle inequality, we can define a
partial order on ℕ directly with an identity type, namely by considering
the fixed points of the family of functions indexed by x of the form (λ y
→ ∣ y - x ∣ + x). This is because the only inhabitants of these fixed
point equalities are identities where x is less than or equal to y. And
because ℕ is a set, each term of this identity type thereby becomes a
proposition, although in contrast to the standard order definition based
on 𝟙 each inhabitant of our order type is its own distinct refl term and
hence distinct inequalities will not be equal terms.

In hindsight it is obvious a type such as this ought to be possible,
because the definition for the standard order module essentially
calculates the inhabitation of its type by the same recursion algorithm as
absolute difference, with the provision that the succ x ≤ zero case is
defined as the empty type. Our definition leads to a partial order type
with interesting properties. As opposed to the one generated by a function
from ℕ to 𝟙, we are able to work directly with the identifications that
specify the order relation, so 'succ-lc' for example will translate an
inequality of 'succ m ≼ succ n' to 'm ≼ n', and likewise with 'ap succ'
for the other direction. Negation is directly handled by the standard
negation proofs for the Naturals. The use of transport is ergonomic as
each term is directly an identity term. Our type definition also has
strong computational properties that assist Agda's case matching as
opposed to the standard definition; you will never see it attempt to match
for the case 'succ x ≼ zero' as Agda can automatically detect this type
is uninhabited.

We use the curly order '≼' so as not to conflict with the one already
defined for the Naturals. Although the early portions of this module were
written myself, after I translated Escardo's definition of ≤-induction to
this type I decided to go further and have begun translating all the Order
lemmas in the standard module to accommodate this definition. For the most
part, I have attempted to preserve the titles and type definitions
exactly, but in the earlier sections of the modules I took some liberties
as I wanted to tailor the most fundamental lemmas to the character of this
type, and also to make certain operations more ergonomic and reduce the
character count of proofs. Notably, 'equal-gives-less-than-or-equal' is
simply '≼-=' here.

Aside from the fundamental lemmas as well as ones concerning absolute
difference the credit for most of the type definitions that will be listed
here goes to the efforts of Martin Escardo, Tom de Jong, and Andrew Sneap.
Sometimes I needed to tailor their proofs to fit our order definition, but
in many cases I was able to use essentially the same principles from
proofs in the other module to guide the equivalent proofs here.

@lane-core lane-core force-pushed the nat-id-order branch 2 times, most recently from 934b2c3 to 081e84b Compare October 17, 2023 21:22
@lane-core
Copy link
Contributor Author

lane-core commented Oct 17, 2023

corrected a small mistake in the preamble, as well as adding to the index file if this is suitable

Copy link
Owner

@martinescardo martinescardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. I am sorry for the delay. I had forgotten about this.

One more thing: although many parts of TypeTopology use zero, I favour using 0 nowadays, so if you adopt this, it would be great.

as I wanted to tailor the most fundamental lemmas to the character of this
type, and also to make certain operations more ergonomic and reduce the
character count of proofs. Notably, 'equal-gives-less-than-or-equal' is
simply '≼-=' here.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename ≼-= to `≼-gives-=' please?

≼-is-discrete : (x y : ℕ) → is-discrete (x ≼ y)
≼-is-discrete x y = props-are-discrete (≼-is-prop-valued x y)

≼-is-set : (x y : ℕ) → is-set (x ≼ y)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why you are proving ≼-is-discrete and ≼-is-set. For the latter you could use props-are-sets. Do you really need this? I would suggest to delete both.

≼-transport₂ : {x y z w : ℕ} → x = z → y = w → x ≼ y → z ≼ w
≼-transport₂ p q i = transport₂ (_≼ℕ_) p q i

≼-= : (x y : ℕ) → x = y → x ≼ y
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this to =-gives-≼ y.

succ-order-injective : (x y : ℕ) → succ x ≼ succ y → x ≼ y
succ-order-injective x y = succ-lc

¬≼-succ-lc : (x y : ℕ) → ¬ (succ x ≼ succ y) → ¬ (x ≼ y)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would omit the definition in line 186. It is just the contrapositive of the previous one, and we have a definition of contrapositivity in MLTT.Negation.

@@ -9,6 +9,7 @@ import Naturals.Addition
import Naturals.Binary
import Naturals.Division
import Naturals.Exponentiation
import Naturals.IdOrder
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use alphabetical order in the index imports.

@lane-core
Copy link
Contributor Author

I will be implementing these changes after I finish my work for the Modular Group. I've been thoughtful about this module more generally and how I want to structure it. First I was considering the question of under what general conditions it is possible to construct a type equivalence like this, and it seems directly related to the fundamental theorem of identity types, so I'm giving some thought of how to explore that theme in this module.

@ayberkt ayberkt marked this pull request as draft April 24, 2024 17:35
@ayberkt
Copy link
Collaborator

ayberkt commented Apr 24, 2024

I will be implementing these changes after I finish my work for the Modular Group.

@lane-core I’ve converted this to a draft PR since you mentioned that you will be addressing the review after PR #214 is completed.

@lane-core
Copy link
Contributor Author

@ayberkt @martinescardo to update here, a simpler presentation of this idea would use the identity type formed by monus m n = 0 as our definition. But yes, I will address this module after my work in PR #214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants