Skip to content
Merged
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
14 changes: 7 additions & 7 deletions Auto/EvaluateAuto/TestAuto.lean
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,18 @@ def readRunAutoOnConstsResult (resultFile : String) : CoreM (Array (Name × Resu
where
analyzeLine (fileName line : String) : CoreM (Name × Result × Nat × Nat) := do
let line := (line.dropWhile (fun c => c != ' ')).drop 1
let s := line.takeWhile (fun c => c != ' ')
let s := (line.takeWhile (fun c => c != ' ')).toString
let .some res := Result.ofConcise? s
| throwError s!"{decl_name%} :: In file {fileName}, {s} is not a concise representation of a `Result`"
let line := (line.dropWhile (fun c => c != ' ')).drop 1
let s := line.takeWhile (fun c => c != ' ')
let line := ((line.dropWhile (fun c => c != ' ')).drop 1).toString
let s := (line.takeWhile (fun c => c != ' ')).toString
let .some time := String.toNat? s
| throwError s!"{decl_name%} :: In file {fileName}, {s} is not a string representation of a Nat"
let line := (line.dropWhile (fun c => c != ' ')).drop 1
let s := line.takeWhile (fun c => c != ' ')
let line := ((line.dropWhile (fun c => c != ' ')).drop 1).toString
let s := (line.takeWhile (fun c => c != ' ')).toString
let .some hb := String.toNat? s
| throwError s!"{decl_name%} :: In file {fileName}, {s} is not a string representation of a Nat"
let line := (line.dropWhile (fun c => c != ' ')).drop 1
let line := ((line.dropWhile (fun c => c != ' ')).drop 1).toString
let name := Name.parseUniqRepr line
return (name, res, time, hb)

Expand Down Expand Up @@ -332,7 +332,7 @@ def readEATAResult (config : EvalAutoAsyncConfig) :
let allFiles := (← System.FilePath.readDir resultFolder).map IO.FS.DirEntry.path
let mut ret := #[]
for file in allFiles do
if !(← System.FilePath.isDir file) && file.toString.takeRight 7 == ".result" then
if !(← System.FilePath.isDir file) && file.toString.takeEnd 7 == ".result" then
ret := ret.append (← readRunAutoOnConstsResult file.toString)
return ret

Expand Down
22 changes: 11 additions & 11 deletions Auto/EvaluateAuto/TestTactics.lean
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,14 @@ def readEvalTacticsAtModuleResult (resultFile : String) : CoreM (Array (Name ×
where
analyzeLine (fileName line : String) : CoreM (Name × Array (Result × Nat × Nat)) := do
let line := (line.dropWhile (fun c => c != ' ')).drop 3
let tr := (line.takeWhile (fun c => c != ']')).splitOn ", "
let tr : Array (Result × Nat × Nat) ← (Array.mk tr).mapM (fun s => do
let tr := ((line.takeWhile (fun c => c != ']')).split ", ").toStringArray
let tr : Array (Result × Nat × Nat) ← tr.mapM (fun s => do
let [sr, st, sh] := s.splitOn " "
| throwError "s!{decl_name%} :: In file {fileName}, {s} is not of the form `<result> <time> <heartbeats>`"
match Result.ofConcise? sr, String.toNat? st, String.toNat? sh with
| .some r, .some t, .some h => return (r, t, h)
| _, _, _ => throwError s!"{decl_name%} :: In file {fileName}, {s} is not of the form `<result> <time> <heartbeats>`")
let line := (line.dropWhile (fun c => c != ']')).drop 2
let line := ((line.dropWhile (fun c => c != ']')).drop 2).toString
let name := Name.parseUniqRepr line
return (name, tr)

Expand Down Expand Up @@ -493,10 +493,10 @@ def readETMHTResult (config : EvalTacticOnMathlibConfig) :
let allPaths ← System.FilePath.walkDir resultFolder
let mut ret := #[]
for path in allPaths do
if !(← System.FilePath.isDir path) && path.toString.takeRight 7 == ".result" then
if !(← System.FilePath.isDir path) && path.toString.takeEnd 7 == ".result" then
let content ← readEvalTacticsAtModuleResult path.toString
let suffix := (path.toString.drop (resultFolder.length + 1)).dropRight 7
let modName := (suffix.splitOn "/").foldl (fun a b => Name.str a b) .anonymous
let suffix := (path.toString.drop (resultFolder.length + 1)).dropEnd 7
let modName := (suffix.split "/").toStringArray.foldl (fun a b => Name.str a b) .anonymous
ret := ret.push (modName, content)
return ret

Expand All @@ -513,14 +513,14 @@ def readETMHTResultAllowNonRet (config : EvalTacticOnMathlibConfig) :
let mut ret := #[]
let mut nonRet := #[]
for path in allPaths do
if !(← System.FilePath.isDir path) && path.toString.takeRight 7 == ".result" then
if !(← System.FilePath.isDir path) && path.toString.takeEnd 7 == ".result" then
let raw ← IO.FS.readFile path
if raw.length == 0 then
nonRet := nonRet.push (path.toString.dropRight 7)
nonRet := nonRet.push (path.toString.dropEnd 7).toString
continue
let content ← readEvalTacticsAtModuleResult path.toString
let suffix := (path.toString.drop (resultFolder.length + 1)).dropRight 7
let modName := (suffix.splitOn "/").foldl (fun a b => Name.str a b) .anonymous
let suffix := (path.toString.drop (resultFolder.length + 1)).dropEnd 7
let modName := (suffix.split "/").toStringArray.foldl (fun a b => Name.str a b) .anonymous
ret := ret.push (modName, content)
return (nonRet, ret)

Expand Down Expand Up @@ -579,7 +579,7 @@ def readETMHTEvaluateFiles (config : EvalTacticOnMathlibConfig) : CoreM (Array N
if line.contains ':' then
let [name, retCode] := line.splitOn ":"
| throwError "{decl_name%} :: Unexpected line format, line content : `{line}`"
let name := name.dropRight 1
let name := (name.dropEnd 1).toString
let retCode := retCode.drop 1
let some retCode := retCode.toNat?
| throwError "{decl_name%} :: Unexpected line format, line content : `{line}`"
Expand Down
2 changes: 1 addition & 1 deletion Auto/EvaluateAuto/TestTranslation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ where analyzeLine (line : String) : CoreM (Name × Nat × Option Nat) := do
let .some rawSize := rawSizeStr.toNat?
| throwError "{decl_name%} :: {rawSizeStr} is not a string representation of a Nat"
let monoSizeStr := line.takeWhile (fun c => c != ' ')
let line := (line.dropWhile (fun c => c != ' ')).drop 1
let line := ((line.dropWhile (fun c => c != ' ')).drop 1).toString
let mut monoSize? : Option Nat := .none
if monoSizeStr != "N" then
let .some monoSize := monoSizeStr.toNat?
Expand Down
2 changes: 1 addition & 1 deletion Auto/IR/SMT.lean
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace IR.SMT
def isSimpleSymbol (s : String) : Bool :=
let symbSpecials := "~!@$%^&*_-+=<>.?/"
let front := s.front.isAlpha || (symbSpecials.contains s.front)
let body := s.all (fun c => c.isAlphanum || symbSpecials.contains c)
let body := s.all (fun (c : Char) => c.isAlphanum || symbSpecials.contains c)
s.length != 0 && front && body

-- <index> ::= <numeral> | <symbol>
Expand Down
8 changes: 4 additions & 4 deletions Auto/Parser/SMTSexp.lean
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ def LexVal.ofString (s : String) (attr : String) : LexVal :=
let bdigs := s.drop 2
.nat (bdigs.foldl (fun x c => x * 2 + c.toNat - '0'.toNat) 0)
| "string" =>
let subs := ((s.drop 1).take (s.length - 2)).splitOn "\"\""
let subs := (((s.drop 1).take (s.length - 2)).split "\"\"").toStringList
.str (String.intercalate "\"" subs)
| "simplesymbol" => .symb s
| "quotedsymbol" => .symb ((s.drop 1).take (s.length - 2))
| "keyword" => .kw (s.drop 1)
| "quotedsymbol" => .symb ((s.drop 1).take (s.length - 2)).toString
| "keyword" => .kw (s.drop 1).toString
| "comment" =>
let rn : Nat := if String.Pos.Raw.get s (String.Pos.Raw.prev s (String.Pos.Raw.prev s s.rawEndPos)) == '\r' then 1 else 0
.comment ((s.drop 1).take (s.length - 2 - rn))
.comment ((s.drop 1).take (s.length - 2 - rn)).toString
| _ => panic! s!"LexVal.ofString :: {repr attr} is not a valid attribute"

inductive Sexp where
Expand Down
14 changes: 7 additions & 7 deletions Auto/Parser/TPTP.lean
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def ident2StringConst (s : String) : Option StringConst :=
match x, y.toNat? with
| .some l, .some y' => .some (l.push (Char.ofNat y'))
| _, _ => .none
match s.take 9, (((s.drop 9).splitOn "d").drop 1).foldl foldFn (.some "") with
match s.take 9, (((s.drop 9).split "d").drop 1).toStringArray.foldl foldFn (.some "") with
| "t_strVal_", .some s => .some (.strVal s)
| _, _ => .none

Expand Down Expand Up @@ -426,7 +426,7 @@ open Embedding.Lam in
def ident2BitVecConst (s : String) : Option BitVecConst :=
match s.take 7 with
| "t_bvVal" =>
match (s.drop 7).splitOn "_" with
match ((s.drop 7).split "_").toList with
| ["", ns, is] =>
match ns.toNat?, is.toNat? with
| .some n, .some i => .some (.bvVal n i)
Expand Down Expand Up @@ -548,35 +548,35 @@ def ident2BitVecConst (s : String) : Option BitVecConst :=
| "ashr", .some n => .some (.bvsmtashr n)
| _, _ => .none
| "t_bvapp" =>
match s.take 11, (s.drop 11).splitOn "_" with
match s.take 11, ((s.drop 11).split "_").toList with
| "t_bvappend_", [ns, ms] =>
match ns.toNat?, ms.toNat? with
| .some n, .some m => .some (.bvappend n m)
| _, _ => .none
| _, _ => .none
| "t_bvext" =>
match s.take 12, (s.drop 12).splitOn "_" with
match s.take 12, ((s.drop 12).split "_").toList with
| "t_bvextract_", [ns, hs, ls] =>
match ns.toNat?, hs.toNat?, ls.toNat? with
| .some n, .some h, .some l => .some (.bvextract n h l)
| _, _, _ => .none
| _, _ => .none
| "t_bvrep" =>
match s.take 11, (s.drop 11).splitOn "_" with
match s.take 11, ((s.drop 11).split "_").toList with
| "t_bvrepeat_", [ws, is] =>
match ws.toNat?, is.toNat? with
| .some w, .some i => .some (.bvrepeat w i)
| _, _ => .none
| _, _ => .none
| "t_bvzer" =>
match s.take 15, (s.drop 15).splitOn "_" with
match s.take 15, ((s.drop 15).split "_").toList with
| "t_bvzeroExtend_", [ws, vs] =>
match ws.toNat?, vs.toNat? with
| .some w, .some v => .some (.bvzeroExtend w v)
| _, _ => .none
| _, _ => .none
| "t_bvsig" =>
match s.take 15, (s.drop 15).splitOn "_" with
match s.take 15, ((s.drop 15).split "_").toList with
| "t_bvsignExtend_", [ws, vs] =>
match ws.toNat?, vs.toNat? with
| .some w, .some v => .some (.bvsignExtend w v)
Expand Down
2 changes: 1 addition & 1 deletion Auto/Translation/LamFOL2SMT.lean
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def SMTNamingInfo.exprToSuggestion (e : Expr) : MetaM String := do
return toString (← PrettyPrinter.formatTerm ppSyntax)

def SMTNamingInfo.suggestNameForSort (sni : SMTNamingInfo) (s : LamSort) := do
let suggestion := ((← go s).take 1).toLower
let suggestion := ((← go s).take 1).toString.toLower
trace[auto.lamFOL2SMT.nameSuggestion] "`{suggestion}` for LamSort `{s}`"
return suggestion
where
Expand Down
2 changes: 1 addition & 1 deletion lean-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
leanprover/lean4:v4.26.0
leanprover/lean4:v4.27.0