Skip to content

s2: clauses, loop checks, quantifiers; printer fixpoint on all sources - #19

Merged
vic merged 1 commit into
mainfrom
s2-clauses
Nov 9, 2026
Merged

vic merged 1 commit into
mainfrom
s2-clauses

Conversation

@vic

@vic vic commented Nov 9, 2026

Copy link
Copy Markdown
Owner

FRONT rung 4c: contract clauses, loop checks and quantifiers. FRONT now covers every s1 syntax form that s1 accepts.

  • Ast.Def and Ast.Spec carry their clauses: requires, ensures, returns, decreases, invariant, proof using, proof by induction, proof lean. An extern has none.
  • Ast.Check is a loop invariant or measure; Ast.Quant is forall/exists.
  • Parser follows s1/parse.srs:147-184, 494, 544-548.
  • Names walks clause expressions, with result as a local.

Two printer fixes for forms that did not parse back: do after a match condition goes on its own line, and else goes on a new line when either branch spans several lines.

Fixpoint oracle: for all 171 sources that parse (s2 itself included), print, parse the printed text, and print again gives the same text.

Parse probe: 171 of 176. The other 5: four s1 parse errors (s2 rejects them too) and one int type arg (s1 rejects it later). Four mutants each change the output. Local tests/run.sh: 185 ok, 0 FAIL.

… fixpoint on every source

Ast.Def and Ast.Spec carry their contract clauses (an extern has none): requires, ensures, returns,
decreases, invariant with an expression, proof using, proof by induction, proof lean (Ast.Clause).
Ast.Check is a loop invariant or measure in a block; Ast.Quant is forall/exists x: T => e. The parser
reads them as s1/parse.srs:147-184, 494, 544-548; the printer writes clauses one step in, then = at the
start of a line. Names walks clause expressions with result as a local and proof using as uses.

The printer fixes two forms that did not parse back: a while whose condition is a match writes do on
its own line, and else starts a new line when either branch takes more than one line (Ast.multiLine).
Printing every parsed source, parsing the printed text and printing again gives the same text for all
171 sources that parse (s2 itself included).

tests/s2/parse: tests/contracts.srs parses and prints; an if with a block branch. Parsing every source:
171 of 176; the rest are 4 s1 parse errors (s2 rejects them too) and one int type arg (s1 rejects it
later). Mutants: spec clauses dropped, no quantifiers, else placement from the else branch only, match
not multi-line: each changes the output.
@vic
vic merged commit 14b9ce9 into main Nov 9, 2026
3 checks passed
@vic
vic deleted the s2-clauses branch November 9, 2026 05:44
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.

1 participant