Skip to content

Commit 30b9518

Browse files
authored
Require programs and oracles to have at least one argument (#135)
Also drops support for general extensions to the syntax for program/declare-rule, which we decided not to focus on.
1 parent c81e4bc commit 30b9518

3 files changed

Lines changed: 14 additions & 43 deletions

File tree

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ethos 0.1.2 prerelease
1818
- The option `--print-let` has been renamed to `--print-dag` and is now enabled by default. The printer is changed to use `eo::define` instead of `let`.
1919
- Ethos now explicitly forbids `:var`, `:implicit`, and `:opaque` on return types.
2020
- The option `--binder-fresh`, which specified for fresh variables to be constructed when parsing binders, has been removed.
21+
- Programs and oracles now are explicitly required to have at least one argument.
2122

2223
ethos 0.1.1
2324
===========

src/cmd_parser.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ bool CmdParser::parseNextCommand()
161161
sk = Kind::CONST;
162162
if (tok==Token::DECLARE_ORACLE_FUN)
163163
{
164+
if (sorts.empty())
165+
{
166+
d_lex.parseError("Oracle functions must have at least one argument");
167+
}
164168
ck = Attr::ORACLE;
165169
sk = Kind::ORACLE;
166170
std::string oname = d_eparser.parseSymbol();
@@ -360,14 +364,6 @@ bool CmdParser::parseNextCommand()
360364
}
361365
d_state.pushScope();
362366
std::string name = d_eparser.parseSymbol();
363-
if (d_lex.peekToken()==Token::KEYWORD)
364-
{
365-
std::string keyword = d_eparser.parseKeyword();
366-
if (keyword!="ethos")
367-
{
368-
d_lex.parseError("Unsupported rule format");
369-
}
370-
}
371367
std::vector<Expr> vs =
372368
d_eparser.parseAndBindSortedVarList(Kind::PROOF_RULE);
373369
Expr assume;
@@ -717,14 +713,6 @@ bool CmdParser::parseNextCommand()
717713
case Token::PROGRAM:
718714
{
719715
std::string name = d_eparser.parseSymbol();
720-
if (d_lex.peekToken()==Token::KEYWORD)
721-
{
722-
std::string keyword = d_eparser.parseKeyword();
723-
if (keyword!="ethos")
724-
{
725-
d_lex.parseError("Unsupported program format");
726-
}
727-
}
728716
// push the scope
729717
d_state.pushScope();
730718
std::vector<Expr> vars =
@@ -736,6 +724,10 @@ bool CmdParser::parseNextCommand()
736724
{
737725
progType = d_state.mkProgramType(argTypes, retType);
738726
}
727+
else
728+
{
729+
d_lex.parseError("Programs must have at least one argument");
730+
}
739731
// it may have been forward declared
740732
Expr pprev = d_state.getVar(name);
741733
Expr pvar;

user_manual.md

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,16 +1275,6 @@ The selectors of a constructor (which are never ambiguous) are returned independ
12751275

12761276
The generic syntax for a `declare-rule` command accepted by `ethos` is:
12771277

1278-
```smt
1279-
(declare-rule <symbol> <keyword>? <sexpr>*)
1280-
```
1281-
1282-
When parsing this command, `ethos` will determine the format of the expected arguments based on the given keyword.
1283-
If the `<keyword>` is not provided, then we assume it has been marked `:ethos`.
1284-
All rules not marked with `:ethos` are not supported by the checker and will cause it to terminate.
1285-
1286-
If the keyword is `:ethos`, then the expected syntax that follows is given below:
1287-
12881278
```smt
12891279
(declare-rule <symbol> :ethos (<typed-param>*) <assumption>? <premises>? <arguments>? <reqs>? :conclusion <term> <attr>*)
12901280
where
@@ -1456,22 +1446,12 @@ Locally assumptions can be arbitrarily nested, for example the above can be exte
14561446

14571447
## Side Conditions
14581448

1459-
Similar to `declare-rule`, Ethos supports an extensible syntax for programs whose generic syntax is given by:
1460-
1461-
```smt
1462-
(program <symbol> <keyword>? <sexpr>*)
1463-
```
1464-
1465-
When parsing this command, `ethos` will determine the format of the expected arguments based on the given keyword.
1466-
If the `<keyword>` is not provided, then we assume it has been marked `:ethos`.
1467-
All programs not marked with `:ethos` are not supported by the checker and will cause it to terminate.
1468-
1469-
If the keyword is `:ethos`, then the expected syntax that follows is given below, and is used for defining recursive programs.
1449+
Ethos supports a `program` command for defining recursive programs.
14701450
In particular, in Ethos, a program is an ordered list of rewrite rules.
14711451
The syntax for this command is as follows.
14721452

14731453
```smt
1474-
(program <symbol> :ethos (<typed-param>*) (<type>*) <type> ((<term> <term>)+))
1454+
(program <symbol> :ethos (<typed-param>*) (<type>+) <type> ((<term> <term>)+))
14751455
```
14761456

14771457
This command declares a program named `<symbol>`.
@@ -1882,7 +1862,7 @@ The syntax and semantics of such functions are described in this [paper](https:/
18821862
In particular, Ethos supports the command:
18831863

18841864
```smt
1885-
(declare-oracle-fun <symbol> (<type>*) <type> <symbol>)
1865+
(declare-oracle-fun <symbol> (<type>+) <type> <symbol>)
18861866
```
18871867

18881868
Like the `declare-fun` command from SMT-LIB, this command declares a constant named `<symbol>` whose type is given by the argument types and return type.
@@ -1984,15 +1964,13 @@ When streaming input to Ethos, we assume the input is being given for a proof fi
19841964
(assume-push <symbol> <term>) |
19851965
(declare-consts <lit-category> <type>) |
19861966
(declare-parameterized-const <symbol> (<typed-param>*) <type> <attr>*) |
1987-
(declare-oracle-fun <symbol> (<type>*) <type> <symbol>) |
1988-
(declare-rule <symbol> <keyword> <sexpr>*) |
1967+
(declare-oracle-fun <symbol> (<type>+) <type> <symbol>) |
19891968
(declare-rule <symbol> (<typed-param>*) <assumption>? <premises>? <arguments>? <reqs>? :conclusion <term> <attr>*) |
19901969
(declare-type <symbol> (<type>*)) |
19911970
(define <symbol> (<typed-param>*) <term> <attr>*) |
19921971
(define-type <symbol> (<type>*) <type>) |
19931972
(include <string>) |
1994-
(program <symbol> <keyword> <sexpr>*) |
1995-
(program <symbol> (<typed-param>*) (<type>*) <type> ((<term> <term>)+)) |
1973+
(program <symbol> (<typed-param>*) (<type>+) <type> ((<term> <term>)+)) |
19961974
(reference <string> <symbol>?) |
19971975
(step <symbol> <term>? :rule <symbol> <simple-premises>? <arguments>?) |
19981976
(step-pop <symbol> <term>? :rule <symbol> <simple-premises>? <arguments>?) |

0 commit comments

Comments
 (0)