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

Variables and sections (Coq-style) #38

Merged
merged 11 commits into from
May 18, 2023
Merged

Variables and sections (Coq-style) #38

merged 11 commits into from
May 18, 2023

Conversation

fizruk
Copy link
Member

@fizruk fizruk commented May 17, 2023

This introduces Coq-style variables and sections.
See #37 for some comparison and discussion around variables in Lean vs Coq vs Rzk.

  • Named sections (#section <name>, ended with #end <name>)
    • Check that names match
  • Unnamed sections (#section, ended with #end)
  • Single-variable command (#variable x : T)
  • Multi-variable command (#variables x y z : T)
  • Issue an error if a variable is used implicitly (not mentioned in its type or body)
    • Support explicit declaration of (implicitly) used variables to suppress the error
  • Issue an error if a variable is never used
  • Documentation
  • Fix free vars extraction for typed terms (have to get free vars from types recursively, possibly should be cached in TypeInfo)
  • Tests (would be nice to have some)

Note that point variables with tope restrictions and patterns are not supported.
That is you cannot define the following:

#variable {t : I | psi t}   -- ERROR: tope restrictions are not supported!
#variable s : Δ²            -- ERROR: tope restrictions are not supported!
#variable (t, s) : 2 * 2    -- ERROR: patterns are not supported!

@fizruk
Copy link
Member Author

fizruk commented May 17, 2023

Example of a warning for an implicit assumption in the following definition:

https://github.com/fizruk/rzk/blob/018e70deb20e1a6bbd35fbe373d20634ba2d362c/docs/docs/rzk-1/recId.md?plain=1#L144-L162

[ 19 out of 20 ] Checking #define recId
Warning: implicit assumption
  r : relfunext2
used in definition of
  recId

EDIT: this is now an error rather than a warning.

@fizruk
Copy link
Member Author

fizruk commented May 18, 2023

The warning can now be suppressed by explicitly mentioning used variables (it is sufficient to only mention variables that are used implicitly):

#def recId uses (r) -- we declare that recId is using r on purpose
    (a_psi : (t : psi) -> A t)
    (a_phi : (t : phi) -> A t)
    (e : {t : I | psi t /\ phi t} -> a_psi t = a_phi t)
  : {t : I | psi t \/ phi t} -> A t
  := ...

@fizruk fizruk marked this pull request as ready for review May 18, 2023 09:41
@fizruk fizruk merged commit bbe78be into develop May 18, 2023
@fizruk fizruk deleted the variables-and-sections branch May 18, 2023 09:48
This was referenced May 18, 2023
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.

None yet

1 participant