Skip to content
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ vcs/*.smt2
*.py.ion
*.py.ion.core.st

Strata.code-workspace
Strata.code-workspace
Build/
2 changes: 1 addition & 1 deletion Strata/Languages/Laurel/ConstrainedTypeElim.lean
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private def mkWitnessProc (ptMap : ConstrainedTypeMap) (ct : ConstrainedType) :
{ name := mkId s!"$witness_{ct.name.text}"
inputs := []
outputs := []
body := .Transparent ⟨.Block [witnessInit, assert] none, src⟩
body := .Opaque [] (some ⟨.Block [witnessInit, assert] none, src⟩) []
preconditions := []
isFunctional := false
decreases := none }
Expand Down
8 changes: 6 additions & 2 deletions Strata/Languages/Laurel/HeapParameterization.lean
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ where
let isLast := idx == n - 1
let s' ← recurse s (isLast && valueUsed)
let rest' ← processStmts (idx + 1) rest
pure (s' :: rest')
-- Flatten blocks created by recurse so that
-- Declare targets remain in the enclosing scope.
match s'.val with
| .Block innerStmts (some "$inlineMe") => pure (innerStmts ++ rest')
| _ => pure (s' :: rest')
Comment thread
tautschnig marked this conversation as resolved.
termination_by sizeOf remaining
let stmts' ← processStmts 0 stmts
return ⟨ .Block stmts' label, source ⟩
Expand Down Expand Up @@ -389,7 +393,7 @@ where

-- Create a block if necessary
if suffixes.length > 0 then
return ⟨ StmtExpr.Block (newAssign :: suffixes) none, source ⟩
return ⟨ StmtExpr.Block (newAssign :: suffixes) (some "$inlineMe"), source ⟩
else
return newAssign

Expand Down
9 changes: 9 additions & 0 deletions Strata/Languages/Laurel/LaurelCompilationPipeline.lean
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ private def runLaurelPasses (options : LaurelTranslateOptions) (program : Progra
-- Run resolve after the pass if needed
if pass.needsResolves then
let result := resolve program (some model)
let newErrors := result.errors.filter fun e => !resolutionErrors.contains e
if !newErrors.isEmpty then
let newDiags := newErrors.toList.map fun d =>
{ d with
message :=
s!"Internal error: resolution after '{pass.name}' introduced this diagnostic: {d.message}"
type := .StrataBug }
emit pass.name "laurel.st" program
return (program, model, allDiags ++ newDiags, allStats)
Comment thread
keyboardDrummer marked this conversation as resolved.
program := result.program
model := result.model
emit pass.name "laurel.st" program
Expand Down
3 changes: 3 additions & 0 deletions StrataTest/Languages/Laurel/ConstrainedTypeElimTest.lean
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ procedure test(n: int)
ensures nat$constraint(r)
{ assert r >= 0; var y: int := n; assert nat$constraint(y); return y };
procedure $witness_nat()
opaque
{ var $witness: int := 0; assert nat$constraint($witness) };
-/
#guard_msgs in
Expand Down Expand Up @@ -80,6 +81,7 @@ info: function pos$constraint(v: int): bool
procedure test(b: bool)
{ if b then { var x: int := 1; assert pos$constraint(x) }; { var x: int := -5; x := -10 } };
procedure $witness_pos()
opaque
{ var $witness: int := 1; assert pos$constraint($witness) };
-/
#guard_msgs in
Expand All @@ -104,6 +106,7 @@ info: function posint$constraint(x: int): bool
procedure f()
{ var x: int; assume posint$constraint(x); assert x == 1 };
procedure $witness_posint()
opaque
{ var $witness: int := 1; assert posint$constraint($witness) };
-/
#guard_msgs in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,5 @@ procedure fieldTargetInMultiAssign()
};
"#

#guard_msgs(drop info, error) in
#guard_msgs (drop info, error) in
#eval testInputWithOffset "MutableFields" program 14 processLaurelFile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace Strata.Laurel
def instanceProcedureProgram := r"
composite Counter {
var count: int
procedure increment(self: Counter)
// ^^^^^^^^^ error: Instance procedure 'increment' on composite type 'Counter' is not yet supported
procedure self_increment(self: Counter)
// ^^^^^^^^^^^^^^ error: Instance procedure 'self_increment' on composite type 'Counter' is not yet supported
opaque
{
self#count := self#count + 1
Expand Down
10 changes: 10 additions & 0 deletions StrataTest/Languages/Laurel/TestExamples.lean
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,14 @@ def processLaurelFileWithOptions (options : LaurelVerifyOptions) (input : InputC
def processLaurelFile (input : InputContext) : IO (Array Diagnostic) :=
processLaurelFileWithOptions default input

/-- Project-root-relative path to the `Build/` directory for intermediate files.
Resolved from the current working directory so it works on any machine. -/
def buildDir : IO String := do
let cwd ← IO.currentDir
return s!"{cwd}/Build/"

def processLaurelFileKeepIntermediates (input : InputContext) : IO (Array Diagnostic) := do
let dir ← buildDir
processLaurelFileWithOptions { translateOptions := { keepAllFilesPrefix := dir}} input

end Laurel
Loading