8000 Exception handling, more cvc5 functions, documentation, tests by AdrienChampion · Pull Request #4 · abdoo8080/lean-cvc5 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Exception handling, more cvc5 functions, documentation, tests #4

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

Open
wants to merge 59 commits into
base: main
Choose a base branch 8000
from

Conversation

AdrienChampion
Copy link
Collaborator
  • deal with C++ exceptions cleanly: many TermManager and Solver functions can now produce clean, lean-level errors

    this is both for a nicer user experience and to test failures using the test framework from Test framework #2 (C++ exceptions crash the lean server)

  • provide small, safe helpers for functions that now generate Except Error T instead of plain T values

  • lift many TermManager/Solver cvc5 functions

  • significant documentation effort

  • start adding C++ API tests: Cvc5Test/ApiTermManagerBlack.lean (currently incomplete)

Copy link
Owner
@abdoo8080 abdoo8080 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 the PR! Here is my first batch of comments! I will review other files later.

Copy link
Owner

Choose a reason for hiding this comment

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

Cvc5Test/TermManager.lean is good enough!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are you sure? I thought it would be better to use the same file name as the original test.

Copy link
Owner

Choose a reason for hiding this comment

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

Api and Black are C++ implementation specific. We don't have bindings for anything beyond the public API nor test any internal functionality. So, those parts of the name don't apply. This is also more consistent with the Java and Python naming conventions.

@[extern "term_getOp"]
opaque getOp : Term → Op
private opaque getOp! : Term → Op
Copy link
Owner

Choose a reason for hiding this comment

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

Shouldn't the default function be getOp : Term → Except Error Op? This version: getOp! : Term → Op should be defined in terms of the former (via a macro). I am thinking of something like:

defs getOp : Term → Except Error Op

where defs is a macro that expands into:

@[extern "term_getOp"]
opaque getOp : Term → Except Error Op

def getOp! : Term → Op := Error.unwrap o getOp

@[extern "term_getSymbol"]
opaque getSymbol : Term → String
private opaque getSymbol! : Term → String
Copy link
Owner

Choose a reason for hiding this comment

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

Same as above...

@[extern "term_getSkolemId"]
opaque getSkolemId : Term → SkolemId
opaque getSkolemId! : Term → SkolemId
Copy link
Owner

Choose a reason for hiding this comment

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

ditto...

-/
@[extern "termManager_mkFloatingPointSort"]
opaque mkFloatingPointSort : TermManager → (exp sig : UInt32) → cvc5.Sort
private opaque mkFloatingPointSortUnsafe : TermManager → (exp sig : UInt32) → Except Error cvc5.Sort
Copy link
Owner

Choose a reason for hiding this comment

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

This should also be safe...

- `base`: The base of the string representation of `size`.
-/
@[extern "termManager_mkFiniteFieldSort"]
opaque mkFiniteFieldSortOfString
Copy link
Owner

Choose a reason for hiding this comment

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

Just take a Int/Nat as input. No need for all these versions (or exceptions). Only BitVec and FloatingPoint need to use machine integers.

@[extern "termManager_mkBoolean"]
opaque mkBoolean : TermManager → Bool → Term
opaque mkBoolean : TermManager → (b : Bool) → Except Error Term
Copy link
Owner

Choose a reason for hiding this comment

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

This function is safe


- `i`: The integer constant.
-/
def mkInteger (tm : TermManager) : (i : Int) → Except Error Term :=
Copy link
Owner

Choose a reason for hiding this comment

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

Ditto

Comment on lines +755 to +758
@[inherit_doc mkTermOfOp]
def mkTermOfOp! tm op children :=
mkTermOfOp tm op children
|> Error.unwrap!
Copy link
Owner

Choose a reason for hiding this comment

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

Use macro. Avoid use of |> if the number of consecutive parentheses is less than 3: (mkTermOfOp tm op children).unwrap!

@abdoo8080 abdoo8080 force-pushed the main branch 4 times, most recently from 1a79ef4 to 76a58ac Compare January 1, 2025 04:57
@abdoo8080 abdoo8080 force-pushed the main branch 2 times, most recently from 48f53fd to 319a41a Compare May 7, 2025 09:37
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.

2 participants
0