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

Add support for :is_eq #82

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ethos 0.1.1 prerelease

- When parsing Eunoia signatures, decimals and hexidecimals are never normalized, variables in binders are always unique for their name and type, and let is never treated as a builtin way of specifying macros. The options `--no-normalize-dec`, `--no-normalize-hex`, `--binder-fresh`, and `--no-parse-let` now only apply when parsing proofs and reference files.
- Adds a new option `--normalize-num`, which also only applies when reference parsing. This option treats numerals as rationals, which can be used when parsing SMT-LIB inputs in logics where numerals are shorthand for rationals.
- Adds support for an attribute `:is_eq` to test whether a defined term is equal to another.
- Fixed a bug when applying operators with opaque arguments.

ethos 0.1.0
Expand Down
1 change: 1 addition & 0 deletions src/attr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ std::ostream& operator<<(std::ostream& o, Attr a)
case Attr::VAR: o << "VAR"; break;
case Attr::IMPLICIT: o << "IMPLICIT"; break;
case Attr::TYPE: o << "TYPE"; break;
case Attr::IS_EQ: o << "IS_EQ"; break;
case Attr::SORRY: o << "SORRY"; break;
case Attr::LIST: o << "LIST"; break;
case Attr::REQUIRES: o << "REQUIRES"; break;
Expand Down
2 changes: 2 additions & 0 deletions src/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ enum class Attr
VAR,
IMPLICIT,
REQUIRES,
// inspecting define
TYPE,
IS_EQ,
// properties of rules
SORRY,

Expand Down
17 changes: 15 additions & 2 deletions src/expr_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ ExprParser::ExprParser(Lexer& lex, State& state, bool isSignature)
{
d_strToAttr[":var"] = Attr::VAR;
d_strToAttr[":implicit"] = Attr::IMPLICIT;
d_strToAttr[":is_eq"] = Attr::IS_EQ;
d_strToAttr[":type"] = Attr::TYPE;
d_strToAttr[":list"] = Attr::LIST;
d_strToAttr[":requires"] = Attr::REQUIRES;
Expand Down Expand Up @@ -1165,15 +1166,27 @@ void ExprParser::parseAttributeList(Kind k, Expr& e, AttrMap& attrs, bool& pushe
break;
case Kind::LAMBDA:
{
// only :type is available in define
Assert (!e.isNull());
if (a==Attr::TYPE)
{
Assert (!e.isNull());
handled = true;
val = parseExpr();
// run type checking
typeCheck(e, val);
}
else if (a==Attr::IS_EQ)
{
handled = true;
val = parseExpr();
if (e!=val)
{
std::stringstream msg;
msg << "Terms are not equal:" << std::endl;
msg << "Expression: " << e << std::endl;
msg << "Target expression: " << val << std::endl;
d_lex.parseError(msg.str());
}
}
}
break;
case Kind::NONE:
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ set(ethos_test_file_list
disamb-arith.eo
opaque-inline.eo
implicit-then-var.eo
is_eq.eo
)

macro(ethos_test file)
Expand Down
3 changes: 3 additions & 0 deletions tests/is_eq.eo
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

(define test () (eo::add 1 1) :is_eq 2)