Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
test: move External and LRAT tests out of the core repo
Browse files Browse the repository at this point in the history
  • Loading branch information
hargoniX committed Feb 21, 2024
1 parent 0523bda commit 92dd07b
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 39 deletions.
14 changes: 0 additions & 14 deletions LeanSAT/External/LRAT.lean
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,3 @@ def parseLRATProof (path : System.FilePath) : IO (Option (Array IntAction)) := d
| none => encounteredError := true
if encounteredError then return none
else return some proof

syntax (name := loadLRATCommand) "loadLRAT " strLit : command

@[command_elab loadLRATCommand] def elabLoadLRAT : CommandElab := fun stx => do
match stx with
| `(loadLRAT $file) =>
match Syntax.isStrLit? file with
| some file =>
let proof ← loadLRATProof file
IO.println s!"{proof}"
| _ => throwError "Expected strLit: {file}"
| _ => throwError "Failed to parse loadLRAT command"

loadLRAT "./pigeon-hole/hole6.lrat"
22 changes: 0 additions & 22 deletions LeanSAT/LRAT/LRATChecker.lean
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,3 @@ def lratChecker [DecidableEq α] [Clause α β] [Formula α β σ] (f : σ) (prf
if checkSuccess then lratChecker f restPrf
else rup_failure
| del ids :: restPrf => lratChecker (delete f ids) restPrf

open Lean Parser Elab Command Dimacs

syntax (name := lratCheckCommand) "lratCheck" strLit strLit : command

@[command_elab lratCheckCommand] def runLRATCheck : CommandElab := fun stx => do
match stx with
| `(lratCheck $problemFile $prfFile) =>
match Syntax.isStrLit? problemFile, Syntax.isStrLit? prfFile with
| some problemFile, some prfFile =>
let ⟨n, formula⟩ ← loadProblem problemFile
let formula : DefaultFormula n := DefaultFormula.ofArray formula
let proof ← loadLRATProof prfFile
IO.println s!"formula: {formula.dimacs}\n"
-- O.println s!"proof: {proof}\n"
let proof ← proof.mapM $ intActionToDefaultClauseAction n
IO.println s!"lratChecker output: {lratChecker formula proof.toList}"
| _, _ => throwError "Either {problemFile} or {prfFile} did not register as a string literal"
| _ => throwError "Failed to parse loadLRAT command"

lratCheck "./pigeon-hole/hole6.cnf" "./pigeon-hole/hole6.lrat"
lratCheck "./pigeon-hole/hole7.cnf" "./pigeon-hole/hole7.lrat"
2 changes: 2 additions & 0 deletions Test.lean
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Test.Sat
import Test.ExternalDimacs
import Test.LRAT
import Test.LRATChecker
import Test.PHPDemo
17 changes: 17 additions & 0 deletions Test/LRAT.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import LeanSAT.External.LRAT

open LRAT Lean Parser Elab Command

syntax (name := loadLRATCommand) "loadLRAT " strLit : command

@[command_elab loadLRATCommand] def elabLoadLRAT : CommandElab := fun stx => do
match stx with
| `(loadLRAT $file) =>
match Syntax.isStrLit? file with
| some file =>
let proof ← loadLRATProof file
IO.println s!"{proof}"
| _ => throwError "Expected strLit: {file}"
| _ => throwError "Failed to parse loadLRAT command"

loadLRAT "./pigeon-hole/hole6.lrat"
23 changes: 23 additions & 0 deletions Test/LRATChecker.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import LeanSAT.LRAT.LRATChecker

open LRAT Lean Parser Elab Command Dimacs

syntax (name := lratCheckCommand) "lratCheck" strLit strLit : command

@[command_elab lratCheckCommand] def runLRATCheck : CommandElab := fun stx => do
match stx with
| `(lratCheck $problemFile $prfFile) =>
match Syntax.isStrLit? problemFile, Syntax.isStrLit? prfFile with
| some problemFile, some prfFile =>
let ⟨n, formula⟩ ← loadProblem problemFile
let formula : DefaultFormula n := DefaultFormula.ofArray formula
let proof ← loadLRATProof prfFile
IO.println s!"formula: {formula.dimacs}\n"
-- O.println s!"proof: {proof}\n"
let proof ← proof.mapM $ intActionToDefaultClauseAction n
IO.println s!"lratChecker output: {lratChecker formula proof.toList}"
| _, _ => throwError "Either {problemFile} or {prfFile} did not register as a string literal"
| _ => throwError "Failed to parse loadLRAT command"

lratCheck "./pigeon-hole/hole6.cnf" "./pigeon-hole/hole6.lrat"
lratCheck "./pigeon-hole/hole7.cnf" "./pigeon-hole/hole7.lrat"
3 changes: 0 additions & 3 deletions dratproof.out

This file was deleted.

0 comments on commit 92dd07b

Please sign in to comment.