Skip to content

feat: heuristic verifier framework for lint rewrites#177

Open
notJoon wants to merge 15 commits intomainfrom
feat/formal-verification-framework
Open

feat: heuristic verifier framework for lint rewrites#177
notJoon wants to merge 15 commits intomainfrom
feat/formal-verification-framework

Conversation

@notJoon
Copy link
Copy Markdown
Member

@notJoon notJoon commented Dec 20, 2025

Description

  • Introduce the MiniLogic package: a termination-aware, call-order–sensitive verifier for lint rewrite equivalence.
    • Add AST-to-MiniLogic conversion and verification gate so early-return suggestions only apply when verified.
    • Provide normalization utilities, symbolic condition handling, and extensive unit tests covering control-flow, scope, calls, and early-return patterns.

Key changes

  • New internal/minilogic package with evaluator, equivalence checker, normalization, and symbolic condition solver.
    • New internal/lints/minilogic_gate.go with AST conversion and verification for early- return lint.
    • Early-return lint now uses MiniLogic to block unsafe auto-fixes.

- Add value types
- Add `Env` for symbolic environment model with scoping
- Define `Expr` and `Stmt` AST nodes for IR
- Add `Result` types for termination-aware evaluation (i.e. `Continue`,
  `Return` ...)
- Add expression evalator with arithmetic and boolean ops
- Implement statement evaluator with short-circuit sequencing
- Support return, break, continue termination statements
- Handle if-init scoping with proper variable cleanup
- Add `CallPolicy` (`OpaqueCalls`/`DisallowCalls`) for functon calls
- add `CondSolver` interface with `BasicCondSolver`
- merge symbolic if results with ite-valued env/returns
call order enforcement

Extend `OpaqueCalls` to track call order and multiplicity for `CallExpr`
inside expression, not just `CallStmt`.

- Thread call logs through expression eval paths
- auumulate calls in order within `BinaryExpr`, `UnaryExpr`, and
  `CallExpr`
- Include calls in conds, assignments, and return expression under the
  same call sequence rules
- Extend AST conversion and evaluator to support `var` in `if init;
  conde {}`
- Support `if x, ok := expr; cond`
@notJoon notJoon changed the title feat: Formal verification framework feat: heuristic verifier framework for lint rewrites Dec 20, 2025
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