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

Use #assume and use for FunExt and ExtExt #28

Merged
merged 2 commits into from
Jul 12, 2023
Merged

Conversation

fizruk
Copy link
Collaborator

@fizruk fizruk commented Jul 11, 2023

Closes #26.

@@ -152,16 +157,15 @@ in two steps.
( \ f -> yon-evid-twice-pointwise ϕ x f)

-- By funext again, these are equal as functions of x and f.
#def yon-evid
(funext : FunExt)
#def yon-evid uses (funext)
(ϕ : (z : A) -> hom A a z -> C z)
: ((yon A is-segal-A a C is-covariant-C) ((evid A a C) ϕ )) = ϕ
:= eq-htpy funext
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You may notice that some occurrences of funext (and extext) in arguments is not removed. This is because definitions that use them come from different files, so the argument becomes explicit.

I think it makes sense have a (global) version of #assume that will maintain assumption implicit, even in other files. I will try to introduce such a feature in future versions of rzk.

@fizruk
Copy link
Collaborator Author

fizruk commented Jul 11, 2023

I've also refactored definitions to use shape coercion where possible.

@@ -176,8 +176,8 @@ This is a literate `rzk` file:
( (t : χ) -> X t [ ψ t |-> f t ]))
:=
( \ h -> (\ t -> h t , \ t -> h t) ,
( ( \ fg t -> (second fg) t , \ h -> refl) ,
( ( \ fg t -> (second fg) t , \ h -> refl))))
( ( \ (_f, g) t -> g t , \ h -> refl) ,
Copy link
Owner

Choose a reason for hiding this comment

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

Can you explain the use of the underscore here and elsewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Single underscore (_) means a wildcard pattern (ignore the argument).
An identifier for an argument that starts with an underscore (e.g. _f or _is-segal-A) serves same purpose, but also helps readability, telling the reader a little bit about what the ignored argument represents.

This is a habit I transfer from programming in Haskell, I will gladly hear about @fredrik-bakke's experience in Agda.

Copy link
Contributor

Choose a reason for hiding this comment

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

In Agda, the underscore character has multiple purposes.

  1. It is used as a placeholder character for mixfix syntax. E.g. if you define a function _!, you can apply it by writing x !. Similarly, you could define the function if_then_else_. I think this is one of the big reasons why there are so few reserved characters and why spaces is so important in Agda.
  2. It is used as a placeholder expression to tell Agda to infer a term.
  3. It is used as a standalone token as a discard similar to how it functions in for instance C#. For example, if you want to define a constant function taking two arguments, you could write \ _ _ -> x.

I quite like having just _ when discarding arguments as it looks more clean and doesn't clutter the code space with information that is irrelevant anyways. In agda-unimath, if an argument is not "irrelevant", but is not directly used in a definition, we tend to just give it a normal name I think. Other than that, I don't have a strong opinion either way and would be open to having a special naming convention for these. Maybe a suffix would look nicer than a prefix, but perhaps this defeats part of the purpose as it will be less familiar to people coming from Haskell or similar coding languages.

@emilyriehl
Copy link
Owner

I'll be offline for most of the rest of the day, so @fizruk whenever you've resolved the conversations above and feel ready to merge please go ahead.

@fizruk
Copy link
Collaborator Author

fizruk commented Jul 12, 2023

I will merge, but leave the conversations open in case you (or others) have more to say.

@fizruk fizruk merged commit d7cdd09 into master Jul 12, 2023
@fizruk fizruk deleted the assume-funext-extext branch July 12, 2023 15:46
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.

Use #assume (alias of #variables) for extension extensionality
3 participants