From 1183d1f5248a503d42820244f36836f3178d6f3c Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 13:19:29 -0600 Subject: [PATCH 01/19] Start with renaming Boogie to Core or Strata Core depending on context in docs and Examples, rename *.boogie.(expected,st) -> *.core.(expected,st) --- .kiro/steering/plausible-instructions.md | 2 +- .kiro/steering/structure.md | 46 +++++++++++-------- .kiro/steering/testing-transformations.md | 8 ++-- ...soning.boogie.st => HeapReasoning.core.st} | 0 ...oopSimple.boogie.st => LoopSimple.core.st} | 0 ...impleProc.boogie.st => SimpleProc.core.st} | 0 ...{TypeError.boogie.st => TypeError.core.st} | 0 ...e.expected => HeapReasoning.core.expected} | 0 ...ogie.expected => LoopSimple.core.expected} | 0 ...ogie.expected => SimpleProc.core.expected} | 0 ...oogie.expected => TypeError.core.expected} | 0 ...impleTest.boogie.st => simpleTest.core.st} | 0 ...oogieTransform.lean => CoreTransform.lean} | 0 BoogieToGoto.lean => StrataCoreToGoto.lean | 0 StrataToCBMC.lean | 2 +- docs/Architecture.md | 40 ++++++++-------- docs/Datatypes.md | 22 ++++----- docs/GettingStarted.md | 10 ++-- docs/verso/DDMDoc.lean | 24 +++++----- 19 files changed, 79 insertions(+), 75 deletions(-) rename Examples/{HeapReasoning.boogie.st => HeapReasoning.core.st} (100%) rename Examples/{LoopSimple.boogie.st => LoopSimple.core.st} (100%) rename Examples/{SimpleProc.boogie.st => SimpleProc.core.st} (100%) rename Examples/{TypeError.boogie.st => TypeError.core.st} (100%) rename Examples/expected/{HeapReasoning.boogie.expected => HeapReasoning.core.expected} (100%) rename Examples/expected/{LoopSimple.boogie.expected => LoopSimple.core.expected} (100%) rename Examples/expected/{SimpleProc.boogie.expected => SimpleProc.core.expected} (100%) rename Examples/expected/{TypeError.boogie.expected => TypeError.core.expected} (100%) rename Strata/Backends/CBMC/tests/{simpleTest.boogie.st => simpleTest.core.st} (100%) rename Strata/Transform/{BoogieTransform.lean => CoreTransform.lean} (100%) rename BoogieToGoto.lean => StrataCoreToGoto.lean (100%) diff --git a/.kiro/steering/plausible-instructions.md b/.kiro/steering/plausible-instructions.md index 0e31357a8..95164fabb 100644 --- a/.kiro/steering/plausible-instructions.md +++ b/.kiro/steering/plausible-instructions.md @@ -63,7 +63,7 @@ instance : Shrinkable (α × β) where ``` ### Strata-Specific Types -For Lambda expressions, Imperative statements, or Boogie constructs, ensure generators produce well-typed, valid AST nodes. +For Lambda expressions, Imperative statements, or Strata Core constructs, ensure generators produce well-typed, valid AST nodes. ## Usage Modes diff --git a/.kiro/steering/structure.md b/.kiro/steering/structure.md index 9fc46dc8a..510cdf40e 100644 --- a/.kiro/steering/structure.md +++ b/.kiro/steering/structure.md @@ -27,19 +27,23 @@ Strata is a Lean4 verification framework using **dialects** as composable langua **`Strata/DL/`** - Dialect Library - `Lambda/` - Pure functional expressions (base layer) - `Imperative/` - Statements with control flow (builds on Lambda) -- `SMT/` - SMT-LIB encoding and solver interface +- `SMT/` - The SMT-LIB standard definition and its solver interface - `Util/` - Shared utilities (maps, lists, string generation) **`Strata/Languages/`** - Concrete Language Implementations -- `Boogie/` - Primary verification language (procedures, contracts, VCG, SMT encoding) +- `Core/` - Primary verification language (procedures, contracts, VCG, SMT encoding) - `C_Simp/` - Simplified C-like language - `Dyn/` - Dynamic language example +- `Laurel/` - A common representation for front-end languages like Java, Python and JavaScript. +Translated to Core. +- `Python/` - The well-known Python language **`Strata/Transform/`** - Program Transformations - Each transformation has implementation + optional correctness proof (`*Correct.lean`) +- `CallElim` - Procedure call elimination via inlining the contract - `DetToNondet` - Deterministic to non-deterministic control flow -- `CallElim` - Procedure call elimination via inlining - `LoopElim` - Loop elimination using invariants +- `ProcedureInlining` - Procedure call elimination via inlining the body **`Strata/Backends/`** - Verification Backends - `CBMC/` - C Bounded Model Checker integration @@ -51,7 +55,7 @@ Strata is a Lean4 verification framework using **dialects** as composable langua Dialects are composable language layers, each defining syntax, types, and semantics: - **Lambda** - Base expression layer (functional) - **Imperative** - Adds statements and control flow (uses Lambda expressions) -- **Boogie** - Adds procedures, contracts, and verification (uses Imperative statements) +- **Strata Core (or simply Core)** - Adds procedures, contracts, and verification (uses Imperative statements) ### Lambda Dialect (Expressions) @@ -84,11 +88,13 @@ Statement-level constructs parameterized by expression and command types: - `StmtSemantics.lean` - Operational semantics - `Cmd.lean` - Command interface -## Boogie Dialect +## The Strata Core Dialect -**Location:** `Strata/Languages/Boogie/` +**Location:** `Strata/Languages/Core/` -Intermediate Verification Language for deductive program verification, mirroring the [Boogie verifier](https://github.com/boogie-org/boogie). +Intermediate Verification Language for deductive program verification. +Its syntax is highly motivated by the [Boogie verifier](https://github.com/boogie-org/boogie), +but has additional convenient syntactic features. ### Types (`Factory.lean`) - Primitives: `bool`, `int`, `real`, `bv`, `string` @@ -158,13 +164,13 @@ Program-to-program translations for simplification and verification. Each has op | Expression types | `Strata/DL/Lambda/LTy.lean` | | Statement AST | `Strata/DL/Imperative/Stmt.lean` | | Statement semantics | `Strata/DL/Imperative/StmtSemantics.lean` | -| Boogie expressions | `Strata/Languages/Boogie/Expressions.lean` | -| Boogie commands | `Strata/Languages/Boogie/Statement.lean` | -| Boogie procedures | `Strata/Languages/Boogie/Procedure.lean` | -| Boogie programs | `Strata/Languages/Boogie/Program.lean` | -| Boogie operators | `Strata/Languages/Boogie/Factory.lean` | -| Boogie VCG | `Strata/Languages/Boogie/Verifier.lean` | -| SMT encoding | `Strata/Languages/Boogie/SMTEncoder.lean` | +| Strata Core expressions | `Strata/Languages/Core/Expressions.lean` | +| Strata Core commands | `Strata/Languages/Core/Statement.lean` | +| Strata Core procedures | `Strata/Languages/Core/Procedure.lean` | +| Strata Core programs | `Strata/Languages/Core/Program.lean` | +| Strata Core operators | `Strata/Languages/Core/Factory.lean` | +| Strata Core VCG | `Strata/Languages/Core/Verifier.lean` | +| SMT encoding | `Strata/Languages/Core/SMTEncoder.lean` | | SMT solver | `Strata/DL/SMT/Solver.lean` | | Transformations | `Strata/Transform/*.lean` | @@ -175,21 +181,21 @@ Program-to-program translations for simplification and verification. Each has op **Executables:** - `StrataVerify` - Main verifier -- `BoogieToGoto` - Boogie to GOTO translation +- `StrataCoreToGoto` - Strata Core to GOTO translation - `StrataToCBMC` - CBMC backend **Commands:** ```bash lake build # Build all lake test # Run tests -lake exe StrataVerify Examples/SimpleProc.boogie.st # Verify program +lake exe StrataVerify Examples/SimpleProc.core.st # Verify program ``` ## Verification Workflow -1. Write program (`.boogie.st` file) +1. Write program (`.core.st` file) 2. Parse (DDM parser) -3. Type check (Boogie type system) +3. Type check (Strata Core's type system) 4. Transform (optional: eliminate calls/loops) 5. Generate VCs (symbolic execution) 6. Encode to SMT (SMT-LIB format) @@ -212,7 +218,7 @@ Before starting any implementation task: **Example workflows:** -- **Adding a Boogie feature:** Read `Expressions.lean`, `Statement.lean`, `Factory.lean`, then check `StrataTest/Languages/Boogie/` for test patterns +- **Adding a feature to Strata Core:** Read `Expressions.lean`, `Statement.lean`, `Factory.lean`, then check `StrataTest/Languages/Core/` for test patterns - **Creating a transformation:** Read existing transforms (`DetToNondet.lean`, `CallElim.lean`), their correctness proofs, and tests in `StrataTest/Transform/` - **Modifying expressions:** Read `Strata/DL/Lambda/LExpr.lean`, `LExprEval.lean`, `LTy.lean` to understand the AST, evaluation, and type system - **Working with statements:** Read `Strata/DL/Imperative/Stmt.lean` and `StmtSemantics.lean` before making changes @@ -223,7 +229,7 @@ Before starting any implementation task: - **File organization:** Mirror test structure in `StrataTest/` to match `Strata/` - **Naming:** Use descriptive names; transformations end with `Correct.lean` for proofs -- **Example files:** Use pattern `..st` (e.g., `SimpleProc.boogie.st`) +- **Example files:** Use pattern `..st` (e.g., `SimpleProc.core.st`) - **Proofs:** Transformation correctness proofs are optional but encouraged - **Documentation:** Reference `docs/Architecture.md` for design philosophy, `docs/GettingStarted.md` for tutorials diff --git a/.kiro/steering/testing-transformations.md b/.kiro/steering/testing-transformations.md index 90e906a4c..bc72ab918 100644 --- a/.kiro/steering/testing-transformations.md +++ b/.kiro/steering/testing-transformations.md @@ -19,11 +19,11 @@ Use Plausible for property-based testing of transformations. Three-step process: - Statements: commands (assign, assert, assume, havoc), control flow (if, loop, block) - Bias towards operations over constants for interesting tests -**Key types from `Strata/Languages/Boogie/`:** +**Key types from `Strata/Languages/Core/`:** - `Expression.Expr` (Expressions.lean) - `Statement` (Statement.lean) - `Command` (atomic operations) -- `BoogieIdent` (identifiers) +- `CoreIdent` (identifiers) ## Measurement Functions @@ -78,8 +78,8 @@ Write **total** (not `partial`) Lean functions to measure program properties. |-----------|----------| | Expression AST | `Strata/DL/Lambda/LExpr.lean` | | Statement AST | `Strata/DL/Imperative/Stmt.lean` | -| Boogie expressions | `Strata/Languages/Boogie/Expressions.lean` | -| Boogie statements | `Strata/Languages/Boogie/Statement.lean` | +| Strata Core expressions | `Strata/Languages/Core/Expressions.lean` | +| Strata Core statements | `Strata/Languages/Core/Statement.lean` | | Transformations | `Strata/Transform/*.lean` | | Transform tests | `StrataTest/Transform/*.lean` | diff --git a/Examples/HeapReasoning.boogie.st b/Examples/HeapReasoning.core.st similarity index 100% rename from Examples/HeapReasoning.boogie.st rename to Examples/HeapReasoning.core.st diff --git a/Examples/LoopSimple.boogie.st b/Examples/LoopSimple.core.st similarity index 100% rename from Examples/LoopSimple.boogie.st rename to Examples/LoopSimple.core.st diff --git a/Examples/SimpleProc.boogie.st b/Examples/SimpleProc.core.st similarity index 100% rename from Examples/SimpleProc.boogie.st rename to Examples/SimpleProc.core.st diff --git a/Examples/TypeError.boogie.st b/Examples/TypeError.core.st similarity index 100% rename from Examples/TypeError.boogie.st rename to Examples/TypeError.core.st diff --git a/Examples/expected/HeapReasoning.boogie.expected b/Examples/expected/HeapReasoning.core.expected similarity index 100% rename from Examples/expected/HeapReasoning.boogie.expected rename to Examples/expected/HeapReasoning.core.expected diff --git a/Examples/expected/LoopSimple.boogie.expected b/Examples/expected/LoopSimple.core.expected similarity index 100% rename from Examples/expected/LoopSimple.boogie.expected rename to Examples/expected/LoopSimple.core.expected diff --git a/Examples/expected/SimpleProc.boogie.expected b/Examples/expected/SimpleProc.core.expected similarity index 100% rename from Examples/expected/SimpleProc.boogie.expected rename to Examples/expected/SimpleProc.core.expected diff --git a/Examples/expected/TypeError.boogie.expected b/Examples/expected/TypeError.core.expected similarity index 100% rename from Examples/expected/TypeError.boogie.expected rename to Examples/expected/TypeError.core.expected diff --git a/Strata/Backends/CBMC/tests/simpleTest.boogie.st b/Strata/Backends/CBMC/tests/simpleTest.core.st similarity index 100% rename from Strata/Backends/CBMC/tests/simpleTest.boogie.st rename to Strata/Backends/CBMC/tests/simpleTest.core.st diff --git a/Strata/Transform/BoogieTransform.lean b/Strata/Transform/CoreTransform.lean similarity index 100% rename from Strata/Transform/BoogieTransform.lean rename to Strata/Transform/CoreTransform.lean diff --git a/BoogieToGoto.lean b/StrataCoreToGoto.lean similarity index 100% rename from BoogieToGoto.lean rename to StrataCoreToGoto.lean diff --git a/StrataToCBMC.lean b/StrataToCBMC.lean index d1abed99f..dc79aae7e 100644 --- a/StrataToCBMC.lean +++ b/StrataToCBMC.lean @@ -33,7 +33,7 @@ def main (args : List String) : IO Unit := do if file.endsWith ".csimp.st" then let csimp_prog := C_Simp.get_program pgm IO.println (CSimp.testSymbols csimp_prog.funcs.head!) - else if file.endsWith ".boogie.st" then + else if file.endsWith ".core.st" then let boogie_prog := (Boogie.getProgram pgm inputCtx).fst match boogie_prog.decls.head! with | .proc f => IO.println (Boogie.testSymbols f) diff --git a/docs/Architecture.md b/docs/Architecture.md index 0cac5e463..ff7e98b1a 100644 --- a/docs/Architecture.md +++ b/docs/Architecture.md @@ -28,28 +28,15 @@ In the current implementation of Strata, composition of dialects can occur in tw Transformations (located in [`Strata.Transform`](../Strata/Transform/)) are a central part of the Strata infrastructure. For some dialects, semantics can be canonically defined in terms of reduction into simpler dialects. For other dialects, transformation of constructs from one form to another can make certain analyses more straightforward. For example, some analyses work better on structured programs and some are easier to implement on unstructured programs. Or some analyses might work best with imperative assignments preserved, while some forms of verification condition generation work better on “passive” programs consisting of only assertions and assumptions. -## Dialect Library +## Dialects in Strata -Strata includes several generic dialects that allow it to represent the semantics of a variety of common programming languages. These dialects are currently sufficient to represent the constructs available in Boogie, and allow some flexibility beyond what Boogie provides, as well. These dialects are located in the [`Strata.DL`](../Strata/DL/) namespace. +### 1. Strata Core -### Lambda - -The `Lambda` dialect ([`Strata.DL.Lambda`](../Strata/DL/Lambda/)) is intended to represent pure expressions of the sort that appear in essentially every programming or specification language. This dialect is parameterized by a set of built-in functions, allowing many first-order and higher-order expression languages as specific instantiations. - -### Imperative - -The `Imperative` dialect ([`Strata.DL.Imperative`](../Strata/DL/Imperative/)) is intended to represent imperative statements of the sort that appear in many programming languages. It is built of commands, which execute atomically, and currently has two mechanisms for combining commands: - -* deterministic structured statements (if and while statements with explicit conditions), -* non-deterministic structured statements (choice and repetition, with conditions encoded using assumptions), - -### Boogie - -The Boogie dialect ([`Strata.Languages.Boogie`](../Strata/Languages/Boogie/)) is intended to roughly mirror the capabilities of the [Boogie Intermediate Verification Language](https://github.com/boogie-org/boogie). As its foundation, it uses the `Imperative` dialect parameterized by the `Lambda` dialect. It specializes these dialects in several ways: +The Strata Core dialect ([`Strata.Languages.Core`](../Strata/Languages/Core/)) is intended to roughly mirror the capabilities of the [Boogie Intermediate Verification Language](https://github.com/boogie-org/boogie). As its foundation, it uses the `Imperative` semantic building block parameterized by the `Lambda` semantic building block. For the definition of semantic building block, please refer to the next section. It specializes these blocks in several ways: * It defines a type of identifiers that include scoping information, which is a parameter to `Lambda`. * It introduces data types to represent named functions and procedures with contracts. -* It extends the language of commands from the `Imperative` dialect to include procedure calls, and uses this extended set of commands as a parameter to the various statement types. +* It extends the language of commands from the `Imperative` block to include procedure calls, and uses this extended set of commands as a parameter to the various statement types. It currently provides the following features: @@ -65,9 +52,20 @@ The `Imperative` dialect also includes a verification condition generator (VCG) ### C_Simp -The C_Simp dialect ([`Strata.Languages.C_Simp`](../Strata//Languages/C_Simp/) is a vaguely C-like language intended to show how to model common programming language constructs in Strata. There are many examples in `C_Simp/Examples`. C_Simp builds on the `Imperative` dialect parameterized by the `Lambda` dialect. +The C_Simp dialect ([`Strata.Languages.C_Simp`](../Strata//Languages/C_Simp/)) is a vaguely C-like language intended to show how to model common programming language constructs in Strata. There are many examples in `C_Simp/Examples`. C_Simp builds on the `Imperative` dialect parameterized by the `Lambda` dialect. + +`C_Simp/Verify.lean` demonstrates verification via transformation to Strata Core. A loop elimination pass is first run to transform loops into the appropriate `assume` and `assert` commands, and then Boogie’s VCG, described above, is used to verify the program. + +### Laurel + +The Laurel dialect is supposed to serve as an intermediate verification language for at least Java, Python, JavaScript. It is translated to Strata Core during its deductive verification. +Please refer to the description in the [`Strata.Languages.Laurel.Laurel`](../Strata/Languages/Laurel/Laurel.lean). + +### SMTLib + +The SMTLib dialect exactly implements the syntax of SMTLib 2.7 +([The SMT-LIB Standard Version 2.7, Feb. 5, 2025](https://smt-lib.org/papers/smt-lib-reference-v2.7-r2025-02-05.pdf)). -`C_Simp/Verify.lean` demonstrates verification via transformation to Boogie. A loop elimination pass is first run to transform loops into the appropriate `assume` and `assert` commands, and then Boogie’s VCG, described above, is used to verify the program. ## Analysis @@ -76,11 +74,11 @@ Our intent is that analysis implementations in Strata become highly reusable by * An analysis can be defined over, for instance, imperative control flow graphs, while being generic over the types of commands and expressions that may appear in them, other than requiring that certain operations exist on them. This allows it to straightforwardly be applied to various instantiations of that type. * An analysis can be defined on one dialect, and transformations can move from other dialects into that one. This allows a single analysis implementation to be applied to multiple languages. -The current Strata implementation includes only one analysis: the Boogie dialect VCG. However, you can add your own analyses on top of the existing dialects. The Imperative dialect includes an inductively-defined operational semantics that can be used as a basis for verifying the correctness of analyses. +The current Strata implementation includes only one analysis: the Strata Core dialect VCG. However, you can add your own analyses on top of the existing dialects. The Imperative dialect includes an inductively-defined operational semantics that can be used as a basis for verifying the correctness of analyses. ## External Reasoning Tools -Strata was designed to be used with external reasoning tools such as SMT solvers, CHC solvers, abstract interpretation engines, model checkers, and others. Currently, the VCG for the Boogie language based on partial evaluation along with an interface to SMT solvers (in [`Strata.DL.SMT`](../Strata/DL/SMT/)). +Strata was designed to be used with external reasoning tools such as SMT solvers, CHC solvers, abstract interpretation engines, model checkers, and others. Currently, the VCG for the Strata Core language based on partial evaluation along with an interface to SMT solvers (in [`Strata.DL.SMT`](../Strata/DL/SMT/)). ## Third-Party Dialects and Analyses diff --git a/docs/Datatypes.md b/docs/Datatypes.md index bb255f996..46d39af3a 100644 --- a/docs/Datatypes.md +++ b/docs/Datatypes.md @@ -1,13 +1,13 @@ # Datatypes in Strata -This document describes the datatype system in Strata.Boogie. +This document describes the datatype system in Strata Core. For DDM-specific documentation on datatype annotations and the function template system, see the [DDM Manual](verso/DDMDoc.lean) (Datatypes section). ## Overview Strata supports algebraic datatypes (ADTs) similar to those found in functional programming languages. Datatypes allow one to define custom types with multiple constructors, each of which can have zero or more fields (constructor arguments). -Example in Boogie/Strata Core syntax: +Example in Strata Core syntax: ```boogie datatype Option () { None(), @@ -17,7 +17,7 @@ datatype Option () { ## Datatype Declaration Syntax -### Boogie/Strata Core Dialect +### Strata Core Dialect Datatypes are declared using the `datatype` keyword: @@ -72,7 +72,7 @@ datatype Tree () { ## Generated Functions -When a datatype is declared, Strata.Boogie automatically generates several auxiliary functions: +When a datatype is declared, Strata Core automatically generates several auxiliary functions: ### Constructors @@ -117,7 +117,7 @@ Datatypes are encoded in SMT-LIB using the `declare-datatypes` command: )) ``` -The generated functions (constructors, testers, accessors) are +The generated functions (constructors, testers, accessors) are mapped to the generated SMT functions (e.g. `Option..isNone` is automatically mapped to `is-None`). @@ -129,9 +129,9 @@ injectivity of constructors. 1. The DDM does not yet support polymorphic functions, including datatype constructors. Polymorphism is supported at the AST level. -Example: `StrataTest/Languages/Boogie/DatatypeVerificationTests.lean` +Example: `StrataTest/Languages/Core/DatatypeVerificationTests.lean` 2. Strata also generates eliminators per data type, allowing -the definition of terms defined by pattern matching and/or +the definition of terms defined by pattern matching and/or recursion, with the correct computational behavior. This is also not yet available at the DDM level. Example: `StrataTest/DL/Lambda/TypeFactoryTests.lean` @@ -140,7 +140,7 @@ Example: `StrataTest/DL/Lambda/TypeFactoryTests.lean` See the following test files for working examples: -- `StrataTest/Languages/Boogie/Examples/DatatypeEnum.lean` - Simple enums -- `StrataTest/Languages/Boogie/Examples/DatatypeOption.lean` - Option type -- `StrataTest/Languages/Boogie/Examples/DatatypeList.lean` - Recursive lists -- `StrataTest/Languages/Boogie/Examples/DatatypeTree.lean` - Binary trees +- `StrataTest/Languages/Core/Examples/DatatypeEnum.lean` - Simple enums +- `StrataTest/Languages/Core/Examples/DatatypeOption.lean` - Option type +- `StrataTest/Languages/Core/Examples/DatatypeList.lean` - Recursive lists +- `StrataTest/Languages/Core/Examples/DatatypeTree.lean` - Binary trees diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index e4e5649d8..99cca3561 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -6,9 +6,9 @@ analyses. In this [example](../StrataTest/DL/Imperative), we show some of Strata's current capabilities by defining a simple Strata dialect called `ArithPrograms` and an associated deductive verifier based on the existing [Imperative](../Strata/DL/Imperative) -dialect in Strata's Dialect Library ([DL](../Strata/DL)). -`Imperative` provides basic commands and statements, is -parameterizable by expressions, and has a parameterizable partial +dialect in Strata's Dialect Library ([DL](../Strata/DL)). +`Imperative` provides basic commands and statements, is +parameterizable by expressions, and has a parameterizable partial evaluator that generates verification conditions. ### 1. Design the concrete syntax @@ -292,14 +292,14 @@ some next steps to explore: - **Study Existing Dialects**: Look at the implementation of the `Imperative` and `Lambda` dialects, and understand how they are used - as building blocks for the existing `Boogie` and `C_Simp` dialects. + as building blocks for the existing `Core` and `C_Simp` dialects. - **Add a New Dialect**: Create a new dialect that captures a language construct that you want to formalize and reason about. Perhaps you want to *transform* your new dialect into an existing Strata dialect to leverage any analysis available for the latter. You may also want to verify any such dialect transformations, i.e., prove that they - are semantics-preserving. One such example in Strata is for call + are semantics-preserving. One such example in Strata is for call eliminiation in Boogie, [here](../Strata/Transform/). - **Create a Language Frontend**: Develop a parser to translate the diff --git a/docs/verso/DDMDoc.lean b/docs/verso/DDMDoc.lean index 477cf933c..e7744491b 100644 --- a/docs/verso/DDMDoc.lean +++ b/docs/verso/DDMDoc.lean @@ -235,7 +235,7 @@ op assert (b : Bool) : Statement => "assert" b ";"; ``` For expressions, Strata supports polymorphic types. An example operator that uses -this is a polymorphic assignment operator in the Boogie statement dialect. +this is a polymorphic assignment operator in the Strata Core statement dialect. ``` op assign (tp : Type, v : Ident, e : tp) : Statement => v " := " e ";"; @@ -377,7 +377,7 @@ metadata declare(name : Ident, type : TypeOrCat); metadata nonempty; ``` -As an example, Boogie variable declaration syntax can be defined in Strata using the +As an example, Strata Core's variable declaration syntax can be defined in Strata using the following code: ``` @@ -444,7 +444,7 @@ be defined in user definable dialects. for special characters. * `Init.Num` represents numeric natural number literals. - + ## Datatypes %%% tag := "datatypes" @@ -461,12 +461,12 @@ constructors) _tester_ functions to identify to which constructor an instance be Dafny datatypes additionally produce an ordering relation, while Lean inductive types produce _eliminator_ instances defining induction principles. The DDM enables automatic creation of (a subset of) these auxiliary functions via a -configurable {deftech}_function template_ system. +configurable {deftech}_function template_ system. ### Example -In the Boogie dialect, the auxiliary functions are testers and accessors. That -is, one can define the following datatype in Strata.Boogie: +In the Strata Core dialect, the auxiliary functions are testers and accessors. That +is, one can define the following datatype in Strata Core: ``` datatype IntList { @@ -475,7 +475,7 @@ datatype IntList { }; ``` -This declares a list type with two constructors (`Nil` and `Cons`) and two fields (`head` and `tail`). The Boogie dialect automatically generates: +This declares a list type with two constructors (`Nil` and `Cons`) and two fields (`head` and `tail`). The Core dialect automatically generates: * Constructors: `Nil : IntList` and `Cons : int -> IntList -> IntList` * Testers: `IntList..isNil : IntList -> bool` and `IntList..isCons : IntList -> bool` @@ -484,7 +484,7 @@ This declares a list type with two constructors (`Nil` and `Cons`) and two field ### Defining Datatype Syntax in a Dialect To support datatypes in a dialect, you must define syntactic categories and -operators with appropriate annotations. The Boogie dialect provides a complete example. +operators with appropriate annotations. The Core dialect provides a complete example. #### Constructor Syntax @@ -517,7 +517,7 @@ arguments #### Datatype Command -The main datatype declaration uses `@[declareDatatype]` to tie everything together. It is best illustrated with an example (from the Boogie dialect): +The main datatype declaration uses `@[declareDatatype]` to tie everything together. It is best illustrated with an example (from the Core dialect): ``` @[declareDatatype(name, typeParams, constructors, @@ -532,7 +532,7 @@ op command_datatype (name : Ident, `@[declareDatatype]` declares a datatype command operator given the datatype name, the optional type parameters, the constructor list, and zero or more -[function templates](#datatypes-function-templates) to expand. Note that the `@[scopeDatatype]` +[function templates](#datatypes-function-templates) to expand. Note that the `@[scopeDatatype]` annotation brings the datatype name and type parameters into scope when parsing the constructors, enabling recursive type references. @@ -544,7 +544,7 @@ tag := "datatypes-function-templates" Function templates specify patterns for generating auxiliary functions from datatype declarations. Currently there are two supported templates: `perConstructor` generates one -function per constructor, while `perField` generates one function per field +function per constructor, while `perField` generates one function per field (note that the DDM enforces that fields are unique across all constructors in a datatype). @@ -575,7 +575,7 @@ Type references consist of the following components: ##### Example Templates -The Boogie dialect uses two templates: +The Strata Core dialect uses two templates: The tester template generates `IntList..isNil : IntList -> bool`: ``` From c68dfd4631ac40ca8437a1a0fe61a3ea15ac2844 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 13:26:24 -0600 Subject: [PATCH 02/19] Fix build failures, missing replacements of BoogieTransform --- Strata/Transform/CallElim.lean | 6 ++-- Strata/Transform/CallElimCorrect.lean | 2 +- Strata/Transform/CoreTransform.lean | 34 +++++++++---------- Strata/Transform/ProcedureInlining.lean | 12 +++---- StrataCoreToGoto.lean | 2 +- StrataMain.lean | 2 +- .../Backends/CBMC/SimpleAdd/mkGotoBin.sh | 2 +- StrataTest/Transform/CallElim.lean | 2 +- StrataTest/Transform/ProcedureInlining.lean | 2 +- lakefile.toml | 4 +-- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Strata/Transform/CallElim.lean b/Strata/Transform/CallElim.lean index 96748474f..eed92c6b3 100644 --- a/Strata/Transform/CallElim.lean +++ b/Strata/Transform/CallElim.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Transform.BoogieTransform +import Strata.Transform.CoreTransform /-! # Call Elimination Transformation -/ @@ -18,7 +18,7 @@ The main call elimination transformation algorithm on a single command. The returned result is a sequence of statements -/ def callElimCmd (cmd: Command) (p : Program) - : BoogieTransformM (List Statement) := do + : CoreTransformM (List Statement) := do match cmd with | .call lhs procName args _ => @@ -94,7 +94,7 @@ def callElimL (dcls : List Decl) (prog : Program) := /-- Call Elimination for an entire program by walking through all procedure bodies -/ -def callElim' (p : Program) : BoogieTransformM Program := +def callElim' (p : Program) : CoreTransformM Program := runProgram callElimCmd p end CallElim diff --git a/Strata/Transform/CallElimCorrect.lean b/Strata/Transform/CallElimCorrect.lean index c09748d9c..7ca2754af 100644 --- a/Strata/Transform/CallElimCorrect.lean +++ b/Strata/Transform/CallElimCorrect.lean @@ -12,7 +12,7 @@ import Strata.Languages.Boogie.Program import Strata.Languages.Boogie.ProgramType import Strata.Languages.Boogie.WF import Strata.DL.Lambda.Lambda -import Strata.Transform.BoogieTransform +import Strata.Transform.CoreTransform import Strata.Transform.CallElim import Strata.DL.Imperative.CmdSemantics import Strata.Languages.Boogie.StatementSemantics diff --git a/Strata/Transform/CoreTransform.lean b/Strata/Transform/CoreTransform.lean index eeb313356..90daf71fa 100644 --- a/Strata/Transform/CoreTransform.lean +++ b/Strata/Transform/CoreTransform.lean @@ -9,7 +9,7 @@ import Strata.Languages.Boogie.Boogie import Strata.Languages.Boogie.BoogieGen import Strata.DL.Util.LabelGen -/-! # Utility functions for program transformation in Boogie -/ +/-! # Utility functions for program transformation in Strata Core -/ namespace Boogie namespace Transform @@ -78,18 +78,18 @@ def isGlobalVar (p : Program) (ident : Expression.Ident) : Bool := abbrev Err := String -abbrev BoogieTransformM := ExceptT Err BoogieGenM +abbrev CoreTransformM := ExceptT Err BoogieGenM def getIdentTy? (p : Program) (id : Expression.Ident) := p.getVarTy? id def getIdentTy! (p : Program) (id : Expression.Ident) - : BoogieTransformM (Expression.Ty) := do + : CoreTransformM (Expression.Ty) := do match getIdentTy? p id with | none => throw s!"failed to find type for {Std.format id}" | some ty => return ty def getIdentTys! (p : Program) (ids : List Expression.Ident) - : BoogieTransformM (List Expression.Ty) := do + : CoreTransformM (List Expression.Ty) := do match ids with | [] => return [] | id :: rest => @@ -104,7 +104,7 @@ Only types of the 'inputs' parameter are used def genArgExprIdentsTrip (inputs : @Lambda.LTySignature Visibility) (args : List Expression.Expr) - : BoogieTransformM (List ((Expression.Ident × Lambda.LTy) × Expression.Expr)) + : CoreTransformM (List ((Expression.Ident × Lambda.LTy) × Expression.Expr)) := do if inputs.length ≠ args.length then throw "input length and args length mismatch" else let gen_idents ← genArgExprIdents args.length @@ -118,7 +118,7 @@ Only types of the 'outputs' parameter are used. def genOutExprIdentsTrip (outputs : @Lambda.LTySignature Visibility) (lhs : List Expression.Ident) - : BoogieTransformM (List ((Expression.Ident × Expression.Ty) × Expression.Ident)) := do + : CoreTransformM (List ((Expression.Ident × Expression.Ty) × Expression.Ident)) := do if outputs.length ≠ lhs.length then throw "output length and lhs length mismatch" else let gen_idents ← genOutExprIdents lhs return (gen_idents.zip outputs.unzip.2).zip lhs @@ -130,7 +130,7 @@ returned list has the shape def genOldExprIdentsTrip (p : Program) (ids : List Expression.Ident) - : BoogieTransformM (List ((Expression.Ident × Expression.Ty) × Expression.Ident)) := do + : CoreTransformM (List ((Expression.Ident × Expression.Ty) × Expression.Ident)) := do let gen_idents ← genOldExprIdents ids let tys ← getIdentTys! p ids return (gen_idents.zip tys).zip ids @@ -190,9 +190,9 @@ def createOldVarsSubst /- Generic runner functions -/ -- Only visit top-level statements and run f -def runStmts (f : Command → Program → BoogieTransformM (List Statement)) +def runStmts (f : Command → Program → CoreTransformM (List Statement)) (ss : List Statement) (inputProg : Program) - : BoogieTransformM (List Statement) := do + : CoreTransformM (List Statement) := do match ss with | [] => return [] | s :: ss => @@ -203,9 +203,9 @@ def runStmts (f : Command → Program → BoogieTransformM (List Statement)) return (← s') ++ (← ss') -- Recursively visit all blocks and run f -def runStmtsRec (f : Command → Program → BoogieTransformM (List Statement)) +def runStmtsRec (f : Command → Program → CoreTransformM (List Statement)) (ss : List Statement) (inputProg : Program) - : BoogieTransformM (List Statement) := do + : CoreTransformM (List Statement) := do match ss with | [] => return [] | s :: ss' => @@ -231,9 +231,9 @@ termination_by sizeOf ss decreasing_by all_goals (unfold Imperative.instSizeOfBlock; decreasing_tactic) -def runProcedures (f : Command → Program → BoogieTransformM (List Statement)) +def runProcedures (f : Command → Program → CoreTransformM (List Statement)) (dcls : List Decl) (inputProg : Program) - : BoogieTransformM (List Decl) := do + : CoreTransformM (List Decl) := do match dcls with | [] => return [] | d :: ds => @@ -244,20 +244,20 @@ def runProcedures (f : Command → Program → BoogieTransformM (List Statement) } md :: (← (runProcedures f ds inputProg)) | _ => return d :: (← (runProcedures f ds inputProg)) -def runProgram (f : Command → Program → BoogieTransformM (List Statement)) - (p : Program) : BoogieTransformM Program := do +def runProgram (f : Command → Program → CoreTransformM (List Statement)) + (p : Program) : CoreTransformM Program := do let newDecls ← runProcedures f p.decls p return { decls := newDecls } @[simp] -def runWith {α : Type} (p : α) (f : α → BoogieTransformM β) +def runWith {α : Type} (p : α) (f : α → CoreTransformM β) (s : BoogieGenState): Except Err β × BoogieGenState := (StateT.run (f p) s) @[simp] -def run {α : Type} (p : α) (f : α → BoogieTransformM β) +def run {α : Type} (p : α) (f : α → CoreTransformM β) (s : BoogieGenState := .emp): Except Err β := (runWith p f s).fst diff --git a/Strata/Transform/ProcedureInlining.lean b/Strata/Transform/ProcedureInlining.lean index 0c6abe73a..dcf9a8236 100644 --- a/Strata/Transform/ProcedureInlining.lean +++ b/Strata/Transform/ProcedureInlining.lean @@ -10,7 +10,7 @@ import Strata.Languages.Boogie.Boogie import Strata.Languages.Boogie.BoogieGen import Strata.Languages.Boogie.ProgramWF import Strata.Languages.Boogie.Statement -import Strata.Transform.BoogieTransform +import Strata.Transform.CoreTransform /-! # Procedure Inlining Transformation -/ @@ -135,7 +135,7 @@ end private def genOldToFreshIdMappings (old_vars : List Expression.Ident) (prev_map : Map Expression.Ident Expression.Ident) (prefix_ : String) - : BoogieTransformM (Map Expression.Ident Expression.Ident) := do + : CoreTransformM (Map Expression.Ident Expression.Ident) := do let prev_map <- old_vars.foldlM (fun var_map id => do let new_name <- genIdent id (fun s => prefix_ ++ "_" ++ s) @@ -144,7 +144,7 @@ private def genOldToFreshIdMappings (old_vars : List Expression.Ident) return prev_map private def renameAllLocalNames (c:Procedure) - : BoogieTransformM (Procedure × Map Expression.Ident Expression.Ident) := do + : CoreTransformM (Procedure × Map Expression.Ident Expression.Ident) := do let var_map: Map Expression.Ident Expression.Ident := [] let proc_name := c.header.name.name @@ -194,7 +194,7 @@ the reachability query. -/ def inlineCallCmd (excluded_calls:List String := []) (cmd: Command) (p : Program) - : BoogieTransformM (List Statement) := + : CoreTransformM (List Statement) := open Lambda in do match cmd with | .call lhs procName args _ => @@ -257,11 +257,11 @@ def inlineCallCmd (excluded_calls:List String := []) | _ => return [.cmd cmd] def inlineCallStmtsRec (ss: List Statement) (prog : Program) - : BoogieTransformM (List Statement) := + : CoreTransformM (List Statement) := runStmtsRec inlineCallCmd ss prog def inlineCallL (dcls : List Decl) (prog : Program) - : BoogieTransformM (List Decl) := + : CoreTransformM (List Decl) := runProcedures inlineCallCmd dcls prog end ProcedureInlining diff --git a/StrataCoreToGoto.lean b/StrataCoreToGoto.lean index 49a7f3a66..dab8c7f16 100644 --- a/StrataCoreToGoto.lean +++ b/StrataCoreToGoto.lean @@ -15,4 +15,4 @@ def main (args : List String) : IO Unit := do (gotoFileName := "StrataTest/Backends/CBMC/SimpleAdd/simpleAdd.goto.json") Strata.simpleAdd IO.println "Written JSON files in StrataTest/Backends/CBMC/SimpleAdd/" - | _ => IO.println "Bad usage of BoogieToGoto" + | _ => IO.println "Bad usage of StrataCoreToGoto" diff --git a/StrataMain.lean b/StrataMain.lean index f6c85a2a5..453e25c47 100644 --- a/StrataMain.lean +++ b/StrataMain.lean @@ -11,7 +11,7 @@ import Strata.Util.IO import Strata.DDM.Integration.Java.Gen import Strata.Languages.Python.Python -import Strata.Transform.BoogieTransform +import Strata.Transform.CoreTransform import Strata.Transform.ProcedureInlining def exitFailure {α} (message : String) : IO α := do diff --git a/StrataTest/Backends/CBMC/SimpleAdd/mkGotoBin.sh b/StrataTest/Backends/CBMC/SimpleAdd/mkGotoBin.sh index c1d6553c7..ae2709533 100755 --- a/StrataTest/Backends/CBMC/SimpleAdd/mkGotoBin.sh +++ b/StrataTest/Backends/CBMC/SimpleAdd/mkGotoBin.sh @@ -6,7 +6,7 @@ rm -f *.gb echo "Writing out JSON files from a Strata.Boogie program SimpleAdd" pushd ../../../../ -lake exe BoogieToGoto writeFiles +lake exe StrataCoreToGoto writeFiles popd # Merge generated file ../simpleAdd.symtab.json with diff --git a/StrataTest/Transform/CallElim.lean b/StrataTest/Transform/CallElim.lean index 8fe5d5cdb..9e4bd746d 100644 --- a/StrataTest/Transform/CallElim.lean +++ b/StrataTest/Transform/CallElim.lean @@ -11,7 +11,7 @@ import Strata.Languages.Boogie.DDMTransform.Translate import Strata.Languages.Boogie.ProgramType import Strata.Languages.Boogie.ProgramWF import Strata.Languages.Boogie.StatementSemantics -import Strata.Transform.BoogieTransform +import Strata.Transform.CoreTransform import Strata.Transform.CallElim diff --git a/StrataTest/Transform/ProcedureInlining.lean b/StrataTest/Transform/ProcedureInlining.lean index 85d332902..4eaeefaef 100644 --- a/StrataTest/Transform/ProcedureInlining.lean +++ b/StrataTest/Transform/ProcedureInlining.lean @@ -11,7 +11,7 @@ import Strata.Languages.Boogie.DDMTransform.Translate import Strata.Languages.Boogie.StatementSemantics import Strata.Languages.Boogie.ProgramType import Strata.Languages.Boogie.ProgramWF -import Strata.Transform.BoogieTransform +import Strata.Transform.CoreTransform import Strata.Transform.ProcedureInlining open Boogie diff --git a/lakefile.toml b/lakefile.toml index f70d9e7dc..ec73eb3d1 100644 --- a/lakefile.toml +++ b/lakefile.toml @@ -1,6 +1,6 @@ name = "Strata" version = "0.1.0" -defaultTargets = ["Strata", "strata", "StrataMain", "StrataVerify", "StrataToCBMC", "BoogieToGoto"] +defaultTargets = ["Strata", "strata", "StrataMain", "StrataVerify", "StrataToCBMC", "StrataCoreToGoto"] testDriver = "StrataTest" [leanOptions] @@ -33,4 +33,4 @@ name = "StrataVerify" name = "StrataToCBMC" [[lean_exe]] -name = "BoogieToGoto" +name = "StrataCoreToGoto" From 62c71d4e1bc0fbdd4bf0b52c7413efd5846cdedf Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 13:30:53 -0600 Subject: [PATCH 03/19] Rename 'program Boogie' to 'program Core' --- Examples/HeapReasoning.core.st | 16 +++++++-------- Examples/LoopSimple.core.st | 2 +- Examples/SimpleProc.core.st | 2 +- Examples/TypeError.core.st | 2 +- Strata/Backends/CBMC/BoogieToCBMC.lean | 2 +- Strata/Backends/CBMC/tests/simpleTest.core.st | 2 +- .../Languages/Boogie/DDMTransform/Parse.lean | 12 +++++------ Strata/Languages/Python/BoogiePrelude.lean | 2 +- .../Backends/CBMC/SimpleAdd/SimpleAdd.lean | 2 +- .../Boogie/Examples/AdvancedMaps.lean | 2 +- .../Boogie/Examples/AdvancedQuantifiers.lean | 2 +- .../Examples/AssertionDefaultNames.lean | 2 +- .../Languages/Boogie/Examples/Axioms.lean | 4 ++-- .../Boogie/Examples/BitVecParse.lean | 2 +- .../Languages/Boogie/Examples/Cover.lean | 4 ++-- .../Boogie/Examples/DDMAxiomsExtraction.lean | 4 ++-- .../Boogie/Examples/DDMTransform.lean | 2 +- .../Boogie/Examples/DatatypeEnum.lean | 6 +++--- .../Boogie/Examples/DatatypeList.lean | 20 +++++++++---------- .../Boogie/Examples/DatatypeOption.lean | 14 ++++++------- .../Boogie/Examples/DatatypeTree.lean | 20 +++++++++---------- .../Boogie/Examples/FailingAssertion.lean | 4 ++-- .../Boogie/Examples/FreeRequireEnsure.lean | 2 +- .../Languages/Boogie/Examples/Functions.lean | 2 +- .../Boogie/Examples/GeneratedLabels.lean | 2 +- .../Languages/Boogie/Examples/Goto.lean | 2 +- .../Languages/Boogie/Examples/Havoc.lean | 2 +- .../Languages/Boogie/Examples/Loops.lean | 4 ++-- StrataTest/Languages/Boogie/Examples/Map.lean | 2 +- StrataTest/Languages/Boogie/Examples/Min.lean | 2 +- .../Boogie/Examples/OldExpressions.lean | 2 +- .../Boogie/Examples/PrecedenceCheck.lean | 2 +- .../Boogie/Examples/ProcedureCall.lean | 2 +- .../Boogie/Examples/Quantifiers.lean | 4 ++-- .../Examples/QuantifiersWithTypeAliases.lean | 2 +- .../Boogie/Examples/RealBitVector.lean | 6 +++--- .../Boogie/Examples/RecursiveProcIte.lean | 2 +- .../Languages/Boogie/Examples/Regex.lean | 6 +++--- .../Examples/RemoveIrrelevantAxioms.lean | 2 +- .../Languages/Boogie/Examples/SimpleProc.lean | 2 +- .../Languages/Boogie/Examples/String.lean | 2 +- .../Languages/Boogie/Examples/TypeAlias.lean | 6 +++--- .../Languages/Boogie/Examples/TypeDecl.lean | 8 ++++---- .../Examples/TypeVarImplicitlyQuantified.lean | 2 +- .../Boogie/Examples/UnreachableAssert.lean | 2 +- StrataTest/Transform/CallElim.lean | 12 +++++------ StrataTest/Transform/ProcedureInlining.lean | 12 +++++------ StrataToCBMC.lean | 2 +- StrataVerify.lean | 2 +- .../BoogieToStrata/Source/StrataGenerator.cs | 2 +- 50 files changed, 113 insertions(+), 113 deletions(-) diff --git a/Examples/HeapReasoning.core.st b/Examples/HeapReasoning.core.st index 95ccf814b..211eb4b9f 100644 --- a/Examples/HeapReasoning.core.st +++ b/Examples/HeapReasoning.core.st @@ -1,5 +1,5 @@ -program Boogie; -// lake exe StrataVerify Strata/Languages/Boogie/Examples/HeapReasoning.boogie.st +program Core; +// lake exe StrataVerify Strata/Languages/Boogie/Examples/HeapReasoning.boogie.st // Prelude begin -------------------------------------------------- type Ref; @@ -76,8 +76,8 @@ spec { requires allocationTime(initialNext) < tickingClock; requires isContainer(r); - free ensures (forall o: Ref :: - { newHeap[o] } + free ensures (forall o: Ref :: + { newHeap[o] } (o != null && allocationTime(o) >= 0 && allocationTime(o) < old(tickingClock)) ==> (newHeap[o] == heap[o] || o == r)); @@ -132,8 +132,8 @@ spec { ensures tickingClock >= old(tickingClock); - free ensures (forall o: Ref :: - { newHeap[o] } + free ensures (forall o: Ref :: + { newHeap[o] } (o != null && allocationTime(o) >= 0 && allocationTime(o) < old(tickingClock)) ==> (newHeap[o] == heap[o] || o == ref1)); @@ -197,8 +197,8 @@ spec { free requires tickingClock >= 0; ensures tickingClock >= old(tickingClock); - free ensures (forall o: Ref :: - { newHeap[o] } + free ensures (forall o: Ref :: + { newHeap[o] } (o != null && allocationTime(o) >= 0 && allocationTime(o) < old(tickingClock)) ==> (newHeap[o] == heap[o])); } diff --git a/Examples/LoopSimple.core.st b/Examples/LoopSimple.core.st index 835a77a6d..139c3573a 100644 --- a/Examples/LoopSimple.core.st +++ b/Examples/LoopSimple.core.st @@ -1,4 +1,4 @@ -program Boogie; +program Core; procedure loopSimple (n: int) returns (r: int) spec { diff --git a/Examples/SimpleProc.core.st b/Examples/SimpleProc.core.st index 8c909fe95..4adbad260 100644 --- a/Examples/SimpleProc.core.st +++ b/Examples/SimpleProc.core.st @@ -1,4 +1,4 @@ -program Boogie; +program Core; // // Copyright Strata Contributors // diff --git a/Examples/TypeError.core.st b/Examples/TypeError.core.st index 386db3dd4..c52319fd5 100644 --- a/Examples/TypeError.core.st +++ b/Examples/TypeError.core.st @@ -1,4 +1,4 @@ -program Boogie; +program Core; // // Copyright Strata Contributors // diff --git a/Strata/Backends/CBMC/BoogieToCBMC.lean b/Strata/Backends/CBMC/BoogieToCBMC.lean index a1071601f..b249d592f 100644 --- a/Strata/Backends/CBMC/BoogieToCBMC.lean +++ b/Strata/Backends/CBMC/BoogieToCBMC.lean @@ -19,7 +19,7 @@ namespace Boogie -- Our test program def SimpleTestEnv := #strata -program Boogie; +program Core; procedure simpleTest(x : int, y : int) returns (ret : int) spec { diff --git a/Strata/Backends/CBMC/tests/simpleTest.core.st b/Strata/Backends/CBMC/tests/simpleTest.core.st index aababdd68..a8ef4ab62 100644 --- a/Strata/Backends/CBMC/tests/simpleTest.core.st +++ b/Strata/Backends/CBMC/tests/simpleTest.core.st @@ -1,4 +1,4 @@ -program Boogie; +program Core; procedure simpleTest(x : int, y : int) returns (ret : int) spec { diff --git a/Strata/Languages/Boogie/DDMTransform/Parse.lean b/Strata/Languages/Boogie/DDMTransform/Parse.lean index d4e8494ea..e21eb2a71 100644 --- a/Strata/Languages/Boogie/DDMTransform/Parse.lean +++ b/Strata/Languages/Boogie/DDMTransform/Parse.lean @@ -15,12 +15,12 @@ namespace Strata --------------------------------------------------------------------- --------------------------------------------------------------------- -/- DDM support for parsing and pretty-printing Boogie -/ +/- DDM support for parsing and pretty-printing Strata Core -/ #dialect -dialect Boogie; +dialect Core; -// Declare Boogie-specific metadata for datatype declarations +// Declare Strata Core-specific metadata for datatype declarations metadata declareDatatype (name : Ident, typeParams : Ident, constructors : Ident, testerTemplate : FunctionTemplate, accessorTemplate : FunctionTemplate); @@ -244,7 +244,7 @@ op command_procedure (name : Ident, // type Array a; // instead of // type Array (a : Type); -// where the former is what's needed for Boogie. +// where the former is what Boogie does. @[declareType(name, some args)] op command_typedecl (name : Ident, args : Option Bindings) : Command => "type " name args ";\n"; @@ -325,11 +325,11 @@ op command_datatype (name : Ident, #end -namespace BoogieDDM +namespace CoreDDM --#strata_gen Boogie -end BoogieDDM +end CoreDDM --------------------------------------------------------------------- diff --git a/Strata/Languages/Python/BoogiePrelude.lean b/Strata/Languages/Python/BoogiePrelude.lean index 7eb7cd3dc..559627551 100644 --- a/Strata/Languages/Python/BoogiePrelude.lean +++ b/Strata/Languages/Python/BoogiePrelude.lean @@ -13,7 +13,7 @@ namespace Strata def boogiePrelude := #strata -program Boogie; +program Core; datatype None () { None_none() diff --git a/StrataTest/Backends/CBMC/SimpleAdd/SimpleAdd.lean b/StrataTest/Backends/CBMC/SimpleAdd/SimpleAdd.lean index 08d460ddf..22409e6cb 100644 --- a/StrataTest/Backends/CBMC/SimpleAdd/SimpleAdd.lean +++ b/StrataTest/Backends/CBMC/SimpleAdd/SimpleAdd.lean @@ -13,7 +13,7 @@ namespace Strata protected def simpleAdd : Program := #strata -program Boogie; +program Core; procedure simpleAdd (x : bv32, y : bv32) returns () { assume (x < bv{32}(0xFFFF0000)); diff --git a/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean b/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean index 09773e6ed..6b848a7b0 100644 --- a/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean +++ b/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean @@ -12,7 +12,7 @@ open Strata private def mapPgm := #strata -program Boogie; +program Core; type MapII := Map int int; type MapIMapII := Map int MapII; diff --git a/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean b/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean index 0ade81810..648523d18 100644 --- a/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean +++ b/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean @@ -11,7 +11,7 @@ namespace Strata def advQuantPgm := #strata -program Boogie; +program Core; axiom [mapAllValues0]: forall m: (Map int int), k: int :: m[k] == 0; procedure Update(mArg: Map int int, kArg: int) returns (res: int) spec { diff --git a/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean b/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean index 6f2601738..149edadc8 100644 --- a/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean +++ b/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean @@ -11,7 +11,7 @@ namespace Strata def assertionNames := #strata -program Boogie; +program Core; procedure Test(x : int) returns () spec { requires x == 1; diff --git a/StrataTest/Languages/Boogie/Examples/Axioms.lean b/StrataTest/Languages/Boogie/Examples/Axioms.lean index 165d8fcb2..86c11367c 100644 --- a/StrataTest/Languages/Boogie/Examples/Axioms.lean +++ b/StrataTest/Languages/Boogie/Examples/Axioms.lean @@ -13,7 +13,7 @@ namespace Strata def axiomPgm1 := #strata -program Boogie; +program Core; const x : int; axiom [a1]: x == 5; @@ -111,7 +111,7 @@ Result: ✅ pass def axiomPgm2 := #strata -program Boogie; +program Core; function f(x : int) : int; function g(x : int) : int; diff --git a/StrataTest/Languages/Boogie/Examples/BitVecParse.lean b/StrataTest/Languages/Boogie/Examples/BitVecParse.lean index b3184492b..467cd7f87 100644 --- a/StrataTest/Languages/Boogie/Examples/BitVecParse.lean +++ b/StrataTest/Languages/Boogie/Examples/BitVecParse.lean @@ -11,7 +11,7 @@ namespace Strata private def pgm : Program := #strata -program Boogie; +program Core; procedure bitVecParseTest() returns () { diff --git a/StrataTest/Languages/Boogie/Examples/Cover.lean b/StrataTest/Languages/Boogie/Examples/Cover.lean index 33beafe42..f8192d358 100644 --- a/StrataTest/Languages/Boogie/Examples/Cover.lean +++ b/StrataTest/Languages/Boogie/Examples/Cover.lean @@ -11,7 +11,7 @@ namespace Strata def coverPgm1 := #strata -program Boogie; +program Core; procedure Test() returns () { var x : int; @@ -65,7 +65,7 @@ Result: ✅ pass def coverPgm2 := #strata -program Boogie; +program Core; procedure Test(x : int) returns () spec { requires x > 1; diff --git a/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean b/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean index f94a90621..e448ed2ce 100644 --- a/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean +++ b/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean @@ -13,7 +13,7 @@ namespace Strata -- Example Boogie program with axioms def examplePgm := #strata -program Boogie; +program Core; type k; type v; axiom [updateSelect]: forall m: Map k v, kk: k, vv: v :: m[kk := vv][kk] == vv; @@ -84,7 +84,7 @@ def extractAxiomsWithFreeTypeVars (pgm: Program) (typeArgs: List String): (List axioms.map (fun a => replaceTypesByFTV a typeArgs) /-- -info: program Boogie; +info: program Core; type k; type v; axiom [updateSelect]:forall(((m):(Map v k)),((kk):(k))),((vv):(v))::((m)[kk:=vv])[kk]==vv; diff --git a/StrataTest/Languages/Boogie/Examples/DDMTransform.lean b/StrataTest/Languages/Boogie/Examples/DDMTransform.lean index c29ed7fc8..11fb72a7d 100644 --- a/StrataTest/Languages/Boogie/Examples/DDMTransform.lean +++ b/StrataTest/Languages/Boogie/Examples/DDMTransform.lean @@ -12,7 +12,7 @@ set_option maxRecDepth 10000 def msPgm : Program := #strata -program Boogie; +program Core; // Running example from Mutual Summaries paper // // int g; diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeEnum.lean b/StrataTest/Languages/Boogie/Examples/DatatypeEnum.lean index c437521e8..f17055baf 100644 --- a/StrataTest/Languages/Boogie/Examples/DatatypeEnum.lean +++ b/StrataTest/Languages/Boogie/Examples/DatatypeEnum.lean @@ -24,7 +24,7 @@ namespace Strata.DatatypeEnumTest def enumPgm : Program := #strata -program Boogie; +program Core; // Define an enum-style datatype with no fields datatype Color () { Red(), Green(), Blue() }; @@ -79,7 +79,7 @@ Result: ✅ pass def enumHavocPgm : Program := #strata -program Boogie; +program Core; datatype Color () { Red(), Green(), Blue() }; @@ -132,7 +132,7 @@ Result: ✅ pass def enumExhaustivePgm : Program := #strata -program Boogie; +program Core; datatype Color () { Red(), Green(), Blue() }; diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeList.lean b/StrataTest/Languages/Boogie/Examples/DatatypeList.lean index e734362de..4f2db3ded 100644 --- a/StrataTest/Languages/Boogie/Examples/DatatypeList.lean +++ b/StrataTest/Languages/Boogie/Examples/DatatypeList.lean @@ -26,7 +26,7 @@ namespace Strata.DatatypeListTest def listTesterPgm : Program := #strata -program Boogie; +program Core; // Define List datatype with Nil() and Cons(head: int, tail: List) constructors // Note: This is a recursive datatype - tail has type List @@ -95,7 +95,7 @@ Result: ✅ pass def listHavocPgm : Program := #strata -program Boogie; +program Core; datatype List () { Nil(), Cons(head: int, tail: List) }; @@ -141,7 +141,7 @@ Result: ✅ pass def listExhaustivePgm : Program := #strata -program Boogie; +program Core; datatype List () { Nil(), Cons(head: int, tail: List) }; @@ -184,7 +184,7 @@ Result: ✅ pass def listMutualExclusionPgm : Program := #strata -program Boogie; +program Core; datatype List () { Nil(), Cons(head: int, tail: List) }; @@ -230,7 +230,7 @@ Result: ✅ pass def listEqualityPgm : Program := #strata -program Boogie; +program Core; datatype List () { Nil(), Cons(head: int, tail: List) }; @@ -285,7 +285,7 @@ Result: ✅ pass def listInequalityPgm : Program := #strata -program Boogie; +program Core; datatype List () { Nil(), Cons(head: int, tail: List) }; @@ -329,7 +329,7 @@ Result: ✅ pass def listDestructorPgm : Program := #strata -program Boogie; +program Core; datatype List () { Nil(), Cons(head: int, tail: List) }; @@ -402,7 +402,7 @@ Result: ✅ pass def listNestedPgm : Program := #strata -program Boogie; +program Core; datatype List () { Nil(), Cons(head: int, tail: List) }; @@ -448,7 +448,7 @@ Result: ✅ pass def listDestructorHavocPgm : Program := #strata -program Boogie; +program Core; datatype List () { Nil(), Cons(head: int, tail: List) }; @@ -498,7 +498,7 @@ Result: ✅ pass def listDifferentValuesPgm : Program := #strata -program Boogie; +program Core; datatype List () { Nil(), Cons(head: int, tail: List) }; diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeOption.lean b/StrataTest/Languages/Boogie/Examples/DatatypeOption.lean index 62b72b188..c9ae8c4e3 100644 --- a/StrataTest/Languages/Boogie/Examples/DatatypeOption.lean +++ b/StrataTest/Languages/Boogie/Examples/DatatypeOption.lean @@ -25,7 +25,7 @@ namespace Strata.DatatypeOptionTest def optionTesterPgm : Program := #strata -program Boogie; +program Core; // Define Option datatype with None() and Some(val: int) constructors datatype Option () { None(), Some(val: int) }; @@ -93,7 +93,7 @@ Result: ✅ pass def optionHavocPgm : Program := #strata -program Boogie; +program Core; datatype Option () { None(), Some(val: int) }; @@ -139,7 +139,7 @@ Result: ✅ pass def optionExhaustivePgm : Program := #strata -program Boogie; +program Core; datatype Option () { None(), Some(val: int) }; @@ -182,7 +182,7 @@ Result: ✅ pass def optionMutualExclusionPgm : Program := #strata -program Boogie; +program Core; datatype Option () { None(), Some(val: int) }; @@ -228,7 +228,7 @@ Result: ✅ pass def optionEqualityPgm : Program := #strata -program Boogie; +program Core; datatype Option () { None(), Some(val: int) }; @@ -283,7 +283,7 @@ Result: ✅ pass def optionInequalityPgm : Program := #strata -program Boogie; +program Core; datatype Option () { None(), Some(val: int) }; @@ -327,7 +327,7 @@ Result: ✅ pass def optionDestructorPgm : Program := #strata -program Boogie; +program Core; datatype Option () { None(), Some(val: int) }; diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeTree.lean b/StrataTest/Languages/Boogie/Examples/DatatypeTree.lean index d2296073d..8f83eaff5 100644 --- a/StrataTest/Languages/Boogie/Examples/DatatypeTree.lean +++ b/StrataTest/Languages/Boogie/Examples/DatatypeTree.lean @@ -25,7 +25,7 @@ namespace Strata.DatatypeTreeTest def treeTesterPgm : Program := #strata -program Boogie; +program Core; // Define Tree datatype with Leaf(val: int) and Node(left: Tree, right: Tree) constructors datatype Tree () { Leaf(val: int), Node(left: Tree, right: Tree) }; @@ -93,7 +93,7 @@ Result: ✅ pass def treeHavocPgm : Program := #strata -program Boogie; +program Core; datatype Tree () { Leaf(val: int), Node(left: Tree, right: Tree) }; @@ -139,7 +139,7 @@ Result: ✅ pass def treeExhaustivePgm : Program := #strata -program Boogie; +program Core; datatype Tree () { Leaf(val: int), Node(left: Tree, right: Tree) }; @@ -182,7 +182,7 @@ Result: ✅ pass def treeMutualExclusionPgm : Program := #strata -program Boogie; +program Core; datatype Tree () { Leaf(val: int), Node(left: Tree, right: Tree) }; @@ -228,7 +228,7 @@ Result: ✅ pass def treeEqualityPgm : Program := #strata -program Boogie; +program Core; datatype Tree () { Leaf(val: int), Node(left: Tree, right: Tree) }; @@ -283,7 +283,7 @@ Result: ✅ pass def treeInequalityPgm : Program := #strata -program Boogie; +program Core; datatype Tree () { Leaf(val: int), Node(left: Tree, right: Tree) }; @@ -327,7 +327,7 @@ Result: ✅ pass def treeDestructorPgm : Program := #strata -program Boogie; +program Core; datatype Tree () { Leaf(val: int), Node(left: Tree, right: Tree) }; @@ -408,7 +408,7 @@ Result: ✅ pass def treeNestedPgm : Program := #strata -program Boogie; +program Core; datatype Tree () { Leaf(val: int), Node(left: Tree, right: Tree) }; @@ -470,7 +470,7 @@ Result: ✅ pass def treeDestructorHavocPgm : Program := #strata -program Boogie; +program Core; datatype Tree () { Leaf(val: int), Node(left: Tree, right: Tree) }; @@ -520,7 +520,7 @@ Result: ✅ pass def treeDifferentValuesPgm : Program := #strata -program Boogie; +program Core; datatype Tree () { Leaf(val: int), Node(left: Tree, right: Tree) }; diff --git a/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean b/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean index 163e7815f..93bdfe212 100644 --- a/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean +++ b/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean @@ -12,7 +12,7 @@ open Strata private def failing := #strata -program Boogie; +program Core; type MapII := Map int int; @@ -92,7 +92,7 @@ Result: ❌ fail private def failingThrice := #strata -program Boogie; +program Core; procedure P(x : int) returns () spec { diff --git a/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean b/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean index 4fdab9aed..a9918f8c7 100644 --- a/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean +++ b/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean @@ -11,7 +11,7 @@ namespace Strata def freeReqEnsPgm : Program := #strata -program Boogie; +program Core; var g : int; procedure Proc() returns () spec { diff --git a/StrataTest/Languages/Boogie/Examples/Functions.lean b/StrataTest/Languages/Boogie/Examples/Functions.lean index ef156b190..e08c743d1 100644 --- a/StrataTest/Languages/Boogie/Examples/Functions.lean +++ b/StrataTest/Languages/Boogie/Examples/Functions.lean @@ -12,7 +12,7 @@ namespace Strata def funcPgm : Program := #strata -program Boogie; +program Core; const fooConst : int; inline function fooTest() : int { fooConst } diff --git a/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean b/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean index 3e3fffb1f..425687526 100644 --- a/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean +++ b/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean @@ -11,7 +11,7 @@ namespace Strata def genLabelsPgm : Program := #strata -program Boogie; +program Core; type Ref; type Field; diff --git a/StrataTest/Languages/Boogie/Examples/Goto.lean b/StrataTest/Languages/Boogie/Examples/Goto.lean index 0f146227a..962a00af7 100644 --- a/StrataTest/Languages/Boogie/Examples/Goto.lean +++ b/StrataTest/Languages/Boogie/Examples/Goto.lean @@ -12,7 +12,7 @@ namespace Strata def gotoPgm : Program := #strata -program Boogie; +program Core; var g : bool; procedure Test1(x : bool) returns (y : bool) { diff --git a/StrataTest/Languages/Boogie/Examples/Havoc.lean b/StrataTest/Languages/Boogie/Examples/Havoc.lean index 12d693e92..7fc609aa5 100644 --- a/StrataTest/Languages/Boogie/Examples/Havoc.lean +++ b/StrataTest/Languages/Boogie/Examples/Havoc.lean @@ -11,7 +11,7 @@ namespace Strata def havocPgm : Program := #strata -program Boogie; +program Core; procedure S() returns () { var x : int; diff --git a/StrataTest/Languages/Boogie/Examples/Loops.lean b/StrataTest/Languages/Boogie/Examples/Loops.lean index ac40121c6..df816c5e9 100644 --- a/StrataTest/Languages/Boogie/Examples/Loops.lean +++ b/StrataTest/Languages/Boogie/Examples/Loops.lean @@ -11,7 +11,7 @@ namespace Strata def gaussPgm := #strata -program Boogie; +program Core; procedure sum(n : int) returns (s : int) spec { @@ -88,7 +88,7 @@ Result: ✅ pass def nestedPgm := #strata -program Boogie; +program Core; const top : int; axiom [top100]: top == 100; diff --git a/StrataTest/Languages/Boogie/Examples/Map.lean b/StrataTest/Languages/Boogie/Examples/Map.lean index 85f252845..3854acd8c 100644 --- a/StrataTest/Languages/Boogie/Examples/Map.lean +++ b/StrataTest/Languages/Boogie/Examples/Map.lean @@ -11,7 +11,7 @@ open Strata --------------------------------------------------------------------- private def mapPgm := #strata -program Boogie; +program Core; const a : Map int bool; diff --git a/StrataTest/Languages/Boogie/Examples/Min.lean b/StrataTest/Languages/Boogie/Examples/Min.lean index 0404de5fd..cdc9d5433 100644 --- a/StrataTest/Languages/Boogie/Examples/Min.lean +++ b/StrataTest/Languages/Boogie/Examples/Min.lean @@ -11,7 +11,7 @@ namespace Strata private def testPgm : Program := #strata -program Boogie; +program Core; procedure min(n : int, m : int) returns (k : int) spec { diff --git a/StrataTest/Languages/Boogie/Examples/OldExpressions.lean b/StrataTest/Languages/Boogie/Examples/OldExpressions.lean index 9a5e65ff3..40fb79623 100644 --- a/StrataTest/Languages/Boogie/Examples/OldExpressions.lean +++ b/StrataTest/Languages/Boogie/Examples/OldExpressions.lean @@ -11,7 +11,7 @@ namespace Strata def oldExprPgm : Program := #strata -program Boogie; +program Core; var g : bool; var g2 : bool; diff --git a/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean b/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean index df028bbd0..608e61418 100644 --- a/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean +++ b/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean @@ -11,7 +11,7 @@ namespace Strata def precPgm : Program := #strata -program Boogie; +program Core; function foo(a : bool, b : bool, c : bool, d : bool) : bool { (((!a) || b) && ((!c) || d)) diff --git a/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean b/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean index e3fff34a0..98f74663d 100644 --- a/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean +++ b/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean @@ -12,7 +12,7 @@ namespace Strata def globalCounterPgm : Program := #strata -program Boogie; +program Core; var counter : int; diff --git a/StrataTest/Languages/Boogie/Examples/Quantifiers.lean b/StrataTest/Languages/Boogie/Examples/Quantifiers.lean index 45e796f9d..c486096f7 100644 --- a/StrataTest/Languages/Boogie/Examples/Quantifiers.lean +++ b/StrataTest/Languages/Boogie/Examples/Quantifiers.lean @@ -11,7 +11,7 @@ namespace Strata def quantPgm := #strata -program Boogie; +program Core; procedure Test(x : int) returns (r : int) spec { ensures [good]: (forall y : int :: exists z : int :: r + (z + y) == y + (z + r)); @@ -25,7 +25,7 @@ spec { def triggerPgm := #strata -program Boogie; +program Core; function f(x : int): int; function g(x : int, y : int): int; diff --git a/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean b/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean index 6aac47fbb..8016a38d8 100644 --- a/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean +++ b/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean @@ -11,7 +11,7 @@ namespace Strata def QuantTypeAliases := #strata -program Boogie; +program Core; type Ref; type Field; diff --git a/StrataTest/Languages/Boogie/Examples/RealBitVector.lean b/StrataTest/Languages/Boogie/Examples/RealBitVector.lean index 9187e138e..864ae3b10 100644 --- a/StrataTest/Languages/Boogie/Examples/RealBitVector.lean +++ b/StrataTest/Languages/Boogie/Examples/RealBitVector.lean @@ -11,7 +11,7 @@ namespace Strata def realPgm : Program := #strata -program Boogie; +program Core; const x : real; const y : real; @@ -109,7 +109,7 @@ Result: ❌ fail def bvPgm : Program := #strata -program Boogie; +program Core; const x : bv8; const y : bv8; @@ -197,7 +197,7 @@ Result: ✅ pass def bvMoreOpsPgm : Program := #strata -program Boogie; +program Core; procedure P(x: bv8, y: bv8, z: bv8) returns () { assert [add_comm]: x + y == y + x; diff --git a/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean b/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean index 929792425..d5557203c 100644 --- a/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean +++ b/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean @@ -11,7 +11,7 @@ namespace Strata def procIfPgm : Program := #strata -program Boogie; +program Core; procedure F(n : int) returns (r : int) spec { diff --git a/StrataTest/Languages/Boogie/Examples/Regex.lean b/StrataTest/Languages/Boogie/Examples/Regex.lean index 5f0a38391..d17944055 100644 --- a/StrataTest/Languages/Boogie/Examples/Regex.lean +++ b/StrataTest/Languages/Boogie/Examples/Regex.lean @@ -11,7 +11,7 @@ namespace Strata def regexPgm1 := #strata -program Boogie; +program Core; function cannot_end_with_period () : regex { re.comp(re.concat (re.* (re.all()), str.to.re("."))) @@ -178,7 +178,7 @@ Result: ✅ pass def regexPgm2 := #strata -program Boogie; +program Core; function bad_re_loop (n : int) : regex { re.loop(re.range("a", "z"), 1, n) @@ -279,7 +279,7 @@ Original expression: (((~Re.Loop ((~Re.Range #a) #z)) #1) %0) def regexPgm3 := #strata -program Boogie; +program Core; procedure main(n : int) returns () { diff --git a/StrataTest/Languages/Boogie/Examples/RemoveIrrelevantAxioms.lean b/StrataTest/Languages/Boogie/Examples/RemoveIrrelevantAxioms.lean index ce0d13505..b7b020030 100644 --- a/StrataTest/Languages/Boogie/Examples/RemoveIrrelevantAxioms.lean +++ b/StrataTest/Languages/Boogie/Examples/RemoveIrrelevantAxioms.lean @@ -11,7 +11,7 @@ namespace Strata def irrelevantAxiomsTestPgm : Strata.Program := #strata -program Boogie; +program Core; type StrataHeap; type StrataRef; type StrataField (t: Type); diff --git a/StrataTest/Languages/Boogie/Examples/SimpleProc.lean b/StrataTest/Languages/Boogie/Examples/SimpleProc.lean index 347d9b91c..e22f8638e 100644 --- a/StrataTest/Languages/Boogie/Examples/SimpleProc.lean +++ b/StrataTest/Languages/Boogie/Examples/SimpleProc.lean @@ -11,7 +11,7 @@ namespace Strata def simpleProcPgm : Program := #strata -program Boogie; +program Core; var g : bool; procedure Test(x : bool) returns (y : bool) spec { diff --git a/StrataTest/Languages/Boogie/Examples/String.lean b/StrataTest/Languages/Boogie/Examples/String.lean index fd32b7194..fcbe0fc74 100644 --- a/StrataTest/Languages/Boogie/Examples/String.lean +++ b/StrataTest/Languages/Boogie/Examples/String.lean @@ -16,7 +16,7 @@ namespace Strata def strPgm := #strata -program Boogie; +program Core; procedure main() returns () { diff --git a/StrataTest/Languages/Boogie/Examples/TypeAlias.lean b/StrataTest/Languages/Boogie/Examples/TypeAlias.lean index 6068a759f..9aef9feed 100644 --- a/StrataTest/Languages/Boogie/Examples/TypeAlias.lean +++ b/StrataTest/Languages/Boogie/Examples/TypeAlias.lean @@ -17,7 +17,7 @@ error: Expression has type FooAlias (Foo int int) when Foo bool int expected. #guard_msgs in def badTypeAlias : Program := #strata -program Boogie; +program Core; type Foo (a : Type, b : Type); type FooAlias (a : Type) := Foo bool bool; @@ -36,7 +36,7 @@ procedure P () returns () { def goodTypeAlias : Program := #strata -program Boogie; +program Core; type Foo (a : Type, b : Type); type FooAlias (a : Type) := Foo int bool; type FooAlias2 (a : Type) := FooAlias (FooAlias bool); @@ -102,7 +102,7 @@ Result: ✅ pass def funcAndTypeAliasesPgm : Program := #strata -program Boogie; +program Core; type MapInt := Map int int; diff --git a/StrataTest/Languages/Boogie/Examples/TypeDecl.lean b/StrataTest/Languages/Boogie/Examples/TypeDecl.lean index 24151e259..20d685cb0 100644 --- a/StrataTest/Languages/Boogie/Examples/TypeDecl.lean +++ b/StrataTest/Languages/Boogie/Examples/TypeDecl.lean @@ -11,7 +11,7 @@ namespace Strata private def typeDeclPgm1 : Program := #strata -program Boogie; +program Core; type Foo (a : Type, b : Type); const fooConst : Foo int bool; @@ -57,7 +57,7 @@ error: Expression has type Foo bool int when Foo bool bool expected. #guard_msgs in def typeDeclPgm2 := #strata -program Boogie; +program Core; type Foo (a : Type, b : Type); @@ -72,7 +72,7 @@ procedure P () returns () { def typeDeclPgm3 : Program := #strata -program Boogie; +program Core; type Foo (a : Type, b : Type); const fooVal : Foo int bool; @@ -119,7 +119,7 @@ Result: ✅ pass def typeDeclPgm4 := #strata -program Boogie; +program Core; type int := bool; #end diff --git a/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean b/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean index d84cf20fa..49d43b046 100644 --- a/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean +++ b/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean @@ -12,7 +12,7 @@ namespace Strata private def pgm := #strata -program Boogie; +program Core; type set := Map int bool; diff --git a/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean b/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean index fd9b9bd08..fd5ebb504 100644 --- a/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean +++ b/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean @@ -11,7 +11,7 @@ namespace Strata def unreachableAssertPgm := #strata -program Boogie; +program Core; procedure R() returns () { var x : int, y : int; diff --git a/StrataTest/Transform/CallElim.lean b/StrataTest/Transform/CallElim.lean index 9e4bd746d..8fc36dd82 100644 --- a/StrataTest/Transform/CallElim.lean +++ b/StrataTest/Transform/CallElim.lean @@ -25,7 +25,7 @@ section CallElimExamples def CallElimTest1 := #strata -program Boogie; +program Core; var i : bool; var j : bool; var k : bool; @@ -46,7 +46,7 @@ procedure h() returns () spec { def CallElimTest1Ans := #strata -program Boogie; +program Core; var i : bool; var j : bool; var k : bool; @@ -73,7 +73,7 @@ procedure h() returns () spec { def CallElimTest2 := #strata -program Boogie; +program Core; var i : bool; var j : bool; var k : bool; @@ -95,7 +95,7 @@ procedure h() returns () spec { def CallElimTest2Ans := #strata -program Boogie; +program Core; var i : bool; var j : bool; var k : bool; @@ -126,7 +126,7 @@ procedure h() returns () spec { def CallElimTest3 := #strata -program Boogie; +program Core; var i : bool; var j : bool; var k : bool; @@ -148,7 +148,7 @@ procedure h() returns () spec { def CallElimTest3Ans := #strata -program Boogie; +program Core; var i : bool; var j : bool; var k : bool; diff --git a/StrataTest/Transform/ProcedureInlining.lean b/StrataTest/Transform/ProcedureInlining.lean index 4eaeefaef..a0f98a464 100644 --- a/StrataTest/Transform/ProcedureInlining.lean +++ b/StrataTest/Transform/ProcedureInlining.lean @@ -252,7 +252,7 @@ def checkInlining (prog : Boogie.Program) (progAns : Boogie.Program) def Test1 := #strata -program Boogie; +program Core; procedure f(x : bool) returns (y : bool) { y := !x; }; @@ -266,7 +266,7 @@ procedure h() returns () { def Test1Ans := #strata -program Boogie; +program Core; procedure f(x : bool) returns (y : bool) { y := !x; }; @@ -291,7 +291,7 @@ procedure h() returns () { def Test2 := #strata -program Boogie; +program Core; procedure f(x : bool) returns (y : bool) { if (x) { goto end; @@ -310,7 +310,7 @@ procedure h() returns () { def Test2Ans := #strata -program Boogie; +program Core; procedure f(x : bool) returns (y : bool) { if (x) { goto end; @@ -348,7 +348,7 @@ procedure h() returns () { def Test3 := #strata -program Boogie; +program Core; procedure f(x : int) returns (y : int) { y := x; }; @@ -365,7 +365,7 @@ procedure g() returns () { def Test3Ans := #strata -program Boogie; +program Core; procedure f(x : int) returns (y : int) { y := x; }; diff --git a/StrataToCBMC.lean b/StrataToCBMC.lean index dc79aae7e..3e7ec634b 100644 --- a/StrataToCBMC.lean +++ b/StrataToCBMC.lean @@ -22,7 +22,7 @@ def main (args : List String) : IO Unit := do let text ← Strata.Util.readInputSource file let inputCtx := Lean.Parser.mkInputContext text (Strata.Util.displayName file) let dctx := Elab.LoadedDialects.builtin - let dctx := dctx.addDialect! Boogie + let dctx := dctx.addDialect! Core let dctx := dctx.addDialect! C_Simp let leanEnv ← Lean.mkEmptyEnvironment 0 match Strata.Elab.elabProgram dctx leanEnv inputCtx with diff --git a/StrataVerify.lean b/StrataVerify.lean index ff7aef041..065b8dc36 100644 --- a/StrataVerify.lean +++ b/StrataVerify.lean @@ -49,7 +49,7 @@ def main (args : List String) : IO UInt32 := do let text ← Strata.Util.readInputSource file let inputCtx := Lean.Parser.mkInputContext text (Strata.Util.displayName file) let dctx := Elab.LoadedDialects.builtin - let dctx := dctx.addDialect! Boogie + let dctx := dctx.addDialect! Core let dctx := dctx.addDialect! C_Simp let leanEnv ← Lean.mkEmptyEnvironment 0 match Strata.Elab.elabProgram dctx leanEnv inputCtx with diff --git a/Tools/BoogieToStrata/Source/StrataGenerator.cs b/Tools/BoogieToStrata/Source/StrataGenerator.cs index 795370e7b..1bd7448fe 100644 --- a/Tools/BoogieToStrata/Source/StrataGenerator.cs +++ b/Tools/BoogieToStrata/Source/StrataGenerator.cs @@ -212,7 +212,7 @@ private void EmitUniqueConstAxioms() { } private void EmitHeader() { - WriteLine("program Boogie;"); + WriteLine("program Core;"); WriteLine("type StrataHeap;"); WriteLine("type StrataRef;"); WriteLine("type StrataField (t: Type);"); From ff2bbc2f08d2eb10886fedb211d7c024fcce0dc7 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 14:41:28 -0600 Subject: [PATCH 04/19] Rename namespace Boogie to Core --- Strata/Backends/CBMC/BoogieToCBMC.lean | 22 +- Strata/Languages/Boogie/Axiom.lean | 2 +- Strata/Languages/Boogie/Boogie.lean | 31 +- Strata/Languages/Boogie/BoogieGen.lean | 10 +- Strata/Languages/Boogie/CallGraph.lean | 4 +- Strata/Languages/Boogie/CmdEval.lean | 6 +- Strata/Languages/Boogie/CmdType.lean | 4 +- .../Boogie/DDMTransform/Translate.lean | 738 +++++++++--------- Strata/Languages/Boogie/Env.lean | 6 +- Strata/Languages/Boogie/Expressions.lean | 4 +- Strata/Languages/Boogie/Factory.lean | 8 +- Strata/Languages/Boogie/Function.lean | 4 +- Strata/Languages/Boogie/FunctionType.lean | 8 +- Strata/Languages/Boogie/Identifiers.lean | 2 +- Strata/Languages/Boogie/OldExpressions.lean | 11 +- Strata/Languages/Boogie/Procedure.lean | 4 +- Strata/Languages/Boogie/ProcedureEval.lean | 4 +- Strata/Languages/Boogie/ProcedureType.lean | 8 +- Strata/Languages/Boogie/ProcedureWF.lean | 4 +- Strata/Languages/Boogie/Program.lean | 18 +- Strata/Languages/Boogie/ProgramEval.lean | 4 +- Strata/Languages/Boogie/ProgramType.lean | 10 +- Strata/Languages/Boogie/ProgramWF.lean | 4 +- Strata/Languages/Boogie/SMTEncoder.lean | 12 +- Strata/Languages/Boogie/Statement.lean | 12 +- Strata/Languages/Boogie/StatementEval.lean | 4 +- .../Languages/Boogie/StatementSemantics.lean | 20 +- .../Boogie/StatementSemanticsProps.lean | 6 +- Strata/Languages/Boogie/StatementType.lean | 4 +- Strata/Languages/Boogie/StatementWF.lean | 4 +- Strata/Languages/Boogie/TypeDecl.lean | 2 +- Strata/Languages/Boogie/Verifier.lean | 32 +- Strata/Languages/Boogie/WF.lean | 4 +- Strata/Languages/C_Simp/Verify.lean | 50 +- .../ConcreteToAbstractTreeTranslator.lean | 4 +- Strata/Languages/Laurel/Laurel.lean | 6 +- .../Laurel/LaurelToBoogieTranslator.lean | 60 +- Strata/Languages/Python/BoogiePrelude.lean | 2 +- .../Languages/Python/FunctionSignatures.lean | 4 +- Strata/Languages/Python/PyFactory.lean | 8 +- Strata/Languages/Python/PythonToBoogie.lean | 132 ++-- Strata/Languages/Python/Regex/ReToBoogie.lean | 10 +- Strata/Transform/CallElim.lean | 6 +- Strata/Transform/CallElimCorrect.lean | 44 +- Strata/Transform/CoreTransform.lean | 4 +- Strata/Transform/DetToNondetCorrect.lean | 2 +- Strata/Transform/LoopElim.lean | 2 +- Strata/Transform/ProcedureInlining.lean | 14 +- StrataCoreToGoto.lean | 2 +- StrataMain.lean | 12 +- .../Backends/CBMC/BoogieToCProverGOTO.lean | 60 +- StrataTest/DDM/Integration/Java/TestGen.lean | 14 +- .../Internal/InternalBoogiePrelude.lean | 2 +- .../Boogie/DatatypeVerificationTests.lean | 8 +- .../Boogie/Examples/AdvancedMaps.lean | 2 +- .../Boogie/Examples/AdvancedQuantifiers.lean | 2 +- .../Examples/AssertionDefaultNames.lean | 2 +- .../Languages/Boogie/Examples/Axioms.lean | 6 +- .../Boogie/Examples/BitVecParse.lean | 2 +- .../Boogie/Examples/DDMAxiomsExtraction.lean | 338 ++++---- .../Boogie/Examples/FailingAssertion.lean | 2 +- .../Boogie/Examples/FreeRequireEnsure.lean | 6 +- .../Languages/Boogie/Examples/Functions.lean | 10 +- .../Boogie/Examples/GeneratedLabels.lean | 6 +- .../Languages/Boogie/Examples/Goto.lean | 4 +- .../Languages/Boogie/Examples/Havoc.lean | 2 +- .../Languages/Boogie/Examples/Loops.lean | 2 +- StrataTest/Languages/Boogie/Examples/Map.lean | 2 +- StrataTest/Languages/Boogie/Examples/Min.lean | 2 +- .../Boogie/Examples/OldExpressions.lean | 2 +- .../Boogie/Examples/PrecedenceCheck.lean | 2 +- .../Boogie/Examples/ProcedureCall.lean | 4 +- .../Boogie/Examples/Quantifiers.lean | 4 +- .../Examples/QuantifiersWithTypeAliases.lean | 6 +- .../Boogie/Examples/RealBitVector.lean | 4 +- .../Boogie/Examples/RecursiveProcIte.lean | 2 +- .../Languages/Boogie/Examples/Regex.lean | 6 +- .../Languages/Boogie/Examples/SimpleProc.lean | 2 +- .../Languages/Boogie/Examples/String.lean | 2 +- .../Languages/Boogie/Examples/TypeAlias.lean | 6 +- .../Languages/Boogie/Examples/TypeDecl.lean | 4 +- .../Examples/TypeVarImplicitlyQuantified.lean | 4 +- .../Boogie/Examples/UnreachableAssert.lean | 2 +- StrataTest/Languages/Boogie/ExprEvalTest.lean | 18 +- .../Languages/Boogie/ProcedureEvalTests.lean | 6 +- .../Languages/Boogie/ProcedureTypeTests.lean | 12 +- .../Languages/Boogie/ProgramTypeTests.lean | 12 +- .../Boogie/SMTEncoderDatatypeTest.lean | 4 +- .../Languages/Boogie/StatementEvalTests.lean | 6 +- .../Languages/Boogie/StatementTypeTests.lean | 6 +- .../Languages/C_Simp/Examples/LoopSimple.lean | 2 +- .../C_Simp/Examples/LoopTrivial.lean | 2 +- StrataTest/Languages/C_Simp/Examples/Min.lean | 2 +- .../Languages/C_Simp/Examples/SimpleTest.lean | 2 +- .../Languages/C_Simp/Examples/Trivial.lean | 2 +- StrataTest/Transform/CallElim.lean | 14 +- StrataTest/Transform/DetToNondet.lean | 2 +- StrataTest/Transform/ProcedureInlining.lean | 16 +- StrataToCBMC.lean | 2 +- StrataVerify.lean | 6 +- 100 files changed, 1006 insertions(+), 1008 deletions(-) diff --git a/Strata/Backends/CBMC/BoogieToCBMC.lean b/Strata/Backends/CBMC/BoogieToCBMC.lean index b249d592f..95aaa169d 100644 --- a/Strata/Backends/CBMC/BoogieToCBMC.lean +++ b/Strata/Backends/CBMC/BoogieToCBMC.lean @@ -15,7 +15,7 @@ import Strata.Backends.CBMC.Common open Lean open Strata.CBMC -namespace Boogie +namespace Core -- Our test program def SimpleTestEnv := #strata @@ -34,10 +34,10 @@ spec { }; #end -open Boogie in +open Core in def SimpleTestEnvAST := Strata.TransM.run Inhabited.default (Strata.translateProgram (SimpleTestEnv)) -def myProc : Boogie.Procedure := match SimpleTestEnvAST.fst.decls.head!.getProc? with +def myProc : Core.Procedure := match SimpleTestEnvAST.fst.decls.head!.getProc? with | .some p => p | .none => panic! "Expected procedure" @@ -54,7 +54,7 @@ instance : IdentToStr String where class HasLExpr (P : Imperative.PureExpr) (I : Lambda.LExprParams) where expr_eq : P.Expr = Lambda.LExpr I.mono -instance : HasLExpr Boogie.Expression BoogieLParams where +instance : HasLExpr Core.Expression BoogieLParams where expr_eq := rfl def exprToJson (I : Lambda.LExprParams) [IdentToStr (Lambda.Identifier I.IDMeta)] (e : Lambda.LExpr I.mono) (loc: SourceLoc) : Json := @@ -79,7 +79,7 @@ def exprToJson (I : Lambda.LExprParams) [IdentToStr (Lambda.Identifier I.IDMeta) mkLvalueSymbol s!"{loc.functionName}::{IdentToStr.toStr name}" loc.lineNum loc.functionName | _ => panic! "Unimplemented" -def cmdToJson (e : Boogie.Command) (loc: SourceLoc) : Json := +def cmdToJson (e : Core.Command) (loc: SourceLoc) : Json := match e with | .call _ _ _ _ => panic! "Not supported" | .cmd c => @@ -207,11 +207,11 @@ def stmtToJson {P : Imperative.PureExpr} (I : Lambda.LExprParams) [IdentToStr (L decreasing_by all_goals(simp; omega) end -def listToExpr (l: ListMap BoogieLabel Boogie.Procedure.Check) : Boogie.Expression.Expr := +def listToExpr (l: ListMap BoogieLabel Core.Procedure.Check) : Core.Expression.Expr := match l with | _ => .true () -def createContractSymbolFromAST (func : Boogie.Procedure) : CBMCSymbol := +def createContractSymbolFromAST (func : Core.Procedure) : CBMCSymbol := let location : Location := { id := "", namedSub := some (Json.mkObj [ @@ -310,14 +310,14 @@ def createContractSymbolFromAST (func : Boogie.Procedure) : CBMCSymbol := value := Json.mkObj [("id", "nil")] } -def getParamJson(func: Boogie.Procedure) : Json := +def getParamJson(func: Core.Procedure) : Json := Json.mkObj [ ("id", ""), ("sub", Json.arr (func.header.inputs.map (λ i => mkParameter i.fst.name (func.header.name.toPretty) "1")).toArray) ] -def createImplementationSymbolFromAST (func : Boogie.Procedure) : CBMCSymbol := +def createImplementationSymbolFromAST (func : Core.Procedure) : CBMCSymbol := let location : Location := { namedSub := some (Json.mkObj [ ("file", Json.mkObj [("id", "ex_prog.c")]), @@ -367,7 +367,7 @@ def createImplementationSymbolFromAST (func : Boogie.Procedure) : CBMCSymbol := value := implValue } -def testSymbols (proc: Boogie.Procedure) : String := Id.run do +def testSymbols (proc: Core.Procedure) : String := Id.run do -- Generate symbols using AST data let contractSymbol := createContractSymbolFromAST proc let implSymbol := createImplementationSymbolFromAST proc @@ -392,4 +392,4 @@ def testSymbols (proc: Boogie.Procedure) : String := Id.run do m := m.insert s!"{proc.header.name.name}::1::z" zSymbol toString (toJson m) -end Boogie +end Core diff --git a/Strata/Languages/Boogie/Axiom.lean b/Strata/Languages/Boogie/Axiom.lean index ea113002b..4a63bae4a 100644 --- a/Strata/Languages/Boogie/Axiom.lean +++ b/Strata/Languages/Boogie/Axiom.lean @@ -11,7 +11,7 @@ import Strata.Languages.Boogie.Statement import Strata.DL.Lambda.LTy import Strata.DL.Lambda.LExpr -namespace Boogie +namespace Core --------------------------------------------------------------------- open Std (ToFormat Format format) diff --git a/Strata/Languages/Boogie/Boogie.lean b/Strata/Languages/Boogie/Boogie.lean index b8f609e59..ee55f8df9 100644 --- a/Strata/Languages/Boogie/Boogie.lean +++ b/Strata/Languages/Boogie/Boogie.lean @@ -11,41 +11,38 @@ import Strata.Languages.Boogie.ProgramType --------------------------------------------------------------------- -namespace Boogie +namespace Core /-! -## Differences between Boogie and Strata.Boogie +## Differences between Boogie and Strata.Core 1. Local variables can shadow globals in Boogie, but the typechecker disallows - that in Strata.Boogie. + that in Strata.Core. -2. Unlike Boogie, Strata.Boogie is sensitive to global declaration order. E.g., +2. Unlike Boogie, Strata.Core is sensitive to global declaration order. E.g., a global variable must be declared before it can be used in a procedure. -3. Strata.Boogie does not (yet) support polymorphism. +3. Strata.Core does not (yet) support polymorphism. -4. Strata.Boogie does not (yet) support arbitrary gotos. All gotos must +4. Strata.Core does not (yet) support arbitrary gotos. All gotos must currently be to labels later in the program. -5. Strata.Boogie does not support `where` clauses and `unique` constants, +5. Strata.Core does not support `where` clauses and `unique` constants, requiring a tool like `BoogieToStrata` to desugar them. - -6. Strata.Boogie does not support algebraic data types or regular expression - types. -/ def typeCheck (options : Options) (program : Program) (moreFns : @Lambda.Factory BoogieLParams := Lambda.Factory.default) : Except Std.Format Program := do let T := Lambda.TEnv.default - let factory ← Boogie.Factory.addFactory moreFns + let factory ← Core.Factory.addFactory moreFns let C := { Lambda.LContext.default with functions := factory, - knownTypes := Boogie.KnownTypes } + knownTypes := Core.KnownTypes } let (program, _T) ← Program.typeCheck C T program - -- dbg_trace f!"[Strata.Boogie] Type variables:\n{T.state.substInfo.subst.length}" - -- dbg_trace f!"[Strata.Boogie] Annotated program:\n{program}" - if options.verbose then dbg_trace f!"[Strata.Boogie] Type checking succeeded.\n" + -- dbg_trace f!"[Strata.Core] Type variables:\n{T.state.substInfo.subst.length}" + -- dbg_trace f!"[Strata.Core] Annotated program:\n{program}" + if options.verbose then dbg_trace f!"[Strata.Core] Type checking succeeded.\n" return program def typeCheckAndPartialEval (options : Options) (program : Program) @@ -57,7 +54,7 @@ def typeCheckAndPartialEval (options : Options) (program : Program) match decl with | .type (.data d) _ => some d | _ => none - let σ ← (Lambda.LState.init).addFactory Boogie.Factory + let σ ← (Lambda.LState.init).addFactory Core.Factory let σ ← σ.addFactory moreFns let E := { Env.init with exprEnv := σ, program := program } @@ -73,6 +70,6 @@ def typeCheckAndPartialEval (options : Options) (program : Program) instance : ToString (Program) where toString p := toString (Std.format p) -end Boogie +end Core --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/BoogieGen.lean b/Strata/Languages/Boogie/BoogieGen.lean index 58f845b91..f4a9fe539 100644 --- a/Strata/Languages/Boogie/BoogieGen.lean +++ b/Strata/Languages/Boogie/BoogieGen.lean @@ -8,9 +8,9 @@ import Strata.Languages.Boogie.Statement import Strata.DL.Util.LabelGen import Strata.DL.Util.StringGen import Strata.DL.Util.ListUtils -open Boogie Lambda Imperative +open Core Lambda Imperative -/-! ## Boogie Identifier Generator +/-! ## Strata Core Identifier Generator This file contains a Boogie Identifier generator `BoogieGenState.gen`, where the uniqueness of the generated identifiers is designed to be provable. It relies on a `StringGenState` to generate unique strings (See `StringGen.lean`). @@ -24,7 +24,7 @@ def initVarValue (id : BoogieIdent) : Expression.Expr := end Names -namespace Boogie +namespace Core structure BoogieGenState where cs : StringGenState @@ -32,7 +32,7 @@ structure BoogieGenState where def BoogieGenState.WF (σ : BoogieGenState) := StringGenState.WF σ.cs ∧ - List.map Boogie.BoogieIdent.temp σ.cs.generated.unzip.snd = σ.generated ∧ + List.map Core.BoogieIdent.temp σ.cs.generated.unzip.snd = σ.generated ∧ σ.generated.Nodup ∧ Forall (BoogieIdent.isTemp ·) σ.generated @@ -110,4 +110,4 @@ instance : LabelGen.WFLabelGen BoogieIdent BoogieGenState where abbrev BoogieGenM := StateM BoogieGenState -end Boogie +end Core diff --git a/Strata/Languages/Boogie/CallGraph.lean b/Strata/Languages/Boogie/CallGraph.lean index 8e60228d4..2b5340c53 100644 --- a/Strata/Languages/Boogie/CallGraph.lean +++ b/Strata/Languages/Boogie/CallGraph.lean @@ -7,7 +7,7 @@ import Strata.Languages.Boogie.Program --------------------------------------------------------------------- -namespace Boogie +namespace Core /-- Generic call graph structure -/ structure CallGraph where @@ -198,4 +198,4 @@ def Program.getIrrelevantAxioms (prog : Program) (functions : List String) : Lis --------------------------------------------------------------------- -end Boogie +end Core diff --git a/Strata/Languages/Boogie/CmdEval.lean b/Strata/Languages/Boogie/CmdEval.lean index 1c38e3c53..870d3b1db 100644 --- a/Strata/Languages/Boogie/CmdEval.lean +++ b/Strata/Languages/Boogie/CmdEval.lean @@ -12,7 +12,7 @@ import Strata.Languages.Boogie.Env import Strata.DL.Imperative.EvalContext import Strata.DL.Imperative.CmdEval -namespace Boogie +namespace Core open Lambda Imperative open Std (ToFormat Format format) @@ -125,7 +125,7 @@ instance : ToFormat (Cmds Expression × Env) where --------------------------------------------------------------------- -open LExpr.SyntaxMono LTy.Syntax Boogie.Syntax +open LExpr.SyntaxMono LTy.Syntax Core.Syntax private def testProgram1 : Cmds Expression := [.init "x" t[int] eb[#0], .set "x" eb[#10], @@ -217,4 +217,4 @@ Proof Obligation: end CmdEval --------------------------------------------------------------------- -end Boogie +end Core diff --git a/Strata/Languages/Boogie/CmdType.lean b/Strata/Languages/Boogie/CmdType.lean index 5b6fcb6e2..1bbbfbef3 100644 --- a/Strata/Languages/Boogie/CmdType.lean +++ b/Strata/Languages/Boogie/CmdType.lean @@ -11,7 +11,7 @@ import Strata.Languages.Boogie.Expressions import Strata.DL.Imperative.TypeContext import Strata.DL.Lambda.Factory -namespace Boogie +namespace Core open Lambda Imperative open Std (ToFormat Format format) @@ -117,4 +117,4 @@ instance : Imperative.TypeContext Expression (LContext BoogieLParams) (TEnv Visi end CmdType --------------------------------------------------------------------- -end Boogie +end Core diff --git a/Strata/Languages/Boogie/DDMTransform/Translate.lean b/Strata/Languages/Boogie/DDMTransform/Translate.lean index 0c563dbb4..4704bb2f3 100644 --- a/Strata/Languages/Boogie/DDMTransform/Translate.lean +++ b/Strata/Languages/Boogie/DDMTransform/Translate.lean @@ -15,7 +15,7 @@ namespace Strata /- Translating concrete syntax into abstract syntax -/ -open Boogie Lambda Imperative Lean.Parser +open Core Lambda Imperative Lean.Parser open Std (ToFormat Format format) --------------------------------------------------------------------- @@ -33,7 +33,7 @@ def TransM.run (ictx : InputContext) (m : TransM α) : (α × Array String) := let (v, s) := StateT.run m { inputCtx := ictx, errors := #[] } (v, s.errors) -instance : ToString (Boogie.Program × Array String) where +instance : ToString (Core.Program × Array String) where toString p := toString (Std.format p.fst) ++ "\n" ++ "Errors: " ++ (toString p.snd) @@ -45,7 +45,7 @@ def TransM.error [Inhabited α] (msg : String) : TransM α := do /- Metadata -/ -def SourceRange.toMetaData (ictx : InputContext) (sr : SourceRange) : Imperative.MetaData Boogie.Expression := +def SourceRange.toMetaData (ictx : InputContext) (sr : SourceRange) : Imperative.MetaData Core.Expression := let file := ictx.fileName let startPos := ictx.fileMap.toPosition sr.start let endPos := ictx.fileMap.toPosition sr.stop @@ -53,10 +53,10 @@ def SourceRange.toMetaData (ictx : InputContext) (sr : SourceRange) : Imperative let fileRangeElt := ⟨ MetaData.fileRange, .fileRange ⟨ uri, startPos, endPos ⟩ ⟩ #[fileRangeElt] -def getOpMetaData (op : Operation) : TransM (Imperative.MetaData Boogie.Expression) := +def getOpMetaData (op : Operation) : TransM (Imperative.MetaData Core.Expression) := return op.ann.toMetaData (← StateT.get).inputCtx -def getArgMetaData (arg : Arg) : TransM (Imperative.MetaData Boogie.Expression) := +def getArgMetaData (arg : Arg) : TransM (Imperative.MetaData Core.Expression) := return arg.ann.toMetaData (← StateT.get).inputCtx --------------------------------------------------------------------- @@ -111,7 +111,7 @@ def translateOptionLabel (default : String) (arg : Arg) : TransM String := do translateOption (fun maybe_arg => do match maybe_arg with | none => return default - | some lop => let args ← checkOpArg lop q`Boogie.label 1 + | some lop => let args ← checkOpArg lop q`Core.label 1 translateIdent String args[0]!) arg @@ -155,7 +155,7 @@ structure GenNum where structure TransBindings where boundTypeVars : Array TyIdentifier := #[] boundVars : Array (LExpr BoogieLParams.mono) := #[] - freeVars : Array Boogie.Decl := #[] + freeVars : Array Core.Decl := #[] gen : GenNum := (GenNum.mk 0 0 0 0 0) def incrNum (gen_kind : GenKind) (b : TransBindings) : TransBindings := @@ -178,19 +178,19 @@ instance : ToFormat TransBindings where {Format.line}\ Gen: {repr b.gen}" -instance : Inhabited (List Boogie.Statement × TransBindings) where +instance : Inhabited (List Core.Statement × TransBindings) where default := ([], {}) -instance : Inhabited Boogie.Decl where +instance : Inhabited Core.Decl where default := .var "badguy" (.forAll [] (.tcons "bool" [])) (.false ()) instance : Inhabited (Procedure.CheckAttr) where default := .Default -instance : Inhabited (Boogie.Decl × TransBindings) where +instance : Inhabited (Core.Decl × TransBindings) where default := (.var "badguy" (.forAll [] (.tcons "bool" [])) (.false ()), {}) -instance : Inhabited (Boogie.Decls × TransBindings) where +instance : Inhabited (Core.Decls × TransBindings) where default := ([], {}) instance : Inhabited (List BoogieIdent × TransBindings) where @@ -204,7 +204,7 @@ instance : Inhabited (List TyIdentifier × TransBindings) where def translateTypeBinding (bindings : TransBindings) (op : Arg) : TransM (TyIdentifier × TransBindings) := do -- (FIXME) Account for metadata. - let bargs ← checkOpArg op q`Boogie.mkBinding 2 + let bargs ← checkOpArg op q`Core.mkBinding 2 let id ← translateIdent TyIdentifier bargs[0]! -- (TODO) It looks like other elements of `bargs` are irrelevant here? -- Perhaps we should not using `Bindings` for type declarations. @@ -229,11 +229,11 @@ partial def translateLMonoTy (bindings : TransBindings) (arg : Arg) : let .type tp := arg | TransM.error s!"translateLMonoTy expected type {repr arg}" match tp with - | .ident _ q`Boogie.bv1 #[] => pure <| .bitvec 1 - | .ident _ q`Boogie.bv8 #[] => pure <| .bitvec 8 - | .ident _ q`Boogie.bv16 #[] => pure <| .bitvec 16 - | .ident _ q`Boogie.bv32 #[] => pure <| .bitvec 32 - | .ident _ q`Boogie.bv64 #[] => pure <| .bitvec 64 + | .ident _ q`Core.bv1 #[] => pure <| .bitvec 1 + | .ident _ q`Core.bv8 #[] => pure <| .bitvec 8 + | .ident _ q`Core.bv16 #[] => pure <| .bitvec 16 + | .ident _ q`Core.bv32 #[] => pure <| .bitvec 32 + | .ident _ q`Core.bv64 #[] => pure <| .bitvec 64 | .ident _ i argst => let argst' ← translateLMonoTys bindings (argst.map ArgF.type) pure <| (.tcons i.name argst'.toList.reverse) @@ -283,13 +283,13 @@ def translateTypeArgs (op : Strata.Arg) : TransM (Array TyIdentifier) := do translateOption (fun x => do match x with | none => return Array.empty | some a => - let args ← checkOpArg a q`Boogie.type_args 1 + let args ← checkOpArg a q`Core.type_args 1 translateCommaSep (translateIdent TyIdentifier) args[0]!) op def translateTypeSynonym (bindings : TransBindings) (op : Operation) : - TransM (Boogie.Decl × TransBindings) := do - let _ ← @checkOp (Boogie.Decl × TransBindings) op q`Boogie.command_typesynonym 4 + TransM (Core.Decl × TransBindings) := do + let _ ← @checkOp (Core.Decl × TransBindings) op q`Core.command_typesynonym 4 let name ← translateIdent TyIdentifier op.args[0]! let (targs, bindings) ← translateOption @@ -297,7 +297,7 @@ def translateTypeSynonym (bindings : TransBindings) (op : Operation) : do match maybearg with | none => pure ([], bindings) | some arg => - let bargs ← checkOpArg arg q`Boogie.mkBindings 1 + let bargs ← checkOpArg arg q`Core.mkBindings 1 let args ← match bargs[0]! with | .seq _ .comma args => @@ -308,13 +308,13 @@ def translateTypeSynonym (bindings : TransBindings) (op : Operation) : op.args[1]! let typedef ← translateLMonoTy bindings op.args[3]! let md ← getOpMetaData op - let decl := Boogie.Decl.type (.syn { name := name, typeArgs := targs, type := typedef }) md + let decl := Core.Decl.type (.syn { name := name, typeArgs := targs, type := typedef }) md return (decl, { bindings with freeVars := bindings.freeVars.push decl }) def translateTypeDecl (bindings : TransBindings) (op : Operation) : - TransM (Boogie.Decl × TransBindings) := do - let _ ← @checkOp (Boogie.Decl × TransBindings) op q`Boogie.command_typedecl 2 + TransM (Core.Decl × TransBindings) := do + let _ ← @checkOp (Core.Decl × TransBindings) op q`Core.command_typedecl 2 let name ← translateIdent TyIdentifier op.args[0]! let numargs ← translateOption @@ -322,7 +322,7 @@ def translateTypeDecl (bindings : TransBindings) (op : Operation) : do match maybearg with | none => pure 0 | some arg => - let bargs ← checkOpArg arg q`Boogie.mkBindings 1 + let bargs ← checkOpArg arg q`Core.mkBindings 1 let numargs ← match bargs[0]! with | .seq _ .comma args => pure args.size @@ -332,7 +332,7 @@ def translateTypeDecl (bindings : TransBindings) (op : Operation) : let md ← getOpMetaData op -- Only the number of type arguments is important; the exact identifiers are -- irrelevant. - let decl := Boogie.Decl.type (.con { name := name, numargs := numargs }) md + let decl := Core.Decl.type (.con { name := name, numargs := numargs }) md return (decl, { bindings with freeVars := bindings.freeVars.push decl }) --------------------------------------------------------------------- @@ -341,7 +341,7 @@ def translateLhs (arg : Arg) : TransM BoogieIdent := do let .op op := arg | TransM.error s!"translateLhs expected op {repr arg}" match op.name, op.args with - | q`Boogie.lhsIdent, #[id] => translateIdent BoogieIdent id + | q`Core.lhsIdent, #[id] => translateIdent BoogieIdent id -- (TODO) Implement lhsArray. | _, _ => TransM.error s!"translateLhs: unimplemented for {repr arg}" @@ -350,7 +350,7 @@ def translateBindMk (bindings : TransBindings) (arg : Arg) : let .op op := arg | TransM.error s!"translateBindMk expected op {repr arg}" match op.name, op.args with - | q`Boogie.bind_mk, #[ida, targsa, tpa] => + | q`Core.bind_mk, #[ida, targsa, tpa] => let id ← translateIdent BoogieIdent ida let args ← translateTypeArgs targsa let tp ← translateLMonoTy bindings tpa @@ -363,7 +363,7 @@ def translateMonoBindMk (bindings : TransBindings) (arg : Arg) : let .op op := arg | TransM.error s!"translateMonoBindMk expected op {repr arg}" match op.name, op.args with - | q`Boogie.mono_bind_mk, #[ida, tpa] => + | q`Core.mono_bind_mk, #[ida, tpa] => let id ← translateIdent BoogieIdent ida let tp ← translateLMonoTy bindings tpa return (id, tp) @@ -375,13 +375,13 @@ partial def translateDeclList (bindings : TransBindings) (arg : Arg) : let .op op := arg | TransM.error s!"translateDeclList expects an op {repr arg}" match op.name with - | q`Boogie.declAtom => - let args ← checkOpArg arg q`Boogie.declAtom 1 + | q`Core.declAtom => + let args ← checkOpArg arg q`Core.declAtom 1 let (id, targs, mty) ← translateBindMk bindings args[0]! let lty := .forAll targs mty pure [(id, lty)] - | q`Boogie.declPush => - let args ← checkOpArg arg q`Boogie.declPush 2 + | q`Core.declPush => + let args ← checkOpArg arg q`Core.declPush 2 let fst ← translateDeclList bindings args[0]! let (id, targs, mty) ← translateBindMk bindings args[1]! let lty : LTy := .forAll targs mty @@ -393,12 +393,12 @@ partial def translateMonoDeclList (bindings : TransBindings) (arg : Arg) : let .op op := arg | TransM.error s!"translateMonoDeclList expects an op {repr arg}" match op.name with - | q`Boogie.monoDeclAtom => - let args ← checkOpArg arg q`Boogie.monoDeclAtom 1 + | q`Core.monoDeclAtom => + let args ← checkOpArg arg q`Core.monoDeclAtom 1 let (id, mty) ← translateMonoBindMk bindings args[0]! pure [(id, mty)] - | q`Boogie.monoDeclPush => - let args ← checkOpArg arg q`Boogie.monoDeclPush 2 + | q`Core.monoDeclPush => + let args ← checkOpArg arg q`Core.monoDeclPush 2 let fst ← translateMonoDeclList bindings args[0]! let (id, mty) ← translateMonoBindMk bindings args[1]! pure (fst ++ ListMap.ofList [(id, mty)]) @@ -433,185 +433,185 @@ def isArithTy : LMonoTy → Bool | .bitvec _ => true | _ => false -def translateFn (ty? : Option LMonoTy) (q : QualifiedIdent) : TransM Boogie.Expression.Expr := +def translateFn (ty? : Option LMonoTy) (q : QualifiedIdent) : TransM Core.Expression.Expr := match ty?, q with - | _, q`Boogie.equiv => return boolEquivOp - | _, q`Boogie.implies => return boolImpliesOp - | _, q`Boogie.and => return boolAndOp - | _, q`Boogie.or => return boolOrOp - | _, q`Boogie.not => return boolNotOp - - | .some .int, q`Boogie.le => return intLeOp - | .some .int, q`Boogie.lt => return intLtOp - | .some .int, q`Boogie.ge => return intGeOp - | .some .int, q`Boogie.gt => return intGtOp - | .some .int, q`Boogie.add_expr => return intAddOp - | .some .int, q`Boogie.sub_expr => return intSubOp - | .some .int, q`Boogie.mul_expr => return intMulOp - | .some .int, q`Boogie.div_expr => return intDivOp - | .some .int, q`Boogie.mod_expr => return intModOp - | .some .int, q`Boogie.neg_expr => return intNegOp - - | .some .real, q`Boogie.le => return realLeOp - | .some .real, q`Boogie.lt => return realLtOp - | .some .real, q`Boogie.ge => return realGeOp - | .some .real, q`Boogie.gt => return realGtOp - | .some .real, q`Boogie.add_expr => return realAddOp - | .some .real, q`Boogie.sub_expr => return realSubOp - | .some .real, q`Boogie.mul_expr => return realMulOp - | .some .real, q`Boogie.div_expr => return realDivOp - | .some .real, q`Boogie.neg_expr => return realNegOp - - | .some .bv1, q`Boogie.le => return bv1ULeOp - | .some .bv1, q`Boogie.lt => return bv1ULtOp - | .some .bv1, q`Boogie.ge => return bv1UGeOp - | .some .bv1, q`Boogie.gt => return bv1UGtOp - | .some .bv1, q`Boogie.bvsle => return bv1SLeOp - | .some .bv1, q`Boogie.bvslt => return bv1SLtOp - | .some .bv1, q`Boogie.bvsge => return bv1SGeOp - | .some .bv1, q`Boogie.bvsgt => return bv1SGtOp - | .some .bv1, q`Boogie.neg_expr => return bv1NegOp - | .some .bv1, q`Boogie.add_expr => return bv1AddOp - | .some .bv1, q`Boogie.sub_expr => return bv1SubOp - | .some .bv1, q`Boogie.mul_expr => return bv1MulOp - | .some .bv1, q`Boogie.div_expr => return bv1UDivOp - | .some .bv1, q`Boogie.mod_expr => return bv1UModOp - | .some .bv1, q`Boogie.bvsdiv => return bv1SDivOp - | .some .bv1, q`Boogie.bvsmod => return bv1SModOp - | .some .bv1, q`Boogie.bvnot => return bv1NotOp - | .some .bv1, q`Boogie.bvand => return bv1AndOp - | .some .bv1, q`Boogie.bvor => return bv1OrOp - | .some .bv1, q`Boogie.bvxor => return bv1XorOp - | .some .bv1, q`Boogie.bvshl => return bv1ShlOp - | .some .bv1, q`Boogie.bvushr => return bv1UShrOp - | .some .bv1, q`Boogie.bvsshr => return bv1SShrOp - - | .some .bv8, q`Boogie.le => return bv8ULeOp - | .some .bv8, q`Boogie.lt => return bv8ULtOp - | .some .bv8, q`Boogie.ge => return bv8UGeOp - | .some .bv8, q`Boogie.gt => return bv8UGtOp - | .some .bv8, q`Boogie.bvsle => return bv8SLeOp - | .some .bv8, q`Boogie.bvslt => return bv8SLtOp - | .some .bv8, q`Boogie.bvsge => return bv8SGeOp - | .some .bv8, q`Boogie.bvsgt => return bv8SGtOp - | .some .bv8, q`Boogie.neg_expr => return bv8NegOp - | .some .bv8, q`Boogie.add_expr => return bv8AddOp - | .some .bv8, q`Boogie.sub_expr => return bv8SubOp - | .some .bv8, q`Boogie.mul_expr => return bv8MulOp - | .some .bv8, q`Boogie.div_expr => return bv8UDivOp - | .some .bv8, q`Boogie.mod_expr => return bv8UModOp - | .some .bv8, q`Boogie.bvsdiv => return bv8SDivOp - | .some .bv8, q`Boogie.bvsmod => return bv8SModOp - | .some .bv8, q`Boogie.bvnot => return bv8NotOp - | .some .bv8, q`Boogie.bvand => return bv8AndOp - | .some .bv8, q`Boogie.bvor => return bv8OrOp - | .some .bv8, q`Boogie.bvxor => return bv8XorOp - | .some .bv8, q`Boogie.bvshl => return bv8ShlOp - | .some .bv8, q`Boogie.bvushr => return bv8UShrOp - | .some .bv8, q`Boogie.bvsshr => return bv8SShrOp - - | .some .bv16, q`Boogie.le => return bv16ULeOp - | .some .bv16, q`Boogie.lt => return bv16ULtOp - | .some .bv16, q`Boogie.ge => return bv16UGeOp - | .some .bv16, q`Boogie.gt => return bv16UGtOp - | .some .bv16, q`Boogie.bvsle => return bv16SLeOp - | .some .bv16, q`Boogie.bvslt => return bv16SLtOp - | .some .bv16, q`Boogie.bvsge => return bv16SGeOp - | .some .bv16, q`Boogie.bvsgt => return bv16SGtOp - | .some .bv16, q`Boogie.neg_expr => return bv16NegOp - | .some .bv16, q`Boogie.add_expr => return bv16AddOp - | .some .bv16, q`Boogie.sub_expr => return bv16SubOp - | .some .bv16, q`Boogie.mul_expr => return bv16MulOp - | .some .bv16, q`Boogie.div_expr => return bv16UDivOp - | .some .bv16, q`Boogie.mod_expr => return bv16UModOp - | .some .bv16, q`Boogie.bvsdiv => return bv16SDivOp - | .some .bv16, q`Boogie.bvsmod => return bv16SModOp - | .some .bv16, q`Boogie.bvnot => return bv16NotOp - | .some .bv16, q`Boogie.bvand => return bv16AndOp - | .some .bv16, q`Boogie.bvor => return bv16OrOp - | .some .bv16, q`Boogie.bvxor => return bv16XorOp - | .some .bv16, q`Boogie.bvshl => return bv16ShlOp - | .some .bv16, q`Boogie.bvushr => return bv16UShrOp - | .some .bv16, q`Boogie.bvsshr => return bv16SShrOp - - | .some .bv32, q`Boogie.le => return bv32ULeOp - | .some .bv32, q`Boogie.lt => return bv32ULtOp - | .some .bv32, q`Boogie.ge => return bv32UGeOp - | .some .bv32, q`Boogie.gt => return bv32UGtOp - | .some .bv32, q`Boogie.bvsle => return bv32SLeOp - | .some .bv32, q`Boogie.bvslt => return bv32SLtOp - | .some .bv32, q`Boogie.bvsge => return bv32SGeOp - | .some .bv32, q`Boogie.bvsgt => return bv32SGtOp - | .some .bv32, q`Boogie.neg_expr => return bv32NegOp - | .some .bv32, q`Boogie.add_expr => return bv32AddOp - | .some .bv32, q`Boogie.sub_expr => return bv32SubOp - | .some .bv32, q`Boogie.mul_expr => return bv32MulOp - | .some .bv32, q`Boogie.div_expr => return bv32UDivOp - | .some .bv32, q`Boogie.mod_expr => return bv32UModOp - | .some .bv32, q`Boogie.bvsdiv => return bv32SDivOp - | .some .bv32, q`Boogie.bvsmod => return bv32SModOp - | .some .bv32, q`Boogie.bvnot => return bv32NotOp - | .some .bv32, q`Boogie.bvand => return bv32AndOp - | .some .bv32, q`Boogie.bvor => return bv32OrOp - | .some .bv32, q`Boogie.bvxor => return bv32XorOp - | .some .bv32, q`Boogie.bvshl => return bv32ShlOp - | .some .bv32, q`Boogie.bvushr => return bv32UShrOp - | .some .bv32, q`Boogie.bvsshr => return bv32SShrOp - - | .some .bv64, q`Boogie.le => return bv64ULeOp - | .some .bv64, q`Boogie.lt => return bv64ULtOp - | .some .bv64, q`Boogie.ge => return bv64UGeOp - | .some .bv64, q`Boogie.gt => return bv64UGtOp - | .some .bv64, q`Boogie.bvsle => return bv64SLeOp - | .some .bv64, q`Boogie.bvslt => return bv64SLtOp - | .some .bv64, q`Boogie.bvsge => return bv64SGeOp - | .some .bv64, q`Boogie.bvsgt => return bv64SGtOp - | .some .bv64, q`Boogie.neg_expr => return bv64NegOp - | .some .bv64, q`Boogie.add_expr => return bv64AddOp - | .some .bv64, q`Boogie.sub_expr => return bv64SubOp - | .some .bv64, q`Boogie.mul_expr => return bv64MulOp - | .some .bv64, q`Boogie.div_expr => return bv64UDivOp - | .some .bv64, q`Boogie.mod_expr => return bv64UModOp - | .some .bv64, q`Boogie.bvsdiv => return bv64SDivOp - | .some .bv64, q`Boogie.bvsmod => return bv64SModOp - | .some .bv64, q`Boogie.bvnot => return bv64NotOp - | .some .bv64, q`Boogie.bvand => return bv64AndOp - | .some .bv64, q`Boogie.bvor => return bv64OrOp - | .some .bv64, q`Boogie.bvxor => return bv64XorOp - | .some .bv64, q`Boogie.bvshl => return bv64ShlOp - | .some .bv64, q`Boogie.bvushr => return bv64UShrOp - | .some .bv64, q`Boogie.bvsshr => return bv64SShrOp - - | _, q`Boogie.bvconcat8 => return bv8ConcatOp - | _, q`Boogie.bvconcat16 => return bv16ConcatOp - | _, q`Boogie.bvconcat32 => return bv32ConcatOp - | _, q`Boogie.bvextract_7_7 => return bv8Extract_7_7_Op - | _, q`Boogie.bvextract_15_15 => return bv16Extract_15_15_Op - | _, q`Boogie.bvextract_31_31 => return bv32Extract_31_31_Op - | _, q`Boogie.bvextract_7_0_16 => return bv16Extract_7_0_Op - | _, q`Boogie.bvextract_7_0_32 => return bv32Extract_7_0_Op - | _, q`Boogie.bvextract_15_0_32 => return bv32Extract_15_0_Op - | _, q`Boogie.bvextract_7_0_64 => return bv64Extract_7_0_Op - | _, q`Boogie.bvextract_15_0_64 => return bv64Extract_15_0_Op - | _, q`Boogie.bvextract_31_0_64 => return bv64Extract_31_0_Op - - | _, q`Boogie.old => return polyOldOp - | _, q`Boogie.str_len => return strLengthOp - | _, q`Boogie.str_concat => return strConcatOp - | _, q`Boogie.str_substr => return strSubstrOp - | _, q`Boogie.str_toregex => return strToRegexOp - | _, q`Boogie.str_inregex => return strInRegexOp - | _, q`Boogie.re_all => return reAllOp - | _, q`Boogie.re_allchar => return reAllCharOp - | _, q`Boogie.re_range => return reRangeOp - | _, q`Boogie.re_concat => return reConcatOp - | _, q`Boogie.re_star => return reStarOp - | _, q`Boogie.re_plus => return rePlusOp - | _, q`Boogie.re_loop => return reLoopOp - | _, q`Boogie.re_union => return reUnionOp - | _, q`Boogie.re_inter => return reInterOp - | _, q`Boogie.re_comp => return reCompOp - | _, q`Boogie.re_none => return reNoneOp + | _, q`Core.equiv => return boolEquivOp + | _, q`Core.implies => return boolImpliesOp + | _, q`Core.and => return boolAndOp + | _, q`Core.or => return boolOrOp + | _, q`Core.not => return boolNotOp + + | .some .int, q`Core.le => return intLeOp + | .some .int, q`Core.lt => return intLtOp + | .some .int, q`Core.ge => return intGeOp + | .some .int, q`Core.gt => return intGtOp + | .some .int, q`Core.add_expr => return intAddOp + | .some .int, q`Core.sub_expr => return intSubOp + | .some .int, q`Core.mul_expr => return intMulOp + | .some .int, q`Core.div_expr => return intDivOp + | .some .int, q`Core.mod_expr => return intModOp + | .some .int, q`Core.neg_expr => return intNegOp + + | .some .real, q`Core.le => return realLeOp + | .some .real, q`Core.lt => return realLtOp + | .some .real, q`Core.ge => return realGeOp + | .some .real, q`Core.gt => return realGtOp + | .some .real, q`Core.add_expr => return realAddOp + | .some .real, q`Core.sub_expr => return realSubOp + | .some .real, q`Core.mul_expr => return realMulOp + | .some .real, q`Core.div_expr => return realDivOp + | .some .real, q`Core.neg_expr => return realNegOp + + | .some .bv1, q`Core.le => return bv1ULeOp + | .some .bv1, q`Core.lt => return bv1ULtOp + | .some .bv1, q`Core.ge => return bv1UGeOp + | .some .bv1, q`Core.gt => return bv1UGtOp + | .some .bv1, q`Core.bvsle => return bv1SLeOp + | .some .bv1, q`Core.bvslt => return bv1SLtOp + | .some .bv1, q`Core.bvsge => return bv1SGeOp + | .some .bv1, q`Core.bvsgt => return bv1SGtOp + | .some .bv1, q`Core.neg_expr => return bv1NegOp + | .some .bv1, q`Core.add_expr => return bv1AddOp + | .some .bv1, q`Core.sub_expr => return bv1SubOp + | .some .bv1, q`Core.mul_expr => return bv1MulOp + | .some .bv1, q`Core.div_expr => return bv1UDivOp + | .some .bv1, q`Core.mod_expr => return bv1UModOp + | .some .bv1, q`Core.bvsdiv => return bv1SDivOp + | .some .bv1, q`Core.bvsmod => return bv1SModOp + | .some .bv1, q`Core.bvnot => return bv1NotOp + | .some .bv1, q`Core.bvand => return bv1AndOp + | .some .bv1, q`Core.bvor => return bv1OrOp + | .some .bv1, q`Core.bvxor => return bv1XorOp + | .some .bv1, q`Core.bvshl => return bv1ShlOp + | .some .bv1, q`Core.bvushr => return bv1UShrOp + | .some .bv1, q`Core.bvsshr => return bv1SShrOp + + | .some .bv8, q`Core.le => return bv8ULeOp + | .some .bv8, q`Core.lt => return bv8ULtOp + | .some .bv8, q`Core.ge => return bv8UGeOp + | .some .bv8, q`Core.gt => return bv8UGtOp + | .some .bv8, q`Core.bvsle => return bv8SLeOp + | .some .bv8, q`Core.bvslt => return bv8SLtOp + | .some .bv8, q`Core.bvsge => return bv8SGeOp + | .some .bv8, q`Core.bvsgt => return bv8SGtOp + | .some .bv8, q`Core.neg_expr => return bv8NegOp + | .some .bv8, q`Core.add_expr => return bv8AddOp + | .some .bv8, q`Core.sub_expr => return bv8SubOp + | .some .bv8, q`Core.mul_expr => return bv8MulOp + | .some .bv8, q`Core.div_expr => return bv8UDivOp + | .some .bv8, q`Core.mod_expr => return bv8UModOp + | .some .bv8, q`Core.bvsdiv => return bv8SDivOp + | .some .bv8, q`Core.bvsmod => return bv8SModOp + | .some .bv8, q`Core.bvnot => return bv8NotOp + | .some .bv8, q`Core.bvand => return bv8AndOp + | .some .bv8, q`Core.bvor => return bv8OrOp + | .some .bv8, q`Core.bvxor => return bv8XorOp + | .some .bv8, q`Core.bvshl => return bv8ShlOp + | .some .bv8, q`Core.bvushr => return bv8UShrOp + | .some .bv8, q`Core.bvsshr => return bv8SShrOp + + | .some .bv16, q`Core.le => return bv16ULeOp + | .some .bv16, q`Core.lt => return bv16ULtOp + | .some .bv16, q`Core.ge => return bv16UGeOp + | .some .bv16, q`Core.gt => return bv16UGtOp + | .some .bv16, q`Core.bvsle => return bv16SLeOp + | .some .bv16, q`Core.bvslt => return bv16SLtOp + | .some .bv16, q`Core.bvsge => return bv16SGeOp + | .some .bv16, q`Core.bvsgt => return bv16SGtOp + | .some .bv16, q`Core.neg_expr => return bv16NegOp + | .some .bv16, q`Core.add_expr => return bv16AddOp + | .some .bv16, q`Core.sub_expr => return bv16SubOp + | .some .bv16, q`Core.mul_expr => return bv16MulOp + | .some .bv16, q`Core.div_expr => return bv16UDivOp + | .some .bv16, q`Core.mod_expr => return bv16UModOp + | .some .bv16, q`Core.bvsdiv => return bv16SDivOp + | .some .bv16, q`Core.bvsmod => return bv16SModOp + | .some .bv16, q`Core.bvnot => return bv16NotOp + | .some .bv16, q`Core.bvand => return bv16AndOp + | .some .bv16, q`Core.bvor => return bv16OrOp + | .some .bv16, q`Core.bvxor => return bv16XorOp + | .some .bv16, q`Core.bvshl => return bv16ShlOp + | .some .bv16, q`Core.bvushr => return bv16UShrOp + | .some .bv16, q`Core.bvsshr => return bv16SShrOp + + | .some .bv32, q`Core.le => return bv32ULeOp + | .some .bv32, q`Core.lt => return bv32ULtOp + | .some .bv32, q`Core.ge => return bv32UGeOp + | .some .bv32, q`Core.gt => return bv32UGtOp + | .some .bv32, q`Core.bvsle => return bv32SLeOp + | .some .bv32, q`Core.bvslt => return bv32SLtOp + | .some .bv32, q`Core.bvsge => return bv32SGeOp + | .some .bv32, q`Core.bvsgt => return bv32SGtOp + | .some .bv32, q`Core.neg_expr => return bv32NegOp + | .some .bv32, q`Core.add_expr => return bv32AddOp + | .some .bv32, q`Core.sub_expr => return bv32SubOp + | .some .bv32, q`Core.mul_expr => return bv32MulOp + | .some .bv32, q`Core.div_expr => return bv32UDivOp + | .some .bv32, q`Core.mod_expr => return bv32UModOp + | .some .bv32, q`Core.bvsdiv => return bv32SDivOp + | .some .bv32, q`Core.bvsmod => return bv32SModOp + | .some .bv32, q`Core.bvnot => return bv32NotOp + | .some .bv32, q`Core.bvand => return bv32AndOp + | .some .bv32, q`Core.bvor => return bv32OrOp + | .some .bv32, q`Core.bvxor => return bv32XorOp + | .some .bv32, q`Core.bvshl => return bv32ShlOp + | .some .bv32, q`Core.bvushr => return bv32UShrOp + | .some .bv32, q`Core.bvsshr => return bv32SShrOp + + | .some .bv64, q`Core.le => return bv64ULeOp + | .some .bv64, q`Core.lt => return bv64ULtOp + | .some .bv64, q`Core.ge => return bv64UGeOp + | .some .bv64, q`Core.gt => return bv64UGtOp + | .some .bv64, q`Core.bvsle => return bv64SLeOp + | .some .bv64, q`Core.bvslt => return bv64SLtOp + | .some .bv64, q`Core.bvsge => return bv64SGeOp + | .some .bv64, q`Core.bvsgt => return bv64SGtOp + | .some .bv64, q`Core.neg_expr => return bv64NegOp + | .some .bv64, q`Core.add_expr => return bv64AddOp + | .some .bv64, q`Core.sub_expr => return bv64SubOp + | .some .bv64, q`Core.mul_expr => return bv64MulOp + | .some .bv64, q`Core.div_expr => return bv64UDivOp + | .some .bv64, q`Core.mod_expr => return bv64UModOp + | .some .bv64, q`Core.bvsdiv => return bv64SDivOp + | .some .bv64, q`Core.bvsmod => return bv64SModOp + | .some .bv64, q`Core.bvnot => return bv64NotOp + | .some .bv64, q`Core.bvand => return bv64AndOp + | .some .bv64, q`Core.bvor => return bv64OrOp + | .some .bv64, q`Core.bvxor => return bv64XorOp + | .some .bv64, q`Core.bvshl => return bv64ShlOp + | .some .bv64, q`Core.bvushr => return bv64UShrOp + | .some .bv64, q`Core.bvsshr => return bv64SShrOp + + | _, q`Core.bvconcat8 => return bv8ConcatOp + | _, q`Core.bvconcat16 => return bv16ConcatOp + | _, q`Core.bvconcat32 => return bv32ConcatOp + | _, q`Core.bvextract_7_7 => return bv8Extract_7_7_Op + | _, q`Core.bvextract_15_15 => return bv16Extract_15_15_Op + | _, q`Core.bvextract_31_31 => return bv32Extract_31_31_Op + | _, q`Core.bvextract_7_0_16 => return bv16Extract_7_0_Op + | _, q`Core.bvextract_7_0_32 => return bv32Extract_7_0_Op + | _, q`Core.bvextract_15_0_32 => return bv32Extract_15_0_Op + | _, q`Core.bvextract_7_0_64 => return bv64Extract_7_0_Op + | _, q`Core.bvextract_15_0_64 => return bv64Extract_15_0_Op + | _, q`Core.bvextract_31_0_64 => return bv64Extract_31_0_Op + + | _, q`Core.old => return polyOldOp + | _, q`Core.str_len => return strLengthOp + | _, q`Core.str_concat => return strConcatOp + | _, q`Core.str_substr => return strSubstrOp + | _, q`Core.str_toregex => return strToRegexOp + | _, q`Core.str_inregex => return strInRegexOp + | _, q`Core.re_all => return reAllOp + | _, q`Core.re_allchar => return reAllCharOp + | _, q`Core.re_range => return reRangeOp + | _, q`Core.re_concat => return reConcatOp + | _, q`Core.re_star => return reStarOp + | _, q`Core.re_plus => return rePlusOp + | _, q`Core.re_loop => return reLoopOp + | _, q`Core.re_union => return reUnionOp + | _, q`Core.re_inter => return reInterOp + | _, q`Core.re_comp => return reCompOp + | _, q`Core.re_none => return reNoneOp | _, _ => TransM.error s!"translateFn: Unknown/unimplemented function {repr q} at type {repr ty?}" mutual @@ -621,7 +621,7 @@ def translateQuantifier (qk: QuantifierKind) (p : Program) (bindings : TransBindings) (xsa : Arg) (triggersa: Option Arg) (bodya: Arg) : - TransM Boogie.Expression.Expr := do + TransM Core.Expression.Expr := do let xsArray ← translateDeclList bindings xsa -- Note: the indices in the following are placeholders let newBoundVars := List.toArray (xsArray.mapIdx (fun i _ => LExpr.bvar () i)) @@ -650,139 +650,139 @@ def translateQuantifier partial def translateTriggerGroup (p: Program) (bindings : TransBindings) (arg : Arg) : - TransM Boogie.Expression.Expr := do + TransM Core.Expression.Expr := do let .op op := arg | TransM.error s!"translateTriggerGroup expected op, got {repr arg}" match op.name, op.args with - | q`Boogie.trigger, #[tsa] => do + | q`Core.trigger, #[tsa] => do let ts ← translateCommaSep (fun t => translateExpr p bindings t) tsa return ts.foldl (fun g t => .app () (.app () addTriggerOp t) g) emptyTriggerGroupOp | _, _ => panic! s!"Unexpected operator in trigger group" partial def translateTriggers (p: Program) (bindings : TransBindings) (arg : Arg) : - TransM Boogie.Expression.Expr := do + TransM Core.Expression.Expr := do let .op op := arg | TransM.error s!"translateTriggers expected op, got: {repr arg}" match op.name, op.args with - | q`Boogie.triggersAtom, #[group] => + | q`Core.triggersAtom, #[group] => let g ← translateTriggerGroup p bindings group return .app () (.app () addTriggerGroupOp g) emptyTriggersOp - | q`Boogie.triggersPush, #[triggers, group] => do + | q`Core.triggersPush, #[triggers, group] => do let ts ← translateTriggers p bindings triggers let g ← translateTriggerGroup p bindings group return .app () (.app () addTriggerGroupOp g) ts | _, _ => panic! s!"Unexpected operator in trigger" partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : - TransM Boogie.Expression.Expr := do + TransM Core.Expression.Expr := do let .expr expr := arg | TransM.error s!"translateExpr expected expr {repr arg}" let (op, args) := expr.flatten match op, args with -- Constants/Literals - | .fn _ q`Boogie.btrue, [] => + | .fn _ q`Core.btrue, [] => return .true () - | .fn _ q`Boogie.bfalse, [] => + | .fn _ q`Core.bfalse, [] => return .false () - | .fn _ q`Boogie.natToInt, [xa] => + | .fn _ q`Core.natToInt, [xa] => let n ← translateNat xa return .intConst () n - | .fn _ q`Boogie.bv1Lit, [xa] => + | .fn _ q`Core.bv1Lit, [xa] => let n ← translateBitVec 1 xa return .bitvecConst () 1 n - | .fn _ q`Boogie.bv8Lit, [xa] => + | .fn _ q`Core.bv8Lit, [xa] => let n ← translateBitVec 8 xa return .bitvecConst () 8 n - | .fn _ q`Boogie.bv16Lit, [xa] => + | .fn _ q`Core.bv16Lit, [xa] => let n ← translateBitVec 16 xa return .bitvecConst () 16 n - | .fn _ q`Boogie.bv32Lit, [xa] => + | .fn _ q`Core.bv32Lit, [xa] => let n ← translateBitVec 32 xa return .bitvecConst () 32 n - | .fn _ q`Boogie.bv64Lit, [xa] => + | .fn _ q`Core.bv64Lit, [xa] => let n ← translateBitVec 64 xa return .bitvecConst () 64 n - | .fn _ q`Boogie.strLit, [xa] => + | .fn _ q`Core.strLit, [xa] => let x ← translateStr xa return .strConst () x - | .fn _ q`Boogie.realLit, [xa] => + | .fn _ q`Core.realLit, [xa] => let x ← translateReal xa return .realConst () (Strata.Decimal.toRat x) -- Equality - | .fn _ q`Boogie.equal, [_tpa, xa, ya] => + | .fn _ q`Core.equal, [_tpa, xa, ya] => let x ← translateExpr p bindings xa let y ← translateExpr p bindings ya return .eq () x y - | .fn _ q`Boogie.not_equal, [_tpa, xa, ya] => + | .fn _ q`Core.not_equal, [_tpa, xa, ya] => let x ← translateExpr p bindings xa let y ← translateExpr p bindings ya - return (.app () Boogie.boolNotOp (.eq () x y)) - | .fn _ q`Boogie.bvnot, [tpa, xa] => + return (.app () Core.boolNotOp (.eq () x y)) + | .fn _ q`Core.bvnot, [tpa, xa] => let tp ← translateLMonoTy bindings (dealiasTypeArg p tpa) let x ← translateExpr p bindings xa let fn : LExpr BoogieLParams.mono ← - translateFn (.some tp) q`Boogie.bvnot + translateFn (.some tp) q`Core.bvnot return (.app () fn x) -- If-then-else expression - | .fn _ q`Boogie.if, [_tpa, ca, ta, fa] => + | .fn _ q`Core.if, [_tpa, ca, ta, fa] => let c ← translateExpr p bindings ca let t ← translateExpr p bindings ta let f ← translateExpr p bindings fa return .ite () c t f -- Re.AllChar - | .fn _ q`Boogie.re_allchar, [] => - let fn ← translateFn .none q`Boogie.re_allchar + | .fn _ q`Core.re_allchar, [] => + let fn ← translateFn .none q`Core.re_allchar return fn -- Re.None - | .fn _ q`Boogie.re_none, [] => - let fn ← translateFn .none q`Boogie.re_none + | .fn _ q`Core.re_none, [] => + let fn ← translateFn .none q`Core.re_none return fn -- Re.All - | .fn _ q`Boogie.re_all, [] => - let fn ← translateFn .none q`Boogie.re_all + | .fn _ q`Core.re_all, [] => + let fn ← translateFn .none q`Core.re_all return fn -- Unary function applications | .fn _ fni, [xa] => match fni with - | q`Boogie.not - | q`Boogie.bvextract_7_7 - | q`Boogie.bvextract_15_15 - | q`Boogie.bvextract_31_31 - | q`Boogie.bvextract_7_0_16 - | q`Boogie.bvextract_7_0_32 - | q`Boogie.bvextract_15_0_32 - | q`Boogie.bvextract_7_0_64 - | q`Boogie.bvextract_15_0_64 - | q`Boogie.bvextract_31_0_64 - | q`Boogie.str_len - | q`Boogie.str_toregex - | q`Boogie.re_star - | q`Boogie.re_plus - | q`Boogie.re_comp => do + | q`Core.not + | q`Core.bvextract_7_7 + | q`Core.bvextract_15_15 + | q`Core.bvextract_31_31 + | q`Core.bvextract_7_0_16 + | q`Core.bvextract_7_0_32 + | q`Core.bvextract_15_0_32 + | q`Core.bvextract_7_0_64 + | q`Core.bvextract_15_0_64 + | q`Core.bvextract_31_0_64 + | q`Core.str_len + | q`Core.str_toregex + | q`Core.re_star + | q`Core.re_plus + | q`Core.re_comp => do let fn ← translateFn .none fni let x ← translateExpr p bindings xa return .mkApp () fn [x] | _ => TransM.error s!"translateExpr unimplemented {repr op} {repr args}" - | .fn _ q`Boogie.neg_expr, [tpa, xa] => + | .fn _ q`Core.neg_expr, [tpa, xa] => let ty ← translateLMonoTy bindings (dealiasTypeArg p tpa) - let fn ← translateFn ty q`Boogie.neg_expr + let fn ← translateFn ty q`Core.neg_expr let x ← translateExpr p bindings xa return .mkApp () fn [x] -- Strings - | .fn _ q`Boogie.str_concat, [xa, ya] => + | .fn _ q`Core.str_concat, [xa, ya] => let x ← translateExpr p bindings xa let y ← translateExpr p bindings ya - return .mkApp () Boogie.strConcatOp [x, y] - | .fn _ q`Boogie.str_substr, [xa, ia, na] => + return .mkApp () Core.strConcatOp [x, y] + | .fn _ q`Core.str_substr, [xa, ia, na] => let x ← translateExpr p bindings xa let i ← translateExpr p bindings ia let n ← translateExpr p bindings na - return .mkApp () Boogie.strSubstrOp [x, i, n] - | .fn _ q`Boogie.old, [_tp, xa] => + return .mkApp () Core.strSubstrOp [x, i, n] + | .fn _ q`Core.old, [_tp, xa] => let x ← translateExpr p bindings xa - return .mkApp () Boogie.polyOldOp [x] - | .fn _ q`Boogie.map_get, [_ktp, _vtp, ma, ia] => + return .mkApp () Core.polyOldOp [x] + | .fn _ q`Core.map_get, [_ktp, _vtp, ma, ia] => let kty ← translateLMonoTy bindings _ktp let vty ← translateLMonoTy bindings _vtp -- TODO: use Boogie.mapSelectOp, but specialized @@ -790,7 +790,7 @@ partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : let m ← translateExpr p bindings ma let i ← translateExpr p bindings ia return .mkApp () fn [m, i] - | .fn _ q`Boogie.map_set, [_ktp, _vtp, ma, ia, xa] => + | .fn _ q`Core.map_set, [_ktp, _vtp, ma, ia, xa] => let kty ← translateLMonoTy bindings _ktp let vty ← translateLMonoTy bindings _vtp -- TODO: use Boogie.mapUpdateOp, but specialized @@ -800,13 +800,13 @@ partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : let x ← translateExpr p bindings xa return .mkApp () fn [m, i, x] -- Quantifiers - | .fn _ q`Boogie.forall, [xsa, ba] => + | .fn _ q`Core.forall, [xsa, ba] => translateQuantifier .all p bindings xsa .none ba - | .fn _ q`Boogie.exists, [xsa, ba] => + | .fn _ q`Core.exists, [xsa, ba] => translateQuantifier .exist p bindings xsa .none ba - | .fn _ q`Boogie.forallT, [xsa, tsa, ba] => + | .fn _ q`Core.forallT, [xsa, tsa, ba] => translateQuantifier .all p bindings xsa (.some tsa) ba - | .fn _ q`Boogie.existsT, [xsa, tsa, ba] => + | .fn _ q`Core.existsT, [xsa, tsa, ba] => translateQuantifier .exist p bindings xsa (.some tsa) ba -- Binary function applications (monomorphic) | .fn _ fni, [xa, ya] => @@ -814,8 +814,8 @@ partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : let x ← translateExpr p bindings xa let y ← translateExpr p bindings ya return .mkApp () fn [x, y] - | .fn _ q`Boogie.re_loop, [xa, ya, za] => - let fn ← translateFn .none q`Boogie.re_loop + | .fn _ q`Core.re_loop, [xa, ya, za] => + let fn ← translateFn .none q`Core.re_loop let x ← translateExpr p bindings xa let y ← translateExpr p bindings ya let z ← translateExpr p bindings za @@ -823,27 +823,27 @@ partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : -- Binary function applications (polymorphic) | .fn _ fni, [tpa, xa, ya] => match fni with - | q`Boogie.add_expr - | q`Boogie.sub_expr - | q`Boogie.mul_expr - | q`Boogie.div_expr - | q`Boogie.mod_expr - | q`Boogie.bvand - | q`Boogie.bvor - | q`Boogie.bvxor - | q`Boogie.bvshl - | q`Boogie.bvushr - | q`Boogie.bvsshr - | q`Boogie.bvsdiv - | q`Boogie.bvsmod - | q`Boogie.le - | q`Boogie.lt - | q`Boogie.gt - | q`Boogie.ge - | q`Boogie.bvsle - | q`Boogie.bvslt - | q`Boogie.bvsgt - | q`Boogie.bvsge => + | q`Core.add_expr + | q`Core.sub_expr + | q`Core.mul_expr + | q`Core.div_expr + | q`Core.mod_expr + | q`Core.bvand + | q`Core.bvor + | q`Core.bvxor + | q`Core.bvshl + | q`Core.bvushr + | q`Core.bvsshr + | q`Core.bvsdiv + | q`Core.bvsmod + | q`Core.le + | q`Core.lt + | q`Core.gt + | q`Core.ge + | q`Core.bvsle + | q`Core.bvslt + | q`Core.bvsgt + | q`Core.bvsge => let ty ← translateLMonoTy bindings (dealiasTypeArg p tpa) if ¬ isArithTy ty then TransM.error s!"translateExpr unexpected type for {repr fni}: {repr args}" @@ -895,7 +895,7 @@ partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : Bindings: {format bindings}}" partial def translateExprs (p : Program) (bindings : TransBindings) (args : Array Arg) : - TransM (Array Boogie.Expression.Expr) := + TransM (Array Core.Expression.Expr) := args.mapM (fun a => translateExpr p bindings a) end @@ -904,22 +904,22 @@ end def translateInvariant (p : Program) (bindings : TransBindings) (arg : Arg) : TransM (Option Expression.Expr) := do match arg with | .option _ (.some m) => do - let args ← checkOpArg m q`Boogie.invariant 1 + let args ← checkOpArg m q`Core.invariant 1 translateExpr p bindings args[0]! | _ => pure none def initVarStmts (tpids : ListMap Expression.Ident LTy) (bindings : TransBindings) : - TransM ((List Boogie.Statement) × TransBindings) := do + TransM ((List Core.Statement) × TransBindings) := do match tpids with | [] => return ([], bindings) | (id, tp) :: rest => - let s := Boogie.Statement.init id tp (Names.initVarValue (id.name ++ "_" ++ (toString bindings.gen.var_def))) + let s := Core.Statement.init id tp (Names.initVarValue (id.name ++ "_" ++ (toString bindings.gen.var_def))) let bindings := incrNum .var_def bindings let (stmts, bindings) ← initVarStmts rest bindings return ((s :: stmts), bindings) def translateVarStatement (bindings : TransBindings) (decls : Array Arg) : - TransM ((List Boogie.Statement) × TransBindings) := do + TransM ((List Core.Statement) × TransBindings) := do if decls.size != 1 then TransM.error s!"translateVarStatement unexpected decls length {repr decls}" else @@ -934,7 +934,7 @@ def translateVarStatement (bindings : TransBindings) (decls : Array Arg) : return (stmts, { bindings with boundVars := bbindings }) def translateInitStatement (p : Program) (bindings : TransBindings) (args : Array Arg) : - TransM ((List Boogie.Statement) × TransBindings) := do + TransM ((List Core.Statement) × TransBindings) := do if args.size != 3 then TransM.error "translateInitStatement unexpected arg length {repr decls}" else @@ -948,82 +948,82 @@ def translateInitStatement (p : Program) (bindings : TransBindings) (args : Arra mutual partial def translateStmt (p : Program) (bindings : TransBindings) (arg : Arg) : - TransM (List Boogie.Statement × TransBindings) := do + TransM (List Core.Statement × TransBindings) := do let .op op := arg | TransM.error s!"translateStmt expected op {repr arg}" match op.name, op.args with - | q`Boogie.varStatement, declsa => + | q`Core.varStatement, declsa => translateVarStatement bindings declsa - | q`Boogie.initStatement, args => + | q`Core.initStatement, args => translateInitStatement p bindings args - | q`Boogie.assign, #[_tpa, lhsa, ea] => + | q`Core.assign, #[_tpa, lhsa, ea] => let lhs ← translateLhs lhsa let val ← translateExpr p bindings ea let md ← getOpMetaData op return ([.set lhs val md], bindings) - | q`Boogie.havoc_statement, #[ida] => + | q`Core.havoc_statement, #[ida] => let id ← translateIdent BoogieIdent ida let md ← getOpMetaData op return ([.havoc id md], bindings) - | q`Boogie.assert, #[la, ca] => + | q`Core.assert, #[la, ca] => let c ← translateExpr p bindings ca let default_name := s!"assert_{bindings.gen.assert_def}" let bindings := incrNum .assert_def bindings let l ← translateOptionLabel default_name la let md ← getOpMetaData op return ([.assert l c md], bindings) - | q`Boogie.cover, #[la, ca] => + | q`Core.cover, #[la, ca] => let c ← translateExpr p bindings ca let default_name := s!"cover_{bindings.gen.assert_def}" let bindings := incrNum .cover_def bindings let l ← translateOptionLabel default_name la let md ← getOpMetaData op return ([.cover l c md], bindings) - | q`Boogie.assume, #[la, ca] => + | q`Core.assume, #[la, ca] => let c ← translateExpr p bindings ca let default_name := s!"assume_{bindings.gen.assume_def}" let bindings := incrNum .assume_def bindings let l ← translateOptionLabel default_name la let md ← getOpMetaData op return ([.assume l c md], bindings) - | q`Boogie.if_statement, #[ca, ta, fa] => + | q`Core.if_statement, #[ca, ta, fa] => let c ← translateExpr p bindings ca let (tss, bindings) ← translateBlock p bindings ta let (fss, bindings) ← translateElse p bindings fa let md ← getOpMetaData op return ([.ite c tss fss md], bindings) - | q`Boogie.while_statement, #[ca, ia, ba] => + | q`Core.while_statement, #[ca, ia, ba] => let c ← translateExpr p bindings ca let i ← translateInvariant p bindings ia let (bodyss, bindings) ← translateBlock p bindings ba let md ← getOpMetaData op return ([.loop c .none i bodyss md], bindings) - | q`Boogie.call_statement, #[lsa, fa, esa] => + | q`Core.call_statement, #[lsa, fa, esa] => let ls ← translateCommaSep (translateIdent BoogieIdent) lsa let f ← translateIdent String fa let es ← translateCommaSep (fun a => translateExpr p bindings a) esa let md ← getOpMetaData op return ([.call ls.toList f es.toList md], bindings) - | q`Boogie.call_unit_statement, #[fa, esa] => + | q`Core.call_unit_statement, #[fa, esa] => let f ← translateIdent String fa let es ← translateCommaSep (fun a => translateExpr p bindings a) esa let md ← getOpMetaData op return ([.call [] f es.toList md], bindings) - | q`Boogie.block_statement, #[la, ba] => + | q`Core.block_statement, #[la, ba] => let l ← translateIdent String la let (ss, bindings) ← translateBlock p bindings ba let md ← getOpMetaData op return ([.block l ss md], bindings) - | q`Boogie.goto_statement, #[la] => + | q`Core.goto_statement, #[la] => let l ← translateIdent String la let md ← getOpMetaData op return ([.goto l md], bindings) | name, args => TransM.error s!"Unexpected statement {name.fullName} with {args.size} arguments." partial def translateBlock (p : Program) (bindings : TransBindings) (arg : Arg) : - TransM ((List Boogie.Statement) × TransBindings) := do - let args ← checkOpArg arg q`Boogie.block 1 + TransM ((List Core.Statement) × TransBindings) := do + let args ← checkOpArg arg q`Core.block 1 let .seq _ .none stmts := args[0]! | TransM.error s!"Invalid block {repr args[0]!}" let (a, bindings) ← stmts.foldlM (init := (#[], bindings)) fun (a, b) s => do @@ -1032,15 +1032,15 @@ partial def translateBlock (p : Program) (bindings : TransBindings) (arg : Arg) return (a.toList, bindings) partial def translateElse (p : Program) (bindings : TransBindings) (arg : Arg) : - TransM ((List Boogie.Statement) × TransBindings) := do + TransM ((List Core.Statement) × TransBindings) := do let .op op := arg | TransM.error s!"translateElse expected op {repr arg}" match op.name with - | q`Boogie.else0 => - let _ ← checkOpArg arg q`Boogie.else0 0 + | q`Core.else0 => + let _ ← checkOpArg arg q`Core.else0 0 return ([], bindings) - | q`Boogie.else1 => - let args ← checkOpArg arg q`Boogie.else1 1 + | q`Core.else1 => + let args ← checkOpArg arg q`Core.else1 1 translateBlock p bindings args[0]! | _ => TransM.error s!"translateElse unimplemented for {repr arg}" @@ -1051,7 +1051,7 @@ end def translateInitMkBinding (bindings : TransBindings) (op : Arg) : TransM (BoogieIdent × LMonoTy) := do -- (FIXME) Account for metadata. - let bargs ← checkOpArg op q`Boogie.mkBinding 2 + let bargs ← checkOpArg op q`Core.mkBinding 2 let id ← translateIdent BoogieIdent bargs[0]! let tp ← translateLMonoTy bindings bargs[1]! return (id, tp) @@ -1062,7 +1062,7 @@ def translateInitMkBindings (bindings : TransBindings) (ops : Array Arg) : def translateBindings (bindings : TransBindings) (op : Arg) : TransM (ListMap BoogieIdent LMonoTy) := do - let bargs ← checkOpArg op q`Boogie.mkBindings 1 + let bargs ← checkOpArg op q`Core.mkBindings 1 match bargs[0]! with | .seq _ .comma args => let arr ← translateInitMkBindings bindings args @@ -1071,7 +1071,7 @@ def translateBindings (bindings : TransBindings) (op : Arg) : TransM.error s!"translateBindings expects a comma separated list: {repr op}" def translateModifies (arg : Arg) : TransM BoogieIdent := do - let args ← checkOpArg arg q`Boogie.modifies_spec 1 + let args ← checkOpArg arg q`Core.modifies_spec 1 translateIdent BoogieIdent args[0]! def translateOptionFree (arg : Arg) : TransM Procedure.CheckAttr := do @@ -1079,13 +1079,13 @@ def translateOptionFree (arg : Arg) : TransM Procedure.CheckAttr := do | TransM.error s!"translateOptionFree unexpected {repr arg}" match free with | some f => - let _ ← checkOpArg f q`Boogie.free 0 + let _ ← checkOpArg f q`Core.free 0 return .Free | none => return .Default def translateRequires (p : Program) (name : BoogieIdent) (count : Nat) (bindings : TransBindings) (arg : Arg) : TransM (ListMap BoogieLabel Procedure.Check) := do - let args ← checkOpArg arg q`Boogie.requires_spec 3 + let args ← checkOpArg arg q`Core.requires_spec 3 let l ← translateOptionLabel s!"{name.name}_requires_{count}" args[0]! let free? ← translateOptionFree args[1]! let e ← translateExpr p bindings args[2]! @@ -1094,7 +1094,7 @@ def translateRequires (p : Program) (name : BoogieIdent) (count : Nat) (bindings def translateEnsures (p : Program) (name : BoogieIdent) (count : Nat) (bindings : TransBindings) (arg : Arg) : TransM (ListMap BoogieLabel Procedure.Check) := do - let args ← checkOpArg arg q`Boogie.ensures_spec 3 + let args ← checkOpArg arg q`Core.ensures_spec 3 let l ← translateOptionLabel s!"{name.name}_ensures_{count}" args[0]! let free? ← translateOptionFree args[1]! let e ← translateExpr p bindings args[2]! @@ -1106,13 +1106,13 @@ def translateSpecElem (p : Program) (name : BoogieIdent) (count : Nat) (bindings let .op op := arg | TransM.error s!"translateSpecElem expects an op {repr arg}" match op.name with - | q`Boogie.modifies_spec => + | q`Core.modifies_spec => let elem ← translateModifies arg return ([elem], [], []) - | q`Boogie.requires_spec => + | q`Core.requires_spec => let elem ← translateRequires p name count bindings arg return ([], elem, []) - | q`Boogie.ensures_spec => + | q`Core.ensures_spec => let elem ← translateEnsures p name count bindings arg return ([], [], elem) | _ => @@ -1120,7 +1120,7 @@ def translateSpecElem (p : Program) (name : BoogieIdent) (count : Nat) (bindings partial def translateSpec (p : Program) (name : BoogieIdent) (bindings : TransBindings) (arg : Arg) : TransM (List BoogieIdent × ListMap BoogieLabel Procedure.Check × ListMap BoogieLabel Procedure.Check) := do - let sargs ← checkOpArg arg q`Boogie.spec_mk 1 + let sargs ← checkOpArg arg q`Core.spec_mk 1 let .seq _ .none args := sargs[0]! | TransM.error s!"Invalid specs {repr sargs[0]!}" go 0 args.size args @@ -1134,8 +1134,8 @@ partial def translateSpec (p : Program) (name : BoogieIdent) (bindings : TransBi return (mods ++ restmods, reqs ++ restreqs, ens ++ restens) def translateProcedure (p : Program) (bindings : TransBindings) (op : Operation) : - TransM (Boogie.Decl × TransBindings) := do - let _ ← @checkOp (Boogie.Decl × TransBindings) op q`Boogie.command_procedure 6 + TransM (Core.Decl × TransBindings) := do + let _ ← @checkOp (Core.Decl × TransBindings) op q`Core.command_procedure 6 let pname ← translateIdent BoogieIdent op.args[0]! let typeArgs ← translateTypeArgs op.args[1]! let sig ← translateBindings bindings op.args[2]! @@ -1171,8 +1171,8 @@ def translateProcedure (p : Program) (bindings : TransBindings) (op : Operation) --------------------------------------------------------------------- def translateConstant (bindings : TransBindings) (op : Operation) : - TransM (Boogie.Decl × TransBindings) := do - let _ ← @checkOp (Boogie.Decl × TransBindings) op q`Boogie.command_constdecl 3 + TransM (Core.Decl × TransBindings) := do + let _ ← @checkOp (Core.Decl × TransBindings) op q`Core.command_constdecl 3 let cname ← translateIdent BoogieIdent op.args[0]! let typeArgs ← translateTypeArgs op.args[1]! let ret ← translateLMonoTy bindings op.args[2]! @@ -1188,8 +1188,8 @@ def translateConstant (bindings : TransBindings) (op : Operation) : --------------------------------------------------------------------- def translateAxiom (p : Program) (bindings : TransBindings) (op : Operation) : - TransM (Boogie.Decl × TransBindings) := do - let _ ← @checkOp (Boogie.Decl × TransBindings) op q`Boogie.command_axiom 2 + TransM (Core.Decl × TransBindings) := do + let _ ← @checkOp (Core.Decl × TransBindings) op q`Core.command_axiom 2 let default_name := s!"axiom_{bindings.gen.axiom_def}" let bindings := incrNum .axiom_def bindings let l ← translateOptionLabel default_name op.args[0]! @@ -1198,8 +1198,8 @@ def translateAxiom (p : Program) (bindings : TransBindings) (op : Operation) : return (.ax (Axiom.mk l e) md, bindings) def translateDistinct (p : Program) (bindings : TransBindings) (op : Operation) : - TransM (Boogie.Decl × TransBindings) := do - let _ ← @checkOp (Boogie.Decl × TransBindings) op q`Boogie.command_distinct 2 + TransM (Core.Decl × TransBindings) := do + let _ ← @checkOp (Core.Decl × TransBindings) op q`Core.command_distinct 2 let default_name := s!"axiom_distinct_{bindings.gen.axiom_def}" let bindings := incrNum .axiom_def bindings let l ← translateOptionLabel default_name op.args[0]! @@ -1224,16 +1224,16 @@ def translateOptionInline (arg : Arg) : TransM (Array String) := do | TransM.error s!"translateOptionInline unexpected {repr arg}" match inline with | some f => - let _ ← checkOpArg f q`Boogie.inline 0 + let _ ← checkOpArg f q`Core.inline 0 return #["inline"] | none => return #[] def translateFunction (status : FnInterp) (p : Program) (bindings : TransBindings) (op : Operation) : - TransM (Boogie.Decl × TransBindings) := do + TransM (Core.Decl × TransBindings) := do let _ ← match status with - | .Definition => @checkOp (Boogie.Decl × TransBindings) op q`Boogie.command_fndef 6 - | .Declaration => @checkOp (Boogie.Decl × TransBindings) op q`Boogie.command_fndecl 4 + | .Definition => @checkOp (Core.Decl × TransBindings) op q`Core.command_fndef 6 + | .Declaration => @checkOp (Core.Decl × TransBindings) op q`Core.command_fndecl 4 let fname ← translateIdent BoogieIdent op.args[0]! let typeArgs ← translateTypeArgs op.args[1]! let sig ← translateBindings bindings op.args[2]! @@ -1305,7 +1305,7 @@ def translateConstructorList (p : Program) (bindings : TransBindings) (arg : Arg Translate a datatype declaration to Boogie declarations, updating bindings appropriately. -**Important:** The returned `Boogie.Decls` only contains the type declaration +**Important:** The returned `Core.Decls` only contains the type declaration itself. Factory functions (constructors, testers, destructors) are generated automatically by `Env.addDatatypes` during program evaluation to avoid duplicates. @@ -1316,9 +1316,9 @@ duplicates. - `op`: The `command_datatype` operation to translate -/ def translateDatatype (p : Program) (bindings : TransBindings) (op : Operation) : - TransM (Boogie.Decls × TransBindings) := do + TransM (Core.Decls × TransBindings) := do -- Check operation has correct name and argument count - let _ ← @checkOp (Boogie.Decls × TransBindings) op q`Boogie.command_datatype 3 + let _ ← @checkOp (Core.Decls × TransBindings) op q`Core.command_datatype 3 let datatypeName ← translateIdent String op.args[0]! @@ -1329,7 +1329,7 @@ def translateDatatype (p : Program) (bindings : TransBindings) (op : Operation) do match maybearg with | none => pure ([], bindings) | some arg => - let bargs ← checkOpArg arg q`Boogie.mkBindings 1 + let bargs ← checkOpArg arg q`Core.mkBindings 1 let args ← match bargs[0]! with | .seq _ .comma args => @@ -1347,7 +1347,7 @@ def translateDatatype (p : Program) (bindings : TransBindings) (op : Operation) typeArgs := typeArgs constrs := [{ name := datatypeName, args := [], testerName := "" }] constrs_ne := by simp } - let placeholderDecl := Boogie.Decl.type (.data placeholderLDatatype) + let placeholderDecl := Core.Decl.type (.data placeholderLDatatype) let bindingsWithPlaceholder := { bindings with freeVars := bindings.freeVars.push placeholderDecl } -- Extract constructor information (possibly recursive) @@ -1374,16 +1374,16 @@ def translateDatatype (p : Program) (bindings : TransBindings) (op : Operation) constrs := lConstrs constrs_ne := constrs_ne } - -- Generate factory from LDatatype and convert to Boogie.Decl + -- Generate factory from LDatatype and convert to Core.Decl -- (used only for bindings.freeVars, not for allDecls) let factory ← match ldatatype.genFactory (T := BoogieLParams) with | .ok f => pure f | .error e => TransM.error s!"Failed to generate datatype factory: {e}" - let funcDecls : List Boogie.Decl := factory.toList.map fun func => - Boogie.Decl.func func + let funcDecls : List Core.Decl := factory.toList.map fun func => + Core.Decl.func func -- Only includes typeDecl, factory functions generated later - let typeDecl := Boogie.Decl.type (.data ldatatype) + let typeDecl := Core.Decl.type (.data ldatatype) let allDecls := [typeDecl] /- @@ -1427,8 +1427,8 @@ def translateDatatype (p : Program) (bindings : TransBindings) (op : Operation) --------------------------------------------------------------------- def translateGlobalVar (bindings : TransBindings) (op : Operation) : - TransM (Boogie.Decl × TransBindings) := do - let _ ← @checkOp (Boogie.Decl × TransBindings) op q`Boogie.command_var 1 + TransM (Core.Decl × TransBindings) := do + let _ ← @checkOp (Core.Decl × TransBindings) op q`Core.command_var 1 let (id, targs, mty) ← translateBindMk bindings op.args[0]! let ty := LTy.forAll targs mty let md ← getOpMetaData op @@ -1439,10 +1439,10 @@ def translateGlobalVar (bindings : TransBindings) (op : Operation) : --------------------------------------------------------------------- partial def translateBoogieDecls (p : Program) (bindings : TransBindings) : - TransM Boogie.Decls := do + TransM Core.Decls := do let (decls, _) ← go 0 p.commands.size bindings p.commands return decls - where go (count max : Nat) bindings ops : TransM (Boogie.Decls × TransBindings) := do + where go (count max : Nat) bindings ops : TransM (Core.Decls × TransBindings) := do match (max - count) with | 0 => return ([], bindings) | _ + 1 => @@ -1450,36 +1450,36 @@ partial def translateBoogieDecls (p : Program) (bindings : TransBindings) : -- Commands that produce multiple declarations let (newDecls, bindings) ← match op.name with - | q`Boogie.command_datatype => + | q`Core.command_datatype => translateDatatype p bindings op | _ => -- All other commands produce a single declaration let (decl, bindings) ← match op.name with - | q`Boogie.command_var => + | q`Core.command_var => translateGlobalVar bindings op - | q`Boogie.command_constdecl => + | q`Core.command_constdecl => translateConstant bindings op - | q`Boogie.command_typedecl => + | q`Core.command_typedecl => translateTypeDecl bindings op - | q`Boogie.command_typesynonym => + | q`Core.command_typesynonym => translateTypeSynonym bindings op - | q`Boogie.command_axiom => + | q`Core.command_axiom => translateAxiom p bindings op - | q`Boogie.command_distinct => + | q`Core.command_distinct => translateDistinct p bindings op - | q`Boogie.command_procedure => + | q`Core.command_procedure => translateProcedure p bindings op - | q`Boogie.command_fndef => + | q`Core.command_fndef => translateFunction .Definition p bindings op - | q`Boogie.command_fndecl => + | q`Core.command_fndecl => translateFunction .Declaration p bindings op | _ => TransM.error s!"translateBoogieDecls unimplemented for {repr op}" pure ([decl], bindings) let (decls, bindings) ← go (count + 1) max bindings ops return (newDecls ++ decls, bindings) -def translateProgram (p : Program) : TransM Boogie.Program := do +def translateProgram (p : Program) : TransM Core.Program := do let decls ← translateBoogieDecls p {} return { decls := decls } diff --git a/Strata/Languages/Boogie/Env.lean b/Strata/Languages/Boogie/Env.lean index 1ebc91778..55eaec1c8 100644 --- a/Strata/Languages/Boogie/Env.lean +++ b/Strata/Languages/Boogie/Env.lean @@ -9,7 +9,7 @@ import Strata.Languages.Boogie.Program import Strata.DL.Imperative.EvalContext -namespace Boogie +namespace Core open Std (ToFormat Format format) open Imperative @@ -140,7 +140,7 @@ structure Env where def Env.init (empty_factory:=false): Env := let σ := Lambda.LState.init - let σ := if empty_factory then σ else σ.setFactory Boogie.Factory + let σ := if empty_factory then σ else σ.setFactory Core.Factory { error := none, program := Program.init, substMap := [], @@ -323,6 +323,6 @@ def Env.addDatatypes (E: Env) (datatypes: List (Lambda.LDatatype Visibility)) : let env ← E.addFactory f return { env with datatypes := datatypes.toArray } -end Boogie +end Core --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/Expressions.lean b/Strata/Languages/Boogie/Expressions.lean index ba9cef6f1..fdd3e11a5 100644 --- a/Strata/Languages/Boogie/Expressions.lean +++ b/Strata/Languages/Boogie/Expressions.lean @@ -11,7 +11,7 @@ import Strata.DL.Imperative.PureExpr import Strata.Languages.Boogie.Identifiers import Strata.DL.Imperative.HasVars -namespace Boogie +namespace Core open Std (ToFormat Format format) --------------------------------------------------------------------- @@ -34,4 +34,4 @@ instance : Inhabited Expression.Expr where --------------------------------------------------------------------- -end Boogie +end Core diff --git a/Strata/Languages/Boogie/Factory.lean b/Strata/Languages/Boogie/Factory.lean index fa0493245..ec5fef6f2 100644 --- a/Strata/Languages/Boogie/Factory.lean +++ b/Strata/Languages/Boogie/Factory.lean @@ -11,7 +11,7 @@ import Strata.DL.Lambda.Factory import Strata.DL.Lambda.IntBoolFactory --------------------------------------------------------------------- -namespace Boogie +namespace Core open Lambda LTy.Syntax LExpr.SyntaxMono @[match_pattern] @@ -368,7 +368,7 @@ macro "ExpandBVOpFuncNames" "[" sizes:num,* "]" : term => do let mut allOps := #[] for size in sizes.getElems do let s := size.getNat.repr - let ops := BVOpNames.map (mkIdent ∘ (.str (.str .anonymous "Boogie")) ∘ (s!"bv{s}" ++ · ++ "Func")) + let ops := BVOpNames.map (mkIdent ∘ (.str (.str .anonymous "Core")) ∘ (s!"bv{s}" ++ · ++ "Func")) allOps := allOps ++ ops.toArray `([$(allOps),*]) @@ -476,7 +476,7 @@ elab "DefBVOpFuncExprs" "[" sizes:num,* "]" : command => do let s := size.getNat.repr for op in BVOpNames do let opName := mkIdent (.str .anonymous s!"bv{s}{op}Op") - let funcName := mkIdent (.str (.str .anonymous "Boogie") s!"bv{s}{op}Func") + let funcName := mkIdent (.str (.str .anonymous "Core") s!"bv{s}{op}Func") elabCommand (← `(def $opName : Expression.Expr := ($funcName).opExpr)) instance : Inhabited BoogieLParams.Metadata where @@ -563,4 +563,4 @@ Get all the built-in functions supported by Boogie. def builtinFunctions : Array String := Factory.map (fun f => BoogieIdent.toPretty f.name) -end Boogie +end Core diff --git a/Strata/Languages/Boogie/Function.lean b/Strata/Languages/Boogie/Function.lean index 81e194839..9a33b9d88 100644 --- a/Strata/Languages/Boogie/Function.lean +++ b/Strata/Languages/Boogie/Function.lean @@ -10,7 +10,7 @@ import Strata.Languages.Boogie.Statement --------------------------------------------------------------------- -namespace Boogie +namespace Core open Std (ToFormat Format format) open Lambda @@ -39,4 +39,4 @@ open LTy.Syntax LExpr.SyntaxMono in --------------------------------------------------------------------- -end Boogie +end Core diff --git a/Strata/Languages/Boogie/FunctionType.lean b/Strata/Languages/Boogie/FunctionType.lean index 089b41ec2..0dd00d412 100644 --- a/Strata/Languages/Boogie/FunctionType.lean +++ b/Strata/Languages/Boogie/FunctionType.lean @@ -11,15 +11,15 @@ import Strata.Languages.Boogie.Program --------------------------------------------------------------------- -namespace Boogie +namespace Core namespace Function open Lambda Imperative open Std (ToFormat Format format) -def typeCheck (C: Boogie.Expression.TyContext) (Env : Boogie.Expression.TyEnv) (func : Function) : - Except Format (Function × Boogie.Expression.TyEnv) := do +def typeCheck (C: Core.Expression.TyContext) (Env : Core.Expression.TyEnv) (func : Function) : + Except Format (Function × Core.Expression.TyEnv) := do -- (FIXME) Very similar to `Lambda.inferOp`, except that the body is annotated -- using `LExprT.resolve`. Can we share code here? -- @@ -56,4 +56,4 @@ def typeCheck (C: Boogie.Expression.TyContext) (Env : Boogie.Expression.TyEnv) ( end Function --------------------------------------------------------------------- -end Boogie +end Core diff --git a/Strata/Languages/Boogie/Identifiers.lean b/Strata/Languages/Boogie/Identifiers.lean index 081ef9509..aaefbbcf3 100644 --- a/Strata/Languages/Boogie/Identifiers.lean +++ b/Strata/Languages/Boogie/Identifiers.lean @@ -8,7 +8,7 @@ import Strata.DL.Lambda.LExprTypeEnv import Strata.DL.Lambda.Factory -namespace Boogie +namespace Core open Std diff --git a/Strata/Languages/Boogie/OldExpressions.lean b/Strata/Languages/Boogie/OldExpressions.lean index a1d6263a0..01d90a533 100644 --- a/Strata/Languages/Boogie/OldExpressions.lean +++ b/Strata/Languages/Boogie/OldExpressions.lean @@ -7,15 +7,16 @@ import Strata.Languages.Boogie.BoogieGen import Strata.Languages.Boogie.Procedure -namespace Boogie +namespace Core namespace OldExpressions -open Lambda.LExpr.SyntaxMono Lambda.LTy.Syntax Boogie.Syntax +open Lambda.LExpr.SyntaxMono Lambda.LTy.Syntax Core.Syntax -/-! ## Old Expressions in Boogie +/-! ## Old Expressions in Strata Core -From Section 4.3 in "This is Boogie 2": +The `old e` expression in Strata Core follows the syntax of the old expression +in Boogie. Specifically, in Section 4.3 in "This is Boogie 2": "Postconditions and procedure implementations are two-state contexts. This means that it is possible to refer to two different values of each variable. In a @@ -698,4 +699,4 @@ inductive ContainsOldVar : Expression.Expr → Prop where | eq_2 : ContainsOldVar e2 → ContainsOldVar (.eq m e1 e2) end OldExpressions -end Boogie +end Core diff --git a/Strata/Languages/Boogie/Procedure.lean b/Strata/Languages/Boogie/Procedure.lean index edfaf804a..71bedc36b 100644 --- a/Strata/Languages/Boogie/Procedure.lean +++ b/Strata/Languages/Boogie/Procedure.lean @@ -11,7 +11,7 @@ import Strata.Languages.Boogie.Statement --------------------------------------------------------------------- -namespace Boogie +namespace Core open Std (ToFormat Format format) open Lambda @@ -209,4 +209,4 @@ instance : HasVarsTrans Expression (List Statement) Procedure where allVarsTrans := Statements.allVarsTrans -end Boogie +end Core diff --git a/Strata/Languages/Boogie/ProcedureEval.lean b/Strata/Languages/Boogie/ProcedureEval.lean index 13b07ad69..4a0b09467 100644 --- a/Strata/Languages/Boogie/ProcedureEval.lean +++ b/Strata/Languages/Boogie/ProcedureEval.lean @@ -14,7 +14,7 @@ import Strata.Transform.LoopElim --------------------------------------------------------------------- -namespace Boogie +namespace Core namespace Procedure open Std @@ -89,4 +89,4 @@ def evalOne (E : Env) (p : Procedure) : Procedure × Env := --------------------------------------------------------------------- end Procedure -end Boogie +end Core diff --git a/Strata/Languages/Boogie/ProcedureType.lean b/Strata/Languages/Boogie/ProcedureType.lean index 63a66f5aa..a78d63e2d 100644 --- a/Strata/Languages/Boogie/ProcedureType.lean +++ b/Strata/Languages/Boogie/ProcedureType.lean @@ -13,15 +13,15 @@ import Strata.Languages.Boogie.OldExpressions --------------------------------------------------------------------- -namespace Boogie +namespace Core open Std (ToFormat Format format) open Imperative (MetaData) namespace Procedure -def typeCheck (C: Boogie.Expression.TyContext) (Env : Boogie.Expression.TyEnv) (p : Program) - (proc : Procedure) (md : MetaData Expression) : Except Format (Procedure × Boogie.Expression.TyEnv) := +def typeCheck (C: Core.Expression.TyContext) (Env : Core.Expression.TyEnv) (p : Program) + (proc : Procedure) (md : MetaData Expression) : Except Format (Procedure × Core.Expression.TyEnv) := let sourceLoc := MetaData.formatFileRangeD md (includeEnd? := false) let sourceLoc := if sourceLoc.isEmpty then sourceLoc else f!"{sourceLoc} " let errorWithSourceLoc := fun e => if sourceLoc.isEmpty then e else f!"{sourceLoc} {e}" @@ -102,4 +102,4 @@ def typeCheck (C: Boogie.Expression.TyContext) (Env : Boogie.Expression.TyEnv) ( --------------------------------------------------------------------- end Procedure -end Boogie +end Core diff --git a/Strata/Languages/Boogie/ProcedureWF.lean b/Strata/Languages/Boogie/ProcedureWF.lean index 136592380..9ad899e8f 100644 --- a/Strata/Languages/Boogie/ProcedureWF.lean +++ b/Strata/Languages/Boogie/ProcedureWF.lean @@ -12,7 +12,7 @@ import Strata.Languages.Boogie.ProcedureType import Strata.Languages.Boogie.WF import Strata.Languages.Boogie.StatementWF -namespace Boogie +namespace Core namespace WF open Lambda @@ -121,4 +121,4 @@ theorem Procedure.typeCheckWF : Procedure.typeCheck T p pp = Except.ok (pp', T') -/ end WF -end Boogie +end Core diff --git a/Strata/Languages/Boogie/Program.lean b/Strata/Languages/Boogie/Program.lean index b62f23a25..e9c864a03 100644 --- a/Strata/Languages/Boogie/Program.lean +++ b/Strata/Languages/Boogie/Program.lean @@ -13,7 +13,7 @@ import Strata.Languages.Boogie.Axiom --------------------------------------------------------------------- -namespace Boogie +namespace Core open Std (ToFormat Format format) open Imperative @@ -43,13 +43,13 @@ A Boogie declaration. Note: constants are 0-ary functions. -/ inductive Decl where - | var (name : Expression.Ident) (ty : Expression.Ty) (e : Expression.Expr) (md : MetaData Boogie.Expression := .empty) - | type (t : TypeDecl) (md : MetaData Boogie.Expression := .empty) - | ax (a : Axiom) (md : MetaData Boogie.Expression := .empty) + | var (name : Expression.Ident) (ty : Expression.Ty) (e : Expression.Expr) (md : MetaData Core.Expression := .empty) + | type (t : TypeDecl) (md : MetaData Core.Expression := .empty) + | ax (a : Axiom) (md : MetaData Core.Expression := .empty) -- The following is temporary, until we have lists and can encode `distinct` in Lambda. - | distinct (name : Expression.Ident) (es : List Expression.Expr) (md : MetaData Boogie.Expression := .empty) - | proc (d : Procedure) (md : MetaData Boogie.Expression := .empty) - | func (f : Function) (md : MetaData Boogie.Expression := .empty) + | distinct (name : Expression.Ident) (es : List Expression.Expr) (md : MetaData Core.Expression := .empty) + | proc (d : Procedure) (md : MetaData Core.Expression := .empty) + | func (f : Function) (md : MetaData Core.Expression := .empty) deriving Inhabited def Decl.metadata (d : Decl) : MetaData Expression := @@ -140,7 +140,7 @@ def Decl.formatWithMetaData (decl : Decl) : Format := abbrev Decls := List Decl -/-- A Boogie Program -/ +/-- A Core.Program -/ structure Program where { decls : Decls } @@ -310,4 +310,4 @@ def Program.Procedure.findP? (P : Program) (x : Expression.Ident) --------------------------------------------------------------------- -end Boogie +end Core diff --git a/Strata/Languages/Boogie/ProgramEval.lean b/Strata/Languages/Boogie/ProgramEval.lean index 132580f23..4109842ad 100644 --- a/Strata/Languages/Boogie/ProgramEval.lean +++ b/Strata/Languages/Boogie/ProgramEval.lean @@ -11,7 +11,7 @@ import Strata.Languages.Boogie.ProcedureEval --------------------------------------------------------------------- -namespace Boogie +namespace Core open Std (ToFormat Format format) @@ -93,4 +93,4 @@ def eval (E : Env) : List (Program × Env) := -------------------------------------------------------------------- end Program -end Boogie +end Core diff --git a/Strata/Languages/Boogie/ProgramType.lean b/Strata/Languages/Boogie/ProgramType.lean index 001acc0a6..bb24e8ca5 100644 --- a/Strata/Languages/Boogie/ProgramType.lean +++ b/Strata/Languages/Boogie/ProgramType.lean @@ -13,7 +13,7 @@ import Strata.Languages.Boogie.ProcedureType --------------------------------------------------------------------- -namespace Boogie +namespace Core open Std (ToFormat Format format) open Lambda @@ -21,14 +21,14 @@ open Lambda namespace Program -def typeCheck (C: Boogie.Expression.TyContext) (Env : Boogie.Expression.TyEnv) (program : Program) : - Except Format (Program × Boogie.Expression.TyEnv) := do +def typeCheck (C: Core.Expression.TyContext) (Env : Core.Expression.TyEnv) (program : Program) : + Except Format (Program × Core.Expression.TyEnv) := do -- Push a type substitution scope to store global type variables. let Env := Env.updateSubst { subst := [[]], isWF := SubstWF_of_empty_empty } let (decls, Env) ← go C Env program.decls [] .ok ({ decls }, Env) - where go C Env remaining acc : Except Format (Decls × Boogie.Expression.TyEnv) := + where go C Env remaining acc : Except Format (Decls × Core.Expression.TyEnv) := match remaining with | [] => .ok (acc.reverse, Env) | decl :: drest => do @@ -102,4 +102,4 @@ def typeCheck (C: Boogie.Expression.TyContext) (Env : Boogie.Expression.TyEnv) ( --------------------------------------------------------------------- end Program -end Boogie +end Core diff --git a/Strata/Languages/Boogie/ProgramWF.lean b/Strata/Languages/Boogie/ProgramWF.lean index 31ceca4ed..1b59634d8 100644 --- a/Strata/Languages/Boogie/ProgramWF.lean +++ b/Strata/Languages/Boogie/ProgramWF.lean @@ -73,7 +73,7 @@ import Strata.Languages.Boogie.ProcedureWF the program is type-checked. -/ -namespace Boogie +namespace Core namespace WF open Imperative Std Lambda @@ -390,4 +390,4 @@ theorem Program.typeCheckWF : Program.typeCheck C T p = .ok (p', T') → WF.WFPr exact typeCheck.goWF Hgo end WF -end Boogie +end Core diff --git a/Strata/Languages/Boogie/SMTEncoder.lean b/Strata/Languages/Boogie/SMTEncoder.lean index 0cc448514..72b6ef9f7 100644 --- a/Strata/Languages/Boogie/SMTEncoder.lean +++ b/Strata/Languages/Boogie/SMTEncoder.lean @@ -14,7 +14,7 @@ import Strata.DDM.Util.Graph.Tarjan --------------------------------------------------------------------- -namespace Boogie +namespace Core open Std (ToFormat Format format) open Lambda Strata.SMT @@ -642,11 +642,11 @@ def ProofObligation.toSMTTerms (E : Env) Except Format ((List Term) × SMT.Context) := do let assumptions := d.assumptions.flatten.map (fun a => a.snd) let (ctx, distinct_terms) ← E.distinct.foldlM (λ (ctx, tss) es => - do let (ts, ctx') ← Boogie.toSMTTerms E es ctx; pure (ctx', ts :: tss)) (ctx, []) + do let (ts, ctx') ← Core.toSMTTerms E es ctx; pure (ctx', ts :: tss)) (ctx, []) let distinct_assumptions := distinct_terms.map (λ ts => Term.app (.core .distinct) ts .bool) - let (assumptions_terms, ctx) ← Boogie.toSMTTerms E assumptions ctx - let (obligation_pos_term, ctx) ← Boogie.toSMTTerm E [] d.obligation ctx + let (assumptions_terms, ctx) ← Core.toSMTTerms E assumptions ctx + let (obligation_pos_term, ctx) ← Core.toSMTTerm E [] d.obligation ctx let obligation_term := if d.property == .cover then obligation_pos_term @@ -714,7 +714,7 @@ info: "; f\n(declare-const f0 (arrow Int Int))\n; f\n(declare-fun f1 (Int) Int)\ (E := {Env.init with exprEnv := { Env.init.exprEnv with config := { Env.init.exprEnv.config with - factory := Boogie.Factory + factory := Core.Factory } }}) @@ -754,4 +754,4 @@ info: "; f\n(declare-fun f0 (Int Int) Int)\n; x\n(declare-const f1 Int)\n(define }}) -end Boogie +end Core diff --git a/Strata/Languages/Boogie/Statement.lean b/Strata/Languages/Boogie/Statement.lean index 005e8ae19..8bf5ecc59 100644 --- a/Strata/Languages/Boogie/Statement.lean +++ b/Strata/Languages/Boogie/Statement.lean @@ -14,7 +14,7 @@ import Strata.DL.Imperative.Stmt import Strata.DL.Imperative.HasVars import Strata.DL.Lambda.LExpr -namespace Boogie +namespace Core open Imperative open Std (ToFormat Format format) --------------------------------------------------------------------- @@ -64,7 +64,7 @@ instance [ToFormat (Cmd P)] [ToFormat (MetaData P)] --------------------------------------------------------------------- -abbrev Statement := Imperative.Stmt Boogie.Expression Boogie.Command +abbrev Statement := Imperative.Stmt Core.Expression Core.Command abbrev Statements := List Statement @[match_pattern] @@ -94,7 +94,7 @@ abbrev Statement.cover (label : String) (b : Expression.Expr) (md : MetaData Exp --------------------------------------------------------------------- -abbrev Block := Imperative.Block Boogie.Expression Boogie.Command +abbrev Block := Imperative.Block Core.Expression Core.Command --------------------------------------------------------------------- @@ -317,7 +317,7 @@ def Block.substFvar (b : Block) (fr:Expression.Ident) termination_by b.sizeOf decreasing_by apply sizeOf_stmt_in_block; assumption -def Statement.substFvar (s : Boogie.Statement) +def Statement.substFvar (s : Core.Statement) (fr:Expression.Ident) (to:Expression.Expr) : Statement := match s with @@ -360,7 +360,7 @@ def Block.renameLhs (b : Block) termination_by b.sizeOf decreasing_by apply sizeOf_stmt_in_block; assumption -def Statement.renameLhs (s : Boogie.Statement) +def Statement.renameLhs (s : Core.Statement) (fr: Lambda.Identifier Visibility) (to: Lambda.Identifier Visibility) : Statement := match s with @@ -382,4 +382,4 @@ end --------------------------------------------------------------------- -end Boogie +end Core diff --git a/Strata/Languages/Boogie/StatementEval.lean b/Strata/Languages/Boogie/StatementEval.lean index e01a43098..b2eedd6cb 100644 --- a/Strata/Languages/Boogie/StatementEval.lean +++ b/Strata/Languages/Boogie/StatementEval.lean @@ -14,7 +14,7 @@ import Strata.Languages.Boogie.CmdEval --------------------------------------------------------------------- -namespace Boogie +namespace Core namespace Statement @@ -463,6 +463,6 @@ def evalOne (E : Env) (old_var_subst : SubstMap) (ss : Statements) : Statements | _ => (ss, { E with error := some (.Misc "More than one result environment") }) end Statement -end Boogie +end Core --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/StatementSemantics.lean b/Strata/Languages/Boogie/StatementSemantics.lean index 9b0f9ed51..9d716fe63 100644 --- a/Strata/Languages/Boogie/StatementSemantics.lean +++ b/Strata/Languages/Boogie/StatementSemantics.lean @@ -10,10 +10,10 @@ import Strata.Languages.Boogie.OldExpressions --------------------------------------------------------------------- -namespace Boogie +namespace Core /-- expressions that can't be reduced when evaluating -/ -inductive Value : Boogie.Expression.Expr → Prop where +inductive Value : Core.Expression.Expr → Prop where | const : Value (.const () _) | bvar : Value (.bvar () _) | op : Value (.op () _ _) @@ -21,24 +21,24 @@ inductive Value : Boogie.Expression.Expr → Prop where open Imperative -instance : HasVal Boogie.Expression where value := Value +instance : HasVal Core.Expression where value := Value -instance : HasFvar Boogie.Expression where +instance : HasFvar Core.Expression where mkFvar := (.fvar () · none) getFvar | .fvar _ v _ => some v | _ => none @[match_pattern] -def Boogie.true : Boogie.Expression.Expr := .boolConst () Bool.true +def Boogie.true : Core.Expression.Expr := .boolConst () Bool.true @[match_pattern] -def Boogie.false : Boogie.Expression.Expr := .boolConst () Bool.false +def Boogie.false : Core.Expression.Expr := .boolConst () Bool.false -instance : HasBool Boogie.Expression where +instance : HasBool Core.Expression where tt := Boogie.true ff := Boogie.false -instance : HasNot Boogie.Expression where +instance : HasNot Core.Expression where not | Boogie.true => Boogie.false | Boogie.false => Boogie.true @@ -164,7 +164,7 @@ def updatedStates -- where this condition will be asserted at procedures utilizing those two-state functions -/ def WellFormedBoogieEvalTwoState (δ : BoogieEval) (σ₀ σ : BoogieStore) : Prop := - open Boogie.OldExpressions in + open Core.OldExpressions in (∃ vs vs' σ₁, HavocVars σ₀ vs σ₁ ∧ InitVars σ₁ vs' σ) ∧ (∀ vs vs' σ₀ σ₁ σ, (HavocVars σ₀ vs σ₁ ∧ InitVars σ₁ vs' σ) → @@ -250,7 +250,7 @@ inductive EvalCommandContract : (String → Option Procedure) → BoogieEval | call_sem {π δ σ args oVals vals σA σAO σO σR n p modvals lhs σ'} : π n = .some p → - EvalExpressions (P:=Boogie.Expression) δ σ args vals → + EvalExpressions (P:=Core.Expression) δ σ args vals → ReadValues σ lhs oVals → WellFormedSemanticEvalVal δ → WellFormedSemanticEvalVar δ → diff --git a/Strata/Languages/Boogie/StatementSemanticsProps.lean b/Strata/Languages/Boogie/StatementSemanticsProps.lean index 8fe645f7f..7312f6ade 100644 --- a/Strata/Languages/Boogie/StatementSemanticsProps.lean +++ b/Strata/Languages/Boogie/StatementSemanticsProps.lean @@ -16,7 +16,7 @@ import Strata.Languages.Boogie.StatementSemantics /-! ## Theorems related to StatementSemantics -/ -namespace Boogie +namespace Core open Imperative theorem InitStatesEmpty : @@ -610,7 +610,7 @@ theorem ReadValuesLength : induction Hrd <;> simp_all theorem EvalExpressionsLength : - EvalExpressions (P:=Boogie.Expression) δ σ ks vs → + EvalExpressions (P:=Core.Expression) δ σ ks vs → ks.length = vs.length := by intros Hrd induction Hrd <;> simp_all @@ -1707,7 +1707,7 @@ theorem HavocVarsDefined : theorem EvalCmdDefMonotone : isDefined σ v → - EvalCmd Boogie.Expression δ σ c σ' → + EvalCmd Core.Expression δ σ c σ' → isDefined σ' v := by intros Hdef Heval cases Heval <;> try exact Hdef diff --git a/Strata/Languages/Boogie/StatementType.lean b/Strata/Languages/Boogie/StatementType.lean index 38b06eac7..4c87657eb 100644 --- a/Strata/Languages/Boogie/StatementType.lean +++ b/Strata/Languages/Boogie/StatementType.lean @@ -12,7 +12,7 @@ import Strata.Languages.Boogie.Program import Strata.Languages.Boogie.OldExpressions import Strata.DL.Imperative.CmdType -namespace Boogie +namespace Core namespace Statement open Lambda Imperative @@ -231,4 +231,4 @@ def typeCheck (C: Expression.TyContext) (Env : Expression.TyEnv) (P : Program) ( --------------------------------------------------------------------- end Statement -end Boogie +end Core diff --git a/Strata/Languages/Boogie/StatementWF.lean b/Strata/Languages/Boogie/StatementWF.lean index e9e90c5ef..52d65f1c0 100644 --- a/Strata/Languages/Boogie/StatementWF.lean +++ b/Strata/Languages/Boogie/StatementWF.lean @@ -12,7 +12,7 @@ import Strata.Languages.Boogie.WF import Strata.Languages.Boogie.StatementType --------------------------------------------------------------------- -namespace Boogie +namespace Core namespace WF open Std Lambda @@ -233,4 +233,4 @@ theorem Statement.typeCheckWF : -/ end WF -end Boogie +end Core diff --git a/Strata/Languages/Boogie/TypeDecl.lean b/Strata/Languages/Boogie/TypeDecl.lean index 6b1d075c4..8da7df873 100644 --- a/Strata/Languages/Boogie/TypeDecl.lean +++ b/Strata/Languages/Boogie/TypeDecl.lean @@ -10,7 +10,7 @@ import Strata.Languages.Boogie.Statement --------------------------------------------------------------------- -namespace Boogie +namespace Core open Std (ToFormat Format format) open Lambda diff --git a/Strata/Languages/Boogie/Verifier.lean b/Strata/Languages/Boogie/Verifier.lean index fce61d485..c23505dce 100644 --- a/Strata/Languages/Boogie/Verifier.lean +++ b/Strata/Languages/Boogie/Verifier.lean @@ -19,7 +19,7 @@ namespace Strata.SMT.Encoder open Strata.SMT.Encoder -- Derived from Strata.SMT.Encoder.encode. -def encodeBoogie (ctx : Boogie.SMT.Context) (prelude : SolverM Unit) (ts : List Term) : +def encodeBoogie (ctx : Core.SMT.Context) (prelude : SolverM Unit) (ts : List Term) : SolverM (List String × EncoderState) := do Solver.reset Solver.setLogic "ALL" @@ -41,7 +41,7 @@ end Strata.SMT.Encoder --------------------------------------------------------------------- -namespace Boogie.SMT +namespace Core.SMT open Std (ToFormat Format format) open Lambda Strata.SMT -- (TODO) Use DL.Imperative.SMTUtils. @@ -202,10 +202,10 @@ def dischargeObligation | .error e => return .error e | .ok result => return .ok (result, estate) -end Boogie.SMT +end Core.SMT --------------------------------------------------------------------- -namespace Boogie +namespace Core open Imperative Lambda Strata.SMT open Std (ToFormat Format format) @@ -267,8 +267,8 @@ def VCResult.isUnknown (vr : VCResult) : Bool := def VCResult.isImplementationError (vr : VCResult) : Bool := match vr.result with | .implementationError _ => true | _ => false -def VCResult.isNotSuccess (vcResult : Boogie.VCResult) := - !Boogie.VCResult.isSuccess vcResult +def VCResult.isNotSuccess (vcResult : Core.VCResult) := + !Core.VCResult.isSuccess vcResult abbrev VCResults := Array VCResult @@ -406,7 +406,7 @@ def verify (smtsolver : String) (program : Program) (options : Options := Options.default) (moreFns : @Lambda.Factory BoogieLParams := Lambda.Factory.default) : EIO Format VCResults := do - match Boogie.typeCheckAndPartialEval options program moreFns with + match Core.typeCheckAndPartialEval options program moreFns with | .error err => .error f!"❌ Type checking error.\n{format err}" | .ok pEs => @@ -416,7 +416,7 @@ def verify (smtsolver : String) (program : Program) (List.mapM (fun pE => verifySingleEnv smtsolver pE options) pEs) .ok VCss.toArray.flatten -end Boogie +end Core --------------------------------------------------------------------- namespace Strata @@ -424,31 +424,31 @@ namespace Strata open Lean.Parser def typeCheck (ictx : InputContext) (env : Program) (options : Options := Options.default) - (moreFns : @Lambda.Factory Boogie.BoogieLParams := Lambda.Factory.default) : - Except Std.Format Boogie.Program := do + (moreFns : @Lambda.Factory Core.BoogieLParams := Lambda.Factory.default) : + Except Std.Format Core.Program := do let (program, errors) := TransM.run ictx (translateProgram env) if errors.isEmpty then -- dbg_trace f!"AST: {program}" - Boogie.typeCheck options program moreFns + Core.typeCheck options program moreFns else .error s!"DDM Transform Error: {repr errors}" def Boogie.getProgram (p : Strata.Program) - (ictx : InputContext := Inhabited.default) : Boogie.Program × Array String := + (ictx : InputContext := Inhabited.default) : Core.Program × Array String := TransM.run ictx (translateProgram p) def verify (smtsolver : String) (env : Program) (ictx : InputContext := Inhabited.default) (options : Options := Options.default) - (moreFns : @Lambda.Factory Boogie.BoogieLParams := Lambda.Factory.default) - : IO Boogie.VCResults := do + (moreFns : @Lambda.Factory Core.BoogieLParams := Lambda.Factory.default) + : IO Core.VCResults := do let (program, errors) := Boogie.getProgram env ictx if errors.isEmpty then -- dbg_trace f!"AST: {program}" EIO.toIO (fun f => IO.Error.userError (toString f)) - (Boogie.verify smtsolver program options moreFns) + (Core.verify smtsolver program options moreFns) else panic! s!"DDM Transform Error: {repr errors}" @@ -461,7 +461,7 @@ structure Diagnostic where message : String deriving Repr, BEq -def toDiagnostic (vcr : Boogie.VCResult) : Option Diagnostic := do +def toDiagnostic (vcr : Core.VCResult) : Option Diagnostic := do -- Only create a diagnostic if verification failed. match vcr.result with | .pass => none -- Verification succeeded, no diagnostic diff --git a/Strata/Languages/Boogie/WF.lean b/Strata/Languages/Boogie/WF.lean index e79c6f445..05294d53d 100644 --- a/Strata/Languages/Boogie/WF.lean +++ b/Strata/Languages/Boogie/WF.lean @@ -35,7 +35,7 @@ import Strata.Languages.Boogie.OldExpressions -/ -namespace Boogie +namespace Core namespace WF open Imperative @@ -174,4 +174,4 @@ structure WFProgram extends (Wrapper Program) where prop: WFProgramProp self end WF -end Boogie +end Core diff --git a/Strata/Languages/C_Simp/Verify.lean b/Strata/Languages/C_Simp/Verify.lean index 309943be9..1db01f008 100644 --- a/Strata/Languages/C_Simp/Verify.lean +++ b/Strata/Languages/C_Simp/Verify.lean @@ -16,7 +16,7 @@ namespace Strata -- 2. Running SymExec of Lambda and Imp -def translate_expr (e : C_Simp.Expression.Expr) : Lambda.LExpr Boogie.BoogieLParams.mono := +def translate_expr (e : C_Simp.Expression.Expr) : Lambda.LExpr Core.BoogieLParams.mono := match e with | .const m c => .const m c | .op m o ty => .op m ⟨o.name, .unres⟩ ty @@ -28,12 +28,12 @@ def translate_expr (e : C_Simp.Expression.Expr) : Lambda.LExpr Boogie.BoogieLPar | .ite m c t e => .ite m (translate_expr c) (translate_expr t) (translate_expr e) | .eq m e1 e2 => .eq m (translate_expr e1) (translate_expr e2) -def translate_opt_expr (e : Option C_Simp.Expression.Expr) : Option (Lambda.LExpr Boogie.BoogieLParams.mono) := +def translate_opt_expr (e : Option C_Simp.Expression.Expr) : Option (Lambda.LExpr Core.BoogieLParams.mono) := match e with | some e => translate_expr e | none => none -def translate_cmd (c: C_Simp.Command) : Boogie.Command := +def translate_cmd (c: C_Simp.Command) : Core.Command := match c with | .init name ty e _md => .cmd (.init ⟨name.name, .unres⟩ ty (translate_expr e) {}) | .set name e _md => .cmd (.set ⟨name.name, .unres⟩ (translate_expr e) {}) @@ -42,7 +42,7 @@ def translate_cmd (c: C_Simp.Command) : Boogie.Command := | .assume label b _md => .cmd (.assume label (translate_expr b) {}) | .cover label b _md => .cmd (.cover label (translate_expr b) {}) -def translate_stmt (s: Imperative.Stmt C_Simp.Expression C_Simp.Command) : Boogie.Statement := +def translate_stmt (s: Imperative.Stmt C_Simp.Expression C_Simp.Command) : Core.Statement := match s with | .cmd c => .cmd (translate_cmd c) | .block l b _md => .block l (b.map translate_stmt) {} @@ -73,38 +73,38 @@ Assumption that invariant holds on exit This is suitable for Symbolic Execution, but may not be suitable for other analyses. -/ -def loop_elimination_statement(s : C_Simp.Statement) : Boogie.Statement := +def loop_elimination_statement(s : C_Simp.Statement) : Core.Statement := match s with | .loop guard measure invariant body _ => match measure, invariant with | .some measure, some invariant => -- let bodyss : := body.ss let assigned_vars := (Imperative.Block.modifiedVars body).map (λ s => ⟨s.name, .unres⟩) - let havocd : Boogie.Statement := .block "loop havoc" (assigned_vars.map (λ n => Boogie.Statement.havoc n {})) {} + let havocd : Core.Statement := .block "loop havoc" (assigned_vars.map (λ n => Core.Statement.havoc n {})) {} let measure_pos := (.app () (.app () (.op () "Int.Ge" none) (translate_expr measure)) (.intConst () 0)) - let entry_invariant : Boogie.Statement := .assert "entry_invariant" (translate_expr invariant) {} - let assert_measure_positive : Boogie.Statement := .assert "assert_measure_pos" measure_pos {} - let first_iter_facts : Boogie.Statement := .block "first_iter_asserts" [entry_invariant, assert_measure_positive] {} + let entry_invariant : Core.Statement := .assert "entry_invariant" (translate_expr invariant) {} + let assert_measure_positive : Core.Statement := .assert "assert_measure_pos" measure_pos {} + let first_iter_facts : Core.Statement := .block "first_iter_asserts" [entry_invariant, assert_measure_positive] {} - let arbitrary_iter_assumes := .block "arbitrary_iter_assumes" [(Boogie.Statement.assume "assume_guard" (translate_expr guard) {}), (Boogie.Statement.assume "assume_invariant" (translate_expr invariant) {}), (Boogie.Statement.assume "assume_measure_pos" measure_pos {})] {} - let measure_old_value_assign : Boogie.Statement := .init "special-name-for-old-measure-value" (.forAll [] (.tcons "int" [])) (translate_expr measure) {} - let measure_decreases : Boogie.Statement := .assert "measure_decreases" (.app () (.app () (.op () "Int.Lt" none) (translate_expr measure)) (.fvar () "special-name-for-old-measure-value" none)) {} - let measure_imp_not_guard : Boogie.Statement := .assert "measure_imp_not_guard" (.ite () (.app () (.app () (.op () "Int.Le" none) (translate_expr measure)) (.intConst () 0)) (.app () (.op () "Bool.Not" none) (translate_expr guard)) (.true ())) {} - let maintain_invariant : Boogie.Statement := .assert "arbitrary_iter_maintain_invariant" (translate_expr invariant) {} - let body_statements : List Boogie.Statement := body.map translate_stmt - let arbitrary_iter_facts : Boogie.Statement := .block "arbitrary iter facts" ([havocd, arbitrary_iter_assumes, measure_old_value_assign] ++ body_statements ++ [measure_decreases, measure_imp_not_guard, maintain_invariant]) {} + let arbitrary_iter_assumes := .block "arbitrary_iter_assumes" [(Core.Statement.assume "assume_guard" (translate_expr guard) {}), (Core.Statement.assume "assume_invariant" (translate_expr invariant) {}), (Core.Statement.assume "assume_measure_pos" measure_pos {})] {} + let measure_old_value_assign : Core.Statement := .init "special-name-for-old-measure-value" (.forAll [] (.tcons "int" [])) (translate_expr measure) {} + let measure_decreases : Core.Statement := .assert "measure_decreases" (.app () (.app () (.op () "Int.Lt" none) (translate_expr measure)) (.fvar () "special-name-for-old-measure-value" none)) {} + let measure_imp_not_guard : Core.Statement := .assert "measure_imp_not_guard" (.ite () (.app () (.app () (.op () "Int.Le" none) (translate_expr measure)) (.intConst () 0)) (.app () (.op () "Bool.Not" none) (translate_expr guard)) (.true ())) {} + let maintain_invariant : Core.Statement := .assert "arbitrary_iter_maintain_invariant" (translate_expr invariant) {} + let body_statements : List Core.Statement := body.map translate_stmt + let arbitrary_iter_facts : Core.Statement := .block "arbitrary iter facts" ([havocd, arbitrary_iter_assumes, measure_old_value_assign] ++ body_statements ++ [measure_decreases, measure_imp_not_guard, maintain_invariant]) {} - let not_guard : Boogie.Statement := .assume "not_guard" (.app () (.op () "Bool.Not" none) (translate_expr guard)) {} - let invariant : Boogie.Statement := .assume "invariant" (translate_expr invariant) {} + let not_guard : Core.Statement := .assume "not_guard" (.app () (.op () "Bool.Not" none) (translate_expr guard)) {} + let invariant : Core.Statement := .assume "invariant" (translate_expr invariant) {} .ite (translate_expr guard) [first_iter_facts, arbitrary_iter_facts, havocd, not_guard, invariant] [] {} | _, _ => panic! "Loop elimination require measure and invariant" | _ => translate_stmt s -- C_Simp functions are Boogie procedures -def loop_elimination_function(f : C_Simp.Function) : Boogie.Procedure := +def loop_elimination_function(f : C_Simp.Function) : Core.Procedure := let boogie_preconditions := [("pre", {expr := translate_expr f.pre })] let boogie_postconditions := [("post", {expr := translate_expr f.post })] {header := {name := f.name.name, typeArgs := [], @@ -116,25 +116,25 @@ def loop_elimination_function(f : C_Simp.Function) : Boogie.Procedure := body := f.body.map loop_elimination_statement} -def loop_elimination(program : C_Simp.Program) : Boogie.Program := +def loop_elimination(program : C_Simp.Program) : Core.Program := {decls := program.funcs.map (λ f => .proc (loop_elimination_function f) {})} -- Do loop elimination -def to_boogie(program : C_Simp.Program) : Boogie.Program := +def to_boogie(program : C_Simp.Program) : Core.Program := loop_elimination program def C_Simp.get_program (p : Strata.Program) : C_Simp.Program := (Strata.C_Simp.TransM.run (Strata.C_Simp.translateProgram (p.commands))).fst def C_Simp.typeCheck (p : Strata.Program) (options : Options := Options.default): - Except Std.Format Boogie.Program := do + Except Std.Format Core.Program := do let program := C_Simp.get_program p - Boogie.typeCheck options (to_boogie program) + Core.typeCheck options (to_boogie program) def C_Simp.verify (smtsolver : String) (p : Strata.Program) (options : Options := Options.default): - IO Boogie.VCResults := do + IO Core.VCResults := do let program := C_Simp.get_program p EIO.toIO (fun f => IO.Error.userError (toString f)) - (Boogie.verify smtsolver (to_boogie program) options) + (Core.verify smtsolver (to_boogie program) options) end Strata diff --git a/Strata/Languages/Laurel/Grammar/ConcreteToAbstractTreeTranslator.lean b/Strata/Languages/Laurel/Grammar/ConcreteToAbstractTreeTranslator.lean index e79088187..4e4f32ac9 100644 --- a/Strata/Languages/Laurel/Grammar/ConcreteToAbstractTreeTranslator.lean +++ b/Strata/Languages/Laurel/Grammar/ConcreteToAbstractTreeTranslator.lean @@ -30,7 +30,7 @@ def TransM.run (ictx : InputContext) (m : TransM α) : Except String α := def TransM.error (msg : String) : TransM α := throw msg -def SourceRange.toMetaData (ictx : InputContext) (sr : SourceRange) : Imperative.MetaData Boogie.Expression := +def SourceRange.toMetaData (ictx : InputContext) (sr : SourceRange) : Imperative.MetaData Core.Expression := let file := ictx.fileName let startPos := ictx.fileMap.toPosition sr.start let endPos := ictx.fileMap.toPosition sr.stop @@ -38,7 +38,7 @@ def SourceRange.toMetaData (ictx : InputContext) (sr : SourceRange) : Imperative let fileRangeElt := ⟨ Imperative.MetaDataElem.Field.label "fileRange", .fileRange ⟨ uri, startPos, endPos ⟩ ⟩ #[fileRangeElt] -def getArgMetaData (arg : Arg) : TransM (Imperative.MetaData Boogie.Expression) := +def getArgMetaData (arg : Arg) : TransM (Imperative.MetaData Core.Expression) := return SourceRange.toMetaData (← get).inputCtx arg.ann def checkOp (op : Strata.Operation) (name : QualifiedIdent) (argc : Nat) : diff --git a/Strata/Languages/Laurel/Laurel.lean b/Strata/Languages/Laurel/Laurel.lean index ffa4d5d39..f8e084f04 100644 --- a/Strata/Languages/Laurel/Laurel.lean +++ b/Strata/Languages/Laurel/Laurel.lean @@ -58,7 +58,7 @@ inductive Operation: Type where deriving Repr -- Explicit instance needed for deriving Repr in the mutual block -instance : Repr (Imperative.MetaData Boogie.Expression) := inferInstance +instance : Repr (Imperative.MetaData Core.Expression) := inferInstance mutual structure Procedure: Type where @@ -153,8 +153,8 @@ inductive StmtExpr : Type where | Fresh(value : StmtExpr) /- Related to proofs -/ - | Assert (condition: StmtExpr) (md : Imperative.MetaData Boogie.Expression) - | Assume (condition: StmtExpr) (md : Imperative.MetaData Boogie.Expression) + | Assert (condition: StmtExpr) (md : Imperative.MetaData Core.Expression) + | Assume (condition: StmtExpr) (md : Imperative.MetaData Core.Expression) /- ProveBy allows writing proof trees. Its semantics are the same as that of the given `value`, but the `proof` is used to help prove any assertions in `value`. diff --git a/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean b/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean index 2063f4a39..3ac92b678 100644 --- a/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean +++ b/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean @@ -18,10 +18,10 @@ import Strata.Languages.Laurel.LaurelFormat namespace Laurel -open Boogie (VCResult VCResults) +open Core (VCResult VCResults) open Strata -open Boogie (intAddOp intSubOp intMulOp intDivOp intModOp intNegOp intLtOp intLeOp intGtOp intGeOp boolAndOp boolOrOp boolNotOp) +open Core (intAddOp intSubOp intMulOp intDivOp intModOp intNegOp intLtOp intLeOp intGtOp intGeOp boolAndOp boolOrOp boolNotOp) open Lambda (LMonoTy LTy LExpr) /- @@ -37,12 +37,12 @@ def translateType (ty : HighType) : LMonoTy := /-- Translate Laurel StmtExpr to Boogie Expression -/ -def translateExpr (expr : StmtExpr) : Boogie.Expression.Expr := +def translateExpr (expr : StmtExpr) : Core.Expression.Expr := match h: expr with | .LiteralBool b => .const () (.boolConst b) | .LiteralInt i => .const () (.intConst i) | .Identifier name => - let ident := Boogie.BoogieIdent.locl name + let ident := Core.BoogieIdent.locl name .fvar () ident (some LMonoTy.int) -- Default to int type | .PrimitiveOp op [e] => match op with @@ -50,7 +50,7 @@ def translateExpr (expr : StmtExpr) : Boogie.Expression.Expr := | .Neg => .app () intNegOp (translateExpr e) | _ => panic! s!"translateExpr: Invalid unary op: {repr op}" | .PrimitiveOp op [e1, e2] => - let binOp (bop : Boogie.Expression.Expr): Boogie.Expression.Expr := + let binOp (bop : Core.Expression.Expr): Core.Expression.Expr := LExpr.mkApp () bop [translateExpr e1, translateExpr e2] match op with | .Eq => .eq () (translateExpr e1) (translateExpr e2) @@ -79,7 +79,7 @@ def translateExpr (expr : StmtExpr) : Boogie.Expression.Expr := | .Assign _ value => translateExpr value -- For expressions, just translate the value | .StaticCall name args => -- Create function call as an op application - let ident := Boogie.BoogieIdent.glob name + let ident := Core.BoogieIdent.glob name let fnOp := .op () ident (some LMonoTy.int) -- Assume int return type args.foldl (fun acc arg => .app () acc (translateExpr arg)) fnOp | _ => panic! Std.Format.pretty (Std.ToFormat.format expr) @@ -87,7 +87,7 @@ def translateExpr (expr : StmtExpr) : Boogie.Expression.Expr := all_goals (simp_wf; try omega) rename_i x_in; have := List.sizeOf_lt_of_mem x_in; omega -def getNameFromMd (md : Imperative.MetaData Boogie.Expression): String := +def getNameFromMd (md : Imperative.MetaData Core.Expression): String := let fileRange := (Imperative.getFileRange md).get! s!"({fileRange.start.column},{fileRange.start.line})" @@ -95,37 +95,37 @@ def getNameFromMd (md : Imperative.MetaData Boogie.Expression): String := Translate Laurel StmtExpr to Boogie Statements Takes the list of output parameter names to handle return statements correctly -/ -def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Boogie.Statement := +def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Core.Statement := match stmt with | @StmtExpr.Assert cond md => let boogieExpr := translateExpr cond - [Boogie.Statement.assert ("assert" ++ getNameFromMd md) boogieExpr md] + [Core.Statement.assert ("assert" ++ getNameFromMd md) boogieExpr md] | @StmtExpr.Assume cond md => let boogieExpr := translateExpr cond - [Boogie.Statement.assume ("assume" ++ getNameFromMd md) boogieExpr md] + [Core.Statement.assume ("assume" ++ getNameFromMd md) boogieExpr md] | .Block stmts _ => stmts.flatMap (translateStmt outputParams) | .LocalVariable name ty initializer => let boogieMonoType := translateType ty let boogieType := LTy.forAll [] boogieMonoType - let ident := Boogie.BoogieIdent.locl name + let ident := Core.BoogieIdent.locl name match initializer with | some initExpr => let boogieExpr := translateExpr initExpr - [Boogie.Statement.init ident boogieType boogieExpr] + [Core.Statement.init ident boogieType boogieExpr] | none => -- Initialize with default value let defaultExpr := match ty with | .TInt => .const () (.intConst 0) | .TBool => .const () (.boolConst false) | _ => .const () (.intConst 0) - [Boogie.Statement.init ident boogieType defaultExpr] + [Core.Statement.init ident boogieType defaultExpr] | .Assign target value => match target with | .Identifier name => - let ident := Boogie.BoogieIdent.locl name + let ident := Core.BoogieIdent.locl name let boogieExpr := translateExpr value - [Boogie.Statement.set ident boogieExpr] + [Core.Statement.set ident boogieExpr] | _ => [] -- Can only assign to simple identifiers | .IfThenElse cond thenBranch elseBranch => let bcond := translateExpr cond @@ -137,20 +137,20 @@ def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Boogi [Imperative.Stmt.ite bcond bthen belse .empty] | .StaticCall name args => let boogieArgs := args.map translateExpr - [Boogie.Statement.call [] name boogieArgs] + [Core.Statement.call [] name boogieArgs] | .Return valueOpt => -- In Boogie, returns are done by assigning to output parameters match valueOpt, outputParams.head? with | some value, some outParam => -- Assign to the first output parameter, then assume false for no fallthrough - let ident := Boogie.BoogieIdent.locl outParam.name + let ident := Core.BoogieIdent.locl outParam.name let boogieExpr := translateExpr value - let assignStmt := Boogie.Statement.set ident boogieExpr - let noFallThrough := Boogie.Statement.assume "return" (.const () (.boolConst false)) .empty + let assignStmt := Core.Statement.set ident boogieExpr + let noFallThrough := Core.Statement.assume "return" (.const () (.boolConst false)) .empty [assignStmt, noFallThrough] | none, _ => -- Return with no value - just indicate no fallthrough - let noFallThrough := Boogie.Statement.assume "return" (.const () (.boolConst false)) .empty + let noFallThrough := Core.Statement.assume "return" (.const () (.boolConst false)) .empty [noFallThrough] | some _, none => -- Error: trying to return a value but no output parameters @@ -160,31 +160,31 @@ def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Boogi /-- Translate Laurel Parameter to Boogie Signature entry -/ -def translateParameterToBoogie (param : Parameter) : (Boogie.BoogieIdent × LMonoTy) := - let ident := Boogie.BoogieIdent.locl param.name +def translateParameterToBoogie (param : Parameter) : (Core.BoogieIdent × LMonoTy) := + let ident := Core.BoogieIdent.locl param.name let ty := translateType param.type (ident, ty) /-- Translate Laurel Procedure to Boogie Procedure -/ -def translateProcedure (proc : Procedure) : Boogie.Procedure := +def translateProcedure (proc : Procedure) : Core.Procedure := -- Translate input parameters let inputPairs := proc.inputs.map translateParameterToBoogie let inputs := inputPairs - let header : Boogie.Procedure.Header := { + let header : Core.Procedure.Header := { name := proc.name typeArgs := [] inputs := inputs outputs := proc.outputs.map translateParameterToBoogie } - let spec : Boogie.Procedure.Spec := { + let spec : Core.Procedure.Spec := { modifies := [] preconditions := [] postconditions := [] } - let body : List Boogie.Statement := + let body : List Core.Statement := match proc.body with | .Transparent bodyExpr => translateStmt proc.outputs bodyExpr | _ => [] -- TODO: handle Opaque and Abstract bodies @@ -197,7 +197,7 @@ def translateProcedure (proc : Procedure) : Boogie.Procedure := /-- Translate Laurel Program to Boogie Program -/ -def translate (program : Program) : Boogie.Program := +def translate (program : Program) : Core.Program := -- First, sequence all assignments (move them out of expression positions) let sequencedProgram := liftExpressionAssignments program dbg_trace "=== Sequenced program Program ===" @@ -205,7 +205,7 @@ def translate (program : Program) : Boogie.Program := dbg_trace "=================================" -- Then translate to Boogie let procedures := sequencedProgram.staticProcedures.map translateProcedure - let decls := procedures.map (fun p => Boogie.Decl.proc p .empty) + let decls := procedures.map (fun p => Core.Decl.proc p .empty) { decls := decls } /-- @@ -215,11 +215,11 @@ def verifyToVcResults (smtsolver : String) (program : Program) (options : Options := Options.default) : IO VCResults := do let boogieProgram := translate program -- Debug: Print the generated Boogie program - dbg_trace "=== Generated Boogie Program ===" + dbg_trace "=== Generated Core.Program ===" dbg_trace (toString (Std.Format.pretty (Std.ToFormat.format boogieProgram))) dbg_trace "=================================" EIO.toIO (fun f => IO.Error.userError (toString f)) - (Boogie.verify smtsolver boogieProgram options) + (Core.verify smtsolver boogieProgram options) def verifyToDiagnostics (smtsolver : String) (program : Program): IO (Array Diagnostic) := do let results <- verifyToVcResults smtsolver program diff --git a/Strata/Languages/Python/BoogiePrelude.lean b/Strata/Languages/Python/BoogiePrelude.lean index 559627551..37f24d314 100644 --- a/Strata/Languages/Python/BoogiePrelude.lean +++ b/Strata/Languages/Python/BoogiePrelude.lean @@ -357,7 +357,7 @@ spec { #end -def Boogie.prelude : Boogie.Program := +def Boogie.prelude : Core.Program := Boogie.getProgram Strata.boogiePrelude |>.fst end Strata diff --git a/Strata/Languages/Python/FunctionSignatures.lean b/Strata/Languages/Python/FunctionSignatures.lean index 2f0c7809b..9d9b1be19 100644 --- a/Strata/Languages/Python/FunctionSignatures.lean +++ b/Strata/Languages/Python/FunctionSignatures.lean @@ -48,7 +48,7 @@ structure FuncDecl where instance : Inhabited FuncDecl where default := { args := #[], argIndexMap := {} } -/-- The name of a Python method as encoded in the Boogie dialect-/ +/-- The name of a Python method as encoded in the Strata Core dialect-/ abbrev FuncName := String /-- A collection of function signatures. -/ @@ -143,7 +143,7 @@ def coreSignatures : Signatures := addCoreDecls |>.run end -def TypeStrToBoogieExpr (ty: String) : Boogie.Expression.Expr := +def TypeStrToBoogieExpr (ty: String) : Core.Expression.Expr := if !ty.endsWith "OrNone" then panic! s!"Should only be called for possibly None types. Called for: {ty}" else diff --git a/Strata/Languages/Python/PyFactory.lean b/Strata/Languages/Python/PyFactory.lean index 927e8dfd4..66a0cb32a 100644 --- a/Strata/Languages/Python/PyFactory.lean +++ b/Strata/Languages/Python/PyFactory.lean @@ -27,7 +27,7 @@ if not re.match(REGEX, name) then # default flags == 0 ... ``` -## Corresponding Strata.Boogie: +## Corresponding Strata.Core: ``` procedure _main () { @@ -61,10 +61,10 @@ if not PyReMatch(REGEX, name, 0) then -/ -open Boogie +open Core open Lambda LTy.Syntax LExpr.SyntaxMono -def reCompileFunc : LFunc Boogie.BoogieLParams := +def reCompileFunc : LFunc Core.BoogieLParams := { name := "PyReCompile", typeArgs := [], inputs := [("string", mty[string]), @@ -94,7 +94,7 @@ def reCompileFunc : LFunc Boogie.BoogieLParams := | _ => .none) } -def ReFactory : @Factory Boogie.BoogieLParams := +def ReFactory : @Factory Core.BoogieLParams := #[ reCompileFunc ] diff --git a/Strata/Languages/Python/PythonToBoogie.lean b/Strata/Languages/Python/PythonToBoogie.lean index b8827277c..c0da98039 100644 --- a/Strata/Languages/Python/PythonToBoogie.lean +++ b/Strata/Languages/Python/PythonToBoogie.lean @@ -20,26 +20,26 @@ namespace Strata open Lambda.LTy.Syntax -- Some hard-coded things we'll need to fix later: -def clientType : Boogie.Expression.Ty := .forAll [] (.tcons "Client" []) -def dummyClient : Boogie.Expression.Expr := .fvar () "DUMMY_CLIENT" none +def clientType : Core.Expression.Ty := .forAll [] (.tcons "Client" []) +def dummyClient : Core.Expression.Expr := .fvar () "DUMMY_CLIENT" none -def dictStrAnyType : Boogie.Expression.Ty := .forAll [] (.tcons "DictStrAny" []) -def dummyDictStrAny : Boogie.Expression.Expr := .fvar () "DUMMY_DICT_STR_ANY" none +def dictStrAnyType : Core.Expression.Ty := .forAll [] (.tcons "DictStrAny" []) +def dummyDictStrAny : Core.Expression.Expr := .fvar () "DUMMY_DICT_STR_ANY" none -def strType : Boogie.Expression.Ty := .forAll [] (.tcons "string" []) -def dummyStr : Boogie.Expression.Expr := .fvar () "DUMMY_STR" none +def strType : Core.Expression.Ty := .forAll [] (.tcons "string" []) +def dummyStr : Core.Expression.Expr := .fvar () "DUMMY_STR" none -def listStrType : Boogie.Expression.Ty := .forAll [] (.tcons "ListStr" []) -def dummyListStr : Boogie.Expression.Expr := .fvar () "DUMMY_LIST_STR" none +def listStrType : Core.Expression.Ty := .forAll [] (.tcons "ListStr" []) +def dummyListStr : Core.Expression.Expr := .fvar () "DUMMY_LIST_STR" none -def datetimeType : Boogie.Expression.Ty := .forAll [] (.tcons "Datetime" []) -def dummyDatetime : Boogie.Expression.Expr := .fvar () "DUMMY_DATETIME" none +def datetimeType : Core.Expression.Ty := .forAll [] (.tcons "Datetime" []) +def dummyDatetime : Core.Expression.Expr := .fvar () "DUMMY_DATETIME" none -def dateType : Boogie.Expression.Ty := .forAll [] (.tcons "Date" []) -def dummyDate : Boogie.Expression.Expr := .fvar () "DUMMY_DATE" none +def dateType : Core.Expression.Ty := .forAll [] (.tcons "Date" []) +def dummyDate : Core.Expression.Expr := .fvar () "DUMMY_DATE" none -def timedeltaType : Boogie.Expression.Ty := .forAll [] (.tcons "int" []) -def dummyTimedelta : Boogie.Expression.Expr := .fvar () "DUMMY_Timedelta" none +def timedeltaType : Core.Expression.Ty := .forAll [] (.tcons "int" []) +def dummyTimedelta : Core.Expression.Expr := .fvar () "DUMMY_Timedelta" none ------------------------------------------------------------------------------- @@ -47,9 +47,9 @@ def dummyTimedelta : Boogie.Expression.Expr := .fvar () "DUMMY_Timedelta" none -- We translate these by first defining temporary variables to store the results of the stmts -- and then using those variables in the expression. structure PyExprTranslated where - stmts : List Boogie.Statement - expr: Boogie.Expression.Expr - post_stmts : List Boogie.Statement := [] + stmts : List Core.Statement + expr: Core.Expression.Expr + post_stmts : List Core.Statement := [] deriving Inhabited structure PythonFunctionDecl where @@ -83,10 +83,10 @@ def unwrapModule (c : Python.Command SourceRange) : Array (Python.stmt SourceRan | Python.Command.Module _ body _ => body.val | _ => panic! "Expected module" -def strToBoogieExpr (s: String) : Boogie.Expression.Expr := +def strToBoogieExpr (s: String) : Core.Expression.Expr := .strConst () s -def intToBoogieExpr (i: Int) : Boogie.Expression.Expr := +def intToBoogieExpr (i: Int) : Core.Expression.Expr := .intConst () i def PyIntToInt (i : Python.int SourceRange) : Int := @@ -94,7 +94,7 @@ def PyIntToInt (i : Python.int SourceRange) : Int := | .IntPos _ n => n.val | .IntNeg _ n => -n.val -def PyConstToBoogie (c: Python.constant SourceRange) : Boogie.Expression.Expr := +def PyConstToBoogie (c: Python.constant SourceRange) : Core.Expression.Expr := match c with | .ConString _ s => .strConst () s.val | .ConPos _ i => .intConst () i.val @@ -103,27 +103,27 @@ def PyConstToBoogie (c: Python.constant SourceRange) : Boogie.Expression.Expr := | .ConFloat _ f => .strConst () (f.val) | _ => panic! s!"Unhandled Constant: {repr c}" -def PyAliasToBoogieExpr (a : Python.alias SourceRange) : Boogie.Expression.Expr := +def PyAliasToBoogieExpr (a : Python.alias SourceRange) : Core.Expression.Expr := match a with | .mk_alias _ n as_n => assert! as_n.val.isNone .strConst () n.val -def handleAdd (lhs rhs: Boogie.Expression.Expr) : Boogie.Expression.Expr := +def handleAdd (lhs rhs: Core.Expression.Expr) : Core.Expression.Expr := let lty : Lambda.LMonoTy := mty[string] let rty : Lambda.LMonoTy := mty[string] match lty, rty with | (.tcons "string" []), (.tcons "string" []) => .app () (.app () (.op () "Str.Concat" mty[string → (string → string)]) lhs) rhs | _, _ => panic! s!"Unimplemented add op for {lhs} + {rhs}" -def handleSub (lhs rhs: Boogie.Expression.Expr) : Boogie.Expression.Expr := +def handleSub (lhs rhs: Core.Expression.Expr) : Core.Expression.Expr := let lty : Lambda.LMonoTy := (.tcons "Datetime" []) let rty : Lambda.LMonoTy := (.tcons "int" []) match lty, rty with | (.tcons "Datetime" []), (.tcons "int" []) => .app () (.app () (.op () "Datetime_sub" none) lhs) rhs | _, _ => panic! s!"Unimplemented add op for {lhs} + {rhs}" -def handleMult (translation_ctx: TranslationContext) (lhs rhs: Boogie.Expression.Expr) : Boogie.Expression.Expr := +def handleMult (translation_ctx: TranslationContext) (lhs rhs: Core.Expression.Expr) : Core.Expression.Expr := match lhs, rhs with | .strConst () s, .intConst () i => .strConst () (String.join (List.replicate i.toNat s)) | .intConst () l, .intConst () r => .intConst () (l * r) @@ -138,26 +138,26 @@ def handleMult (translation_ctx: TranslationContext) (lhs rhs: Boogie.Expression | _, _ => panic! s!"Missing needed type information for *. Exprs: {lhs} and {rhs}" | _ , _ => panic! s!"Unsupported args for * . Got: {lhs} and {rhs}" -def handleFloorDiv (_translation_ctx: TranslationContext) (lhs rhs: Boogie.Expression.Expr) : Boogie.Expression.Expr := +def handleFloorDiv (_translation_ctx: TranslationContext) (lhs rhs: Core.Expression.Expr) : Core.Expression.Expr := .app () (.app () (.op () "Int.Div" mty[int → (int → int)]) lhs) rhs -def handleNot (arg: Boogie.Expression.Expr) : Boogie.Expression.Expr := +def handleNot (arg: Core.Expression.Expr) : Core.Expression.Expr := let ty : Lambda.LMonoTy := (.tcons "ListStr" []) match ty with | (.tcons "ListStr" []) => .eq () arg (.op () "ListStr_nil" none) | _ => panic! s!"Unimplemented not op for {arg}" -def handleLtE (lhs rhs: Boogie.Expression.Expr) : Boogie.Expression.Expr := +def handleLtE (lhs rhs: Core.Expression.Expr) : Core.Expression.Expr := let eq := (.eq () lhs rhs) let lt := (.app () (.app () (.op () "Datetime_lt" none) lhs) rhs) (.app () (.app () (.op () "Bool.Or" none) eq) lt) -def handleGt (lhs rhs: Boogie.Expression.Expr) : Boogie.Expression.Expr := +def handleGt (lhs rhs: Core.Expression.Expr) : Core.Expression.Expr := (.app () (.app () (.op () "Float_gt" none) lhs) rhs) structure SubstitutionRecord where pyExpr : Python.expr SourceRange - boogieExpr : Boogie.Expression.Expr + boogieExpr : Core.Expression.Expr instance : Repr (List SubstitutionRecord) where reprPrec xs _ := @@ -170,7 +170,7 @@ def PyExprIdent (e1 e2: Python.expr SourceRange) : Bool := | _ , _ => false -- TODO: handle rest of names -def PyListStrToBoogie (names : Array (Python.alias SourceRange)) : Boogie.Expression.Expr := +def PyListStrToBoogie (names : Array (Python.alias SourceRange)) : Core.Expression.Expr := .app () (.app () (.op () "ListStr_cons" mty[string → (ListStr → ListStr)]) (PyAliasToBoogieExpr names[0]!)) (.op () "ListStr_nil" mty[ListStr]) @@ -243,7 +243,7 @@ def callCanThrow (func_infos : List PythonFunctionDecl) (stmt: Python.stmt Sourc | _ => false | _ => false -def noneOrExpr (translation_ctx : TranslationContext) (fname n : String) (e: Boogie.Expression.Expr) : Boogie.Expression.Expr := +def noneOrExpr (translation_ctx : TranslationContext) (fname n : String) (e: Core.Expression.Expr) : Core.Expression.Expr := let type_str := translation_ctx.signatures.getFuncSigType fname n if type_str.endsWith "OrNone" then -- Optional param. Need to wrap e.g., string into StrOrNone @@ -255,7 +255,7 @@ def noneOrExpr (translation_ctx : TranslationContext) (fname n : String) (e: Boo else e -def handleCallThrow (jmp_target : String) : Boogie.Statement := +def handleCallThrow (jmp_target : String) : Core.Statement := let cond := .app () (.op () "ExceptOrNone..isExceptOrNone_mk_code" none) (.fvar () "maybe_except" none) .ite cond [.goto jmp_target] [] @@ -279,7 +279,7 @@ def deduplicateTypeAnnotations (l : List (String × Option String)) : List (Stri | .some ty => (n, ty) | .none => panic s!"Missing type annotations for {n}") -partial def collectVarDecls (translation_ctx : TranslationContext) (stmts: Array (Python.stmt SourceRange)) : List Boogie.Statement := +partial def collectVarDecls (translation_ctx : TranslationContext) (stmts: Array (Python.stmt SourceRange)) : List Core.Statement := let rec go (s : Python.stmt SourceRange) : List (String × Option String) := match s with | .Assign _ lhs _ _ => @@ -292,7 +292,7 @@ partial def collectVarDecls (translation_ctx : TranslationContext) (stmts: Array | _ => [] let dup := stmts.toList.flatMap go let dedup := deduplicateTypeAnnotations dup - let toBoogie (p: String × String) : List Boogie.Statement := + let toBoogie (p: String × String) : List Core.Statement := let name := p.fst let ty_name := p.snd match ty_name with @@ -349,7 +349,7 @@ partial def argsAndKWordsToCanonicalList (translation_ctx : TranslationContext) (fname: String) (args : Array (Python.expr SourceRange)) (kwords: Array (Python.keyword SourceRange)) - (substitution_records : Option (List SubstitutionRecord) := none) : List Boogie.Expression.Expr × List Boogie.Statement := + (substitution_records : Option (List SubstitutionRecord) := none) : List Core.Expression.Expr × List Core.Statement := if translation_ctx.func_infos.any (λ e => e.name == fname) || translation_ctx.class_infos.any (λ e => e.name++"___init__" == fname) then if translation_ctx.func_infos.any (λ e => e.name == fname) then (args.toList.map (λ a => (PyExprToBoogieWithSubst default substitution_records a).expr), []) @@ -459,19 +459,19 @@ partial def PyExprToBoogie (translation_ctx : TranslationContext) (e : Python.ex let k := PyExprToBoogie translation_ctx slice -- TODO: we need to plumb the type of `v` here match s!"{repr l.expr}" with - | "LExpr.fvar () { name := \"keys\", metadata := Boogie.Visibility.unres } none" => - -- let access_check : Boogie.Statement := .assert "subscript_bounds_check" (.app () (.app () (.op () "str_in_dict_str_any" none) k.expr) l.expr) + | "LExpr.fvar () { name := \"keys\", metadata := Core.Visibility.unres } none" => + -- let access_check : Core.Statement := .assert "subscript_bounds_check" (.app () (.app () (.op () "str_in_dict_str_any" none) k.expr) l.expr) {stmts := l.stmts ++ k.stmts, expr := .app () (.app () (.op () "list_str_get" none) l.expr) k.expr} - | "LExpr.fvar () { name := \"blended_cost\", metadata := Boogie.Visibility.unres } none" => - -- let access_check : Boogie.Statement := .assert "subscript_bounds_check" (.app () (.app () (.op () "str_in_dict_str_any" none) k.expr) l.expr) + | "LExpr.fvar () { name := \"blended_cost\", metadata := Core.Visibility.unres } none" => + -- let access_check : Core.Statement := .assert "subscript_bounds_check" (.app () (.app () (.op () "str_in_dict_str_any" none) k.expr) l.expr) {stmts := l.stmts ++ k.stmts, expr := .app () (.app () (.op () "dict_str_any_get_str" none) l.expr) k.expr} | _ => match translation_ctx.expectedType with | .some (.tcons "ListStr" []) => - let access_check : Boogie.Statement := .assert "subscript_bounds_check" (.app () (.app () (.op () "str_in_dict_str_any" none) k.expr) l.expr) + let access_check : Core.Statement := .assert "subscript_bounds_check" (.app () (.app () (.op () "str_in_dict_str_any" none) k.expr) l.expr) {stmts := l.stmts ++ k.stmts ++ [access_check], expr := .app () (.app () (.op () "dict_str_any_get_list_str" none) l.expr) k.expr} | _ => - let access_check : Boogie.Statement := .assert "subscript_bounds_check" (.app () (.app () (.op () "str_in_dict_str_any" none) k.expr) l.expr) + let access_check : Core.Statement := .assert "subscript_bounds_check" (.app () (.app () (.op () "str_in_dict_str_any" none) k.expr) l.expr) {stmts := l.stmts ++ k.stmts ++ [access_check], expr := .app () (.app () (.op () "dict_str_any_get" none) l.expr) k.expr} | .List _ elmts _ => match elmts.val[0]! with @@ -482,7 +482,7 @@ partial def PyExprToBoogie (translation_ctx : TranslationContext) (e : Python.ex | _ => panic! s!"Unexpected element: {repr elmts.val[0]!}" | _ => panic! s!"Unhandled Expr: {repr e}" -partial def initTmpParam (p: Python.expr SourceRange × String) : List Boogie.Statement := +partial def initTmpParam (p: Python.expr SourceRange × String) : List Core.Statement := match p.fst with | .Call _ f args _ => match f with @@ -497,18 +497,18 @@ partial def initTmpParam (p: Python.expr SourceRange × String) : List Boogie.St | _ => panic! s!"Unsupported tmp param init call: {repr f}" | _ => panic! "Expected Call" -partial def exceptHandlersToBoogie (jmp_targets: List String) (translation_ctx: TranslationContext) (h : Python.excepthandler SourceRange) : List Boogie.Statement := +partial def exceptHandlersToBoogie (jmp_targets: List String) (translation_ctx: TranslationContext) (h : Python.excepthandler SourceRange) : List Core.Statement := assert! jmp_targets.length >= 2 match h with | .ExceptHandler _ ex_ty _ body => let set_ex_ty_matches := match ex_ty.val with | .some ex_ty => - let inherits_from : Boogie.BoogieIdent := "inheritsFrom" - let get_ex_tag : Boogie.BoogieIdent := "ExceptOrNone_code_val" - let exception_ty : Boogie.Expression.Expr := .app () (.op () get_ex_tag none) (.fvar () "maybe_except" none) - let rhs_curried : Boogie.Expression.Expr := .app () (.op () inherits_from none) exception_ty + let inherits_from : Core.BoogieIdent := "inheritsFrom" + let get_ex_tag : Core.BoogieIdent := "ExceptOrNone_code_val" + let exception_ty : Core.Expression.Expr := .app () (.op () get_ex_tag none) (.fvar () "maybe_except" none) + let rhs_curried : Core.Expression.Expr := .app () (.op () inherits_from none) exception_ty let res := PyExprToBoogie translation_ctx ex_ty - let rhs : Boogie.Expression.Expr := .app () rhs_curried (res.expr) + let rhs : Core.Expression.Expr := .app () rhs_curried (res.expr) let call := .set "exception_ty_matches" rhs res.stmts ++ [call] | .none => @@ -517,13 +517,13 @@ partial def exceptHandlersToBoogie (jmp_targets: List String) (translation_ctx: let body_if_matches := body.val.toList.flatMap (λ s => (PyStmtToBoogie jmp_targets translation_ctx s).fst) ++ [.goto jmp_targets[1]!] set_ex_ty_matches ++ [.ite cond body_if_matches []] -partial def handleFunctionCall (lhs: List Boogie.Expression.Ident) +partial def handleFunctionCall (lhs: List Core.Expression.Ident) (fname: String) (args: Ann (Array (Python.expr SourceRange)) SourceRange) (kwords: Ann (Array (Python.keyword SourceRange)) SourceRange) (_jmp_targets: List String) (translation_ctx: TranslationContext) - (_s : Python.stmt SourceRange) : List Boogie.Statement := + (_s : Python.stmt SourceRange) : List Core.Statement := let fname := remapFname translation_ctx fname @@ -543,19 +543,19 @@ partial def handleFunctionCall (lhs: List Boogie.Expression.Ident) kwords_calls_to_tmps.toList.flatMap initTmpParam ++ res.snd ++ [.call lhs fname res.fst] -partial def handleComprehension (lhs: Python.expr SourceRange) (gen: Array (Python.comprehension SourceRange)) : List Boogie.Statement := +partial def handleComprehension (lhs: Python.expr SourceRange) (gen: Array (Python.comprehension SourceRange)) : List Core.Statement := assert! gen.size == 1 match gen[0]! with | .mk_comprehension _ _ itr _ _ => let res := PyExprToBoogie default itr let guard := .app () (.op () "Bool.Not" none) (.eq () (.app () (.op () "dict_str_any_length" none) res.expr) (.intConst () 0)) - let then_ss: List Boogie.Statement := [.havoc (PyExprToString lhs)] - let else_ss: List Boogie.Statement := [.set (PyExprToString lhs) (.op () "ListStr_nil" none)] + let then_ss: List Core.Statement := [.havoc (PyExprToString lhs)] + let else_ss: List Core.Statement := [.set (PyExprToString lhs) (.op () "ListStr_nil" none)] res.stmts ++ [.ite guard then_ss else_ss] -partial def PyStmtToBoogie (jmp_targets: List String) (translation_ctx : TranslationContext) (s : Python.stmt SourceRange) : List Boogie.Statement × TranslationContext := +partial def PyStmtToBoogie (jmp_targets: List String) (translation_ctx : TranslationContext) (s : Python.stmt SourceRange) : List Core.Statement × TranslationContext := assert! jmp_targets.length > 0 - let non_throw : List Boogie.Statement × Option (String × Lambda.LMonoTy) := match s with + let non_throw : List Core.Statement × Option (String × Lambda.LMonoTy) := match s with | .Import _ names => ([.call [] "import" [PyListStrToBoogie names.val]], none) | .ImportFrom _ s names i => @@ -653,7 +653,7 @@ partial def PyStmtToBoogie (jmp_targets: List String) (translation_ctx : Transla else (non_throw.fst, new_translation_ctx) -partial def ArrPyStmtToBoogie (translation_ctx: TranslationContext) (a : Array (Python.stmt SourceRange)) : (List Boogie.Statement × TranslationContext) := +partial def ArrPyStmtToBoogie (translation_ctx: TranslationContext) (a : Array (Python.stmt SourceRange)) : (List Core.Statement × TranslationContext) := a.foldl (fun (stmts, ctx) stmt => let (newStmts, newCtx) := PyStmtToBoogie ["end"] ctx stmt (stmts ++ newStmts, newCtx) @@ -662,12 +662,12 @@ partial def ArrPyStmtToBoogie (translation_ctx: TranslationContext) (a : Array ( end --mutual -def translateFunctions (a : Array (Python.stmt SourceRange)) (translation_ctx: TranslationContext) : List Boogie.Decl := +def translateFunctions (a : Array (Python.stmt SourceRange)) (translation_ctx: TranslationContext) : List Core.Decl := a.toList.filterMap (λ s => match s with | .FunctionDef _ name _args body _ _ret _ _ => - let varDecls : List Boogie.Statement := [] - let proc : Boogie.Procedure := { + let varDecls : List Core.Statement := [] + let proc : Core.Procedure := { header := { name := name.val, typeArgs := [], @@ -686,8 +686,8 @@ def pyTyStrToLMonoTy (ty_str: String) : Lambda.LMonoTy := | "datetime" => (.tcons "Datetime" []) | _ => panic! s!"Unsupported type: {ty_str}" -def pythonFuncToBoogie (name : String) (args: List (String × String)) (body: Array (Python.stmt SourceRange)) (ret : Option (Python.expr SourceRange)) (spec : Boogie.Procedure.Spec) (translation_ctx : TranslationContext) : Boogie.Procedure := - let inputs : List (Lambda.Identifier Boogie.Visibility × Lambda.LMonoTy) := args.map (λ p => (p.fst, pyTyStrToLMonoTy p.snd)) +def pythonFuncToBoogie (name : String) (args: List (String × String)) (body: Array (Python.stmt SourceRange)) (ret : Option (Python.expr SourceRange)) (spec : Core.Procedure.Spec) (translation_ctx : TranslationContext) : Core.Procedure := + let inputs : List (Lambda.Identifier Core.Visibility × Lambda.LMonoTy) := args.map (λ p => (p.fst, pyTyStrToLMonoTy p.snd)) let varDecls := collectVarDecls translation_ctx body ++ [(.init "exception_ty_matches" t[bool] (.boolConst () false)), (.havoc "exception_ty_matches")] let stmts := (ArrPyStmtToBoogie translation_ctx body).fst let body := varDecls ++ stmts ++ [.block "end" []] @@ -725,14 +725,14 @@ def unpackPyArguments (args: Python.arguments SourceRange) : List (String × Str | .some ty => some (name.val, PyExprToString ty) | _ => panic! s!"Missing type annotation on arg: {repr a} ({repr args})") -def PyFuncDefToBoogie (s: Python.stmt SourceRange) (translation_ctx: TranslationContext) : List Boogie.Decl × PythonFunctionDecl := +def PyFuncDefToBoogie (s: Python.stmt SourceRange) (translation_ctx: TranslationContext) : List Core.Decl × PythonFunctionDecl := match s with | .FunctionDef _ name args body _ ret _ _ => let args := unpackPyArguments args ([.proc (pythonFuncToBoogie name.val args body.val ret.val default translation_ctx)], {name := name.val, args, ret := s!"{repr ret}"}) | _ => panic! s!"Expected function def: {repr s}" -def PyClassDefToBoogie (s: Python.stmt SourceRange) (translation_ctx: TranslationContext) : List Boogie.Decl × PythonClassDecl := +def PyClassDefToBoogie (s: Python.stmt SourceRange) (translation_ctx: TranslationContext) : List Core.Decl × PythonClassDecl := match s with | .ClassDef _ c_name _ _ body _ _ => let member_fn_defs := body.val.toList.filterMap (λ s => match s with @@ -746,7 +746,7 @@ def PyClassDefToBoogie (s: Python.stmt SourceRange) (translation_ctx: Translatio .proc (pythonFuncToBoogie (c_name.val++"_"++name) args body ret default translation_ctx)), {name := c_name.val}) | _ => panic! s!"Expected function def: {repr s}" -def pythonToBoogie (signatures : Python.Signatures) (pgm: Strata.Program): Boogie.Program := +def pythonToBoogie (signatures : Python.Signatures) (pgm: Strata.Program): Core.Program := let pyCmds := toPyCommands pgm.commands assert! pyCmds.size == 1 let insideMod := unwrapModule pyCmds[0]! @@ -765,10 +765,10 @@ def pythonToBoogie (signatures : Python.Signatures) (pgm: Strata.Program): Boogi let globals := [(.var "__name__" (.forAll [] mty[string]) (.strConst () "__main__"))] - let rec helper {α : Type} (f : Python.stmt SourceRange → TranslationContext → List Boogie.Decl × α) + let rec helper {α : Type} (f : Python.stmt SourceRange → TranslationContext → List Core.Decl × α) (update : TranslationContext → α → TranslationContext) (acc : TranslationContext) : - List (Python.stmt SourceRange) → List Boogie.Decl × TranslationContext + List (Python.stmt SourceRange) → List Core.Decl × TranslationContext | [] => ([], acc) | x :: xs => let (y, info) := f x acc diff --git a/Strata/Languages/Python/Regex/ReToBoogie.lean b/Strata/Languages/Python/Regex/ReToBoogie.lean index 4ea29793f..575218e66 100644 --- a/Strata/Languages/Python/Regex/ReToBoogie.lean +++ b/Strata/Languages/Python/Regex/ReToBoogie.lean @@ -13,7 +13,7 @@ namespace Python ------------------------------------------------------------------------------- open Lambda.LExpr -open Boogie +open Core /-- Python regexes can be interpreted differently based on the matching mode. @@ -66,17 +66,17 @@ def RegexAST.alwaysConsume (r : RegexAST) : Bool := /-- Empty regex pattern; matches an empty string. -/ -def Boogie.emptyRegex : Boogie.Expression.Expr := +def Boogie.emptyRegex : Core.Expression.Expr := mkApp () (.op () strToRegexFunc.name none) [strConst () ""] /-- Unmatchable regex pattern. -/ -def Boogie.unmatchableRegex : Boogie.Expression.Expr := +def Boogie.unmatchableRegex : Core.Expression.Expr := mkApp () (.op () reNoneFunc.name none) [] partial def RegexAST.toBoogie (r : RegexAST) (atStart atEnd : Bool) : - Boogie.Expression.Expr := + Core.Expression.Expr := match r with | .char c => (mkApp () (.op () strToRegexFunc.name none) [strConst () (toString c)]) @@ -156,7 +156,7 @@ partial def RegexAST.toBoogie (r : RegexAST) (atStart atEnd : Bool) : mkApp () (.op () reUnionFunc.name none) [r1b, r2b] def pythonRegexToBoogie (pyRegex : String) (mode : MatchMode := .fullmatch) : - Boogie.Expression.Expr × Option ParseError := + Core.Expression.Expr × Option ParseError := match parseTop pyRegex with | .error err => (mkApp () (.op () reAllFunc.name none) [], some err) | .ok ast => diff --git a/Strata/Transform/CallElim.lean b/Strata/Transform/CallElim.lean index eed92c6b3..e90397063 100644 --- a/Strata/Transform/CallElim.lean +++ b/Strata/Transform/CallElim.lean @@ -8,10 +8,10 @@ import Strata.Transform.CoreTransform /-! # Call Elimination Transformation -/ -namespace Boogie +namespace Core namespace CallElim -open Boogie.Transform +open Core.Transform /-- The main call elimination transformation algorithm on a single command. @@ -98,4 +98,4 @@ def callElim' (p : Program) : CoreTransformM Program := runProgram callElimCmd p end CallElim -end Boogie +end Core diff --git a/Strata/Transform/CallElimCorrect.lean b/Strata/Transform/CallElimCorrect.lean index 7ca2754af..2a8594bee 100644 --- a/Strata/Transform/CallElimCorrect.lean +++ b/Strata/Transform/CallElimCorrect.lean @@ -28,7 +28,7 @@ import Strata.DL.Util.ListUtils -/ namespace CallElimCorrect -open Boogie Boogie.Transform CallElim +open Core Core.Transform CallElim theorem BoogieIdent.isGlob_isGlobOrLocl : PredImplies (BoogieIdent.isGlob ·) (BoogieIdent.isGlobOrLocl ·) := by @@ -165,8 +165,8 @@ theorem getIdentTys!_no_throw : -- Step 1. A theorem stating that given a well-formed program, call-elim will return no exception theorem callElimBlockNoExcept : - ∀ (st : Boogie.Statement) - (p : Boogie.Program), + ∀ (st : Core.Statement) + (p : Core.Program), WF.WFStatementsProp p [st] → ∃ sts, Except.ok sts = ((run [st] (CallElim.callElimStmts · p))) -- NOTE: the generated variables will not be local, but temp. So it will not be well-formed @@ -335,7 +335,7 @@ theorem updatedStateIsDefinedMono : theorem EvalExpressionUpdatedState {δ : BoogieEval}: Imperative.WellFormedSemanticEvalVar δ → -Boogie.WellFormedBoogieEvalCong δ → +Core.WellFormedBoogieEvalCong δ → Imperative.WellFormedSemanticEvalVal δ → ¬ k ∈ (Imperative.HasVarsPure.getVars e) → δ σ e = some v' → @@ -366,11 +366,11 @@ Imperative.WellFormedSemanticEvalVal δ → theorem EvalExpressionsUpdatedState {δ : BoogieEval} : Imperative.WellFormedSemanticEvalVar δ → - Boogie.WellFormedBoogieEvalCong δ → + Core.WellFormedBoogieEvalCong δ → Imperative.WellFormedSemanticEvalVal δ → ¬ k ∈ es.flatMap Imperative.HasVarsPure.getVars → - EvalExpressions (P:=Boogie.Expression) δ σ es vs → - EvalExpressions (P:=Boogie.Expression) δ (updatedState σ k v) es vs := by + EvalExpressions (P:=Core.Expression) δ σ es vs → + EvalExpressions (P:=Core.Expression) δ (updatedState σ k v) es vs := by intros Hwfv Hwfc Hwfvl Hnin Heval have Hlen := EvalExpressionsLength Heval induction es generalizing vs σ @@ -391,7 +391,7 @@ theorem EvalExpressionsUpdatedState {δ : BoogieEval} : theorem EvalExpressionUpdatedStates {δ : BoogieEval} : Imperative.WellFormedSemanticEvalVar δ → - Boogie.WellFormedBoogieEvalCong δ → + Core.WellFormedBoogieEvalCong δ → Imperative.WellFormedSemanticEvalVal δ → ks'.length = vs'.length → ks'.Nodup → @@ -422,13 +422,13 @@ theorem EvalExpressionUpdatedStates {δ : BoogieEval} : theorem EvalExpressionsUpdatedStates {δ : BoogieEval} : Imperative.WellFormedSemanticEvalVar δ → - Boogie.WellFormedBoogieEvalCong δ → + Core.WellFormedBoogieEvalCong δ → Imperative.WellFormedSemanticEvalVal δ → ks'.length = vs'.length → ks'.Nodup → ks'.Disjoint (es.flatMap Imperative.HasVarsPure.getVars) → - EvalExpressions (P:=Boogie.Expression) δ σ es vs → - EvalExpressions (P:=Boogie.Expression) δ (updatedStates σ ks' vs') es vs := by + EvalExpressions (P:=Core.Expression) δ σ es vs → + EvalExpressions (P:=Core.Expression) δ (updatedStates σ ks' vs') es vs := by intros Hwfv Hwfc Hwfvl Hlen Hnd Hnin Heval have Hlen := EvalExpressionsLength Heval induction ks' generalizing vs' σ @@ -706,7 +706,7 @@ theorem EvalStatementsContractInits : -- the generated old variable names shouldn't overlap with original variables trips.unzip.1.unzip.1.Disjoint (List.flatMap (Imperative.HasVarsPure.getVars (P:=Expression)) trips.unzip.2) → List.Nodup (trips.unzip.1.unzip.1) → - EvalExpressions (P:=Boogie.Expression) δ σ (trips.unzip.2) vvs → + EvalExpressions (P:=Core.Expression) δ σ (trips.unzip.2) vvs → -- ReadValues σ (trips.unzip.2) vvs → Imperative.isNotDefined σ (trips.unzip.1.unzip.1) → EvalStatementsContract π δ σ @@ -799,7 +799,7 @@ theorem createFvarsSubstStores : Imperative.substDefined σ σA (ks1.zip ks2) → Imperative.substStores σ σA (ks1.zip ks2) → ReadValues σA ks2 argVals → - EvalExpressions (P:=Boogie.Expression) δ σ (createFvars ks1) argVals := by + EvalExpressions (P:=Core.Expression) δ σ (createFvars ks1) argVals := by intros Hlen Hwfv Hdef Hsubst Hrd simp [createFvars] have Hlen2 := ReadValuesLength Hrd @@ -1110,7 +1110,7 @@ case cons h t ih => because then we can't say anything about the stores due to not knowing the exact form of the expressions -/ theorem Lambda.LExpr.substFvarCorrect : - Boogie.WellFormedBoogieEvalCong δ → + Core.WellFormedBoogieEvalCong δ → Imperative.WellFormedSemanticEvalVar (P:=Expression) δ → Imperative.WellFormedSemanticEvalVal (P:=Expression) δ → Imperative.substStores σ σ' [(fro, to)] → @@ -1210,7 +1210,7 @@ theorem Lambda.LExpr.substFvarCorrect : apply Hwfc.eqcongr <;> grind theorem Lambda.LExpr.substFvarsCorrectZero : - Boogie.WellFormedBoogieEvalCong δ → + Core.WellFormedBoogieEvalCong δ → Imperative.WellFormedSemanticEvalVar δ → Imperative.WellFormedSemanticEvalVal δ → Imperative.invStores σ σ' (Imperative.HasVarsPure.getVars e) → @@ -1572,7 +1572,7 @@ theorem createAssertsCorrect : Imperative.WellFormedSemanticEvalVar δ → Imperative.WellFormedSemanticEvalVal δ → -- TODO: remove congruence of old expressions, and require pre to contain no old expressions - Boogie.WellFormedBoogieEvalCong δ → + Core.WellFormedBoogieEvalCong δ → ks.length = ks'.length → Imperative.substNodup (ks.zip ks') → Imperative.substDefined σA σ' (ks.zip ks') → @@ -1630,7 +1630,7 @@ theorem createAssumesCorrect : Imperative.WellFormedSemanticEvalBool δ → Imperative.WellFormedSemanticEvalVar δ → Imperative.WellFormedSemanticEvalVal δ → - Boogie.WellFormedBoogieEvalCong δ → + Core.WellFormedBoogieEvalCong δ → ks.length = ks'.length → Imperative.substNodup (ks.zip ks') → Imperative.substDefined σA σ' (ks.zip ks') → @@ -1719,8 +1719,8 @@ theorem createOldStoreSubstEq : theorem substOldCorrect : Imperative.WellFormedSemanticEvalVar δ → Imperative.WellFormedSemanticEvalVal δ → - Boogie.WellFormedBoogieEvalCong δ → - Boogie.WellFormedBoogieEvalTwoState δ σ₀ σ → + Core.WellFormedBoogieEvalCong δ → + Core.WellFormedBoogieEvalTwoState δ σ₀ σ → OldExpressions.NormalizedOldExpr e → --Imperative.invStores σ₀ σ -- ((OldExpressions.extractOldExprVars e).removeAll [fro]) → @@ -2086,7 +2086,7 @@ theorem substOldExpr_cons: rename_i _ fn e _ _ H generalize H1: (OldExpressions.substOld h.snd (Lambda.LExpr.fvar () h.fst.fst none) fn) = fn' generalize H2: (OldExpressions.substOld h.snd (Lambda.LExpr.fvar () h.fst.fst none) e) = e' - rw (occs := [3]) [Boogie.OldExpressions.substsOldExpr.eq_def] + rw (occs := [3]) [Core.OldExpressions.substsOldExpr.eq_def] simp; split simp_all [Map.isEmpty]; rename_i H; split at H <;> simp_all rw[OldExpressions.substOldExpr_nil, OldExpressions.substOldExpr_nil]; simp @@ -2128,8 +2128,8 @@ theorem substOldExpr_cons: theorem substsOldCorrect : Imperative.WellFormedSemanticEvalVar δ → Imperative.WellFormedSemanticEvalVal δ → - Boogie.WellFormedBoogieEvalCong δ → - Boogie.WellFormedBoogieEvalTwoState δ σ₀ σ → + Core.WellFormedBoogieEvalCong δ → + Core.WellFormedBoogieEvalTwoState δ σ₀ σ → OldExpressions.NormalizedOldExpr e → Imperative.substStores σ₀ σ (createOldStoreSubst oldTrips) → Imperative.substDefined σ₀ σ (createOldStoreSubst oldTrips) → diff --git a/Strata/Transform/CoreTransform.lean b/Strata/Transform/CoreTransform.lean index 90daf71fa..ba508be33 100644 --- a/Strata/Transform/CoreTransform.lean +++ b/Strata/Transform/CoreTransform.lean @@ -11,7 +11,7 @@ import Strata.DL.Util.LabelGen /-! # Utility functions for program transformation in Strata Core -/ -namespace Boogie +namespace Core namespace Transform open LabelGen @@ -263,4 +263,4 @@ def run {α : Type} (p : α) (f : α → CoreTransformM β) (runWith p f s).fst end Transform -end Boogie +end Core diff --git a/Strata/Transform/DetToNondetCorrect.lean b/Strata/Transform/DetToNondetCorrect.lean index 86c5e62d5..9b22a9922 100644 --- a/Strata/Transform/DetToNondetCorrect.lean +++ b/Strata/Transform/DetToNondetCorrect.lean @@ -16,7 +16,7 @@ import Strata.Transform.DetToNondet `StmtToNondetStmtCorrect`) -/ -open Imperative Boogie +open Imperative Core /-- The proof implementation for `StmtToNondetStmtCorrect` and diff --git a/Strata/Transform/LoopElim.lean b/Strata/Transform/LoopElim.lean index 1a5f435f2..69d8e5772 100644 --- a/Strata/Transform/LoopElim.lean +++ b/Strata/Transform/LoopElim.lean @@ -6,7 +6,7 @@ import Strata.DL.Imperative.Stmt -namespace Boogie +namespace Core open Imperative Lambda /-! ## Loop elimination diff --git a/Strata/Transform/ProcedureInlining.lean b/Strata/Transform/ProcedureInlining.lean index dcf9a8236..54578c7a3 100644 --- a/Strata/Transform/ProcedureInlining.lean +++ b/Strata/Transform/ProcedureInlining.lean @@ -14,7 +14,7 @@ import Strata.Transform.CoreTransform /-! # Procedure Inlining Transformation -/ -namespace Boogie +namespace Core namespace ProcedureInlining open Transform @@ -26,7 +26,7 @@ def Block.substFvar (b : Block) (fr:Expression.Ident) termination_by b.sizeOf decreasing_by apply Imperative.sizeOf_stmt_in_block; assumption -def Statement.substFvar (s : Boogie.Statement) +def Statement.substFvar (s : Core.Statement) (fr:Expression.Ident) (to:Expression.Expr) : Statement := match s with @@ -65,7 +65,7 @@ def Block.renameLhs (b : Block) (fr: Lambda.Identifier Visibility) (to: Lambda.I termination_by b.sizeOf decreasing_by apply Imperative.sizeOf_stmt_in_block; assumption -def Statement.renameLhs (s : Boogie.Statement) (fr: Lambda.Identifier Visibility) (to: Lambda.Identifier Visibility) +def Statement.renameLhs (s : Core.Statement) (fr: Lambda.Identifier Visibility) (to: Lambda.Identifier Visibility) : Statement := match s with | .init lhs ty rhs metadata => @@ -95,7 +95,7 @@ def Block.labels (b : Block): List String := -- Assume and Assert's labels have special meanings, so they must not be -- mangled during procedure inlining. -def Statement.labels (s : Boogie.Statement) : List String := +def Statement.labels (s : Core.Statement) : List String := match s with | .block lbl b _ => lbl :: (Block.labels b) | .ite _ thenb elseb _ => (Block.labels thenb) ++ (Block.labels elseb) @@ -114,7 +114,7 @@ def Block.replaceLabels (b : Block) (map:Map String String) decreasing_by apply Imperative.sizeOf_stmt_in_block; assumption def Statement.replaceLabels - (s : Boogie.Statement) (map:Map String String) : Boogie.Statement := + (s : Core.Statement) (map:Map String String) : Core.Statement := let app (s:String) := match Map.find? map s with | .none => s @@ -248,7 +248,7 @@ def inlineCallCmd (excluded_calls:List String := []) Statement.set lhs_var (.fvar () out_var (.none))) outs_lhs_and_sig - let stmts:List (Imperative.Stmt Boogie.Expression Boogie.Command) + let stmts:List (Imperative.Stmt Core.Expression Core.Command) := inputInits ++ outputInits ++ outputHavocs ++ proc.body ++ outputSetStmts @@ -265,4 +265,4 @@ def inlineCallL (dcls : List Decl) (prog : Program) runProcedures inlineCallCmd dcls prog end ProcedureInlining -end Boogie +end Core diff --git a/StrataCoreToGoto.lean b/StrataCoreToGoto.lean index dab8c7f16..329c7824c 100644 --- a/StrataCoreToGoto.lean +++ b/StrataCoreToGoto.lean @@ -10,7 +10,7 @@ import StrataTest.Backends.CBMC.SimpleAdd.SimpleAdd def main (args : List String) : IO Unit := do match args with | ["writeFiles"] => - BoogieToGOTO.writeToGotoJson (programName := "simpleAdd") + CoreToGOTO.writeToGotoJson (programName := "simpleAdd") (symTabFileName := "StrataTest/Backends/CBMC/SimpleAdd/simpleAdd.symtab.json") (gotoFileName := "StrataTest/Backends/CBMC/SimpleAdd/simpleAdd.goto.json") Strata.simpleAdd diff --git a/StrataMain.lean b/StrataMain.lean index 453e25c47..71f1b22db 100644 --- a/StrataMain.lean +++ b/StrataMain.lean @@ -181,12 +181,12 @@ def readPythonStrata (path : String) : IO Strata.Program := do def pyTranslateCommand : Command where name := "pyTranslate" args := [ "file" ] - help := "Translate a Strata Python Ion file to Strata.Boogie. Write results to stdout." + help := "Translate a Strata Python Ion file to Strata Core. Write results to stdout." callback := fun _ v => do let pgm ← readPythonStrata v[0] let preludePgm := Strata.Python.Internal.Boogie.prelude let bpgm := Strata.pythonToBoogie Strata.Python.Internal.signatures pgm - let newPgm : Boogie.Program := { decls := preludePgm.decls ++ bpgm.decls } + let newPgm : Core.Program := { decls := preludePgm.decls ++ bpgm.decls } IO.print newPgm def pyAnalyzeCommand : Command where @@ -200,11 +200,11 @@ def pyAnalyzeCommand : Command where IO.print pgm let preludePgm := Strata.Python.Internal.Boogie.prelude let bpgm := Strata.pythonToBoogie Strata.Python.Internal.signatures pgm - let newPgm : Boogie.Program := { decls := preludePgm.decls ++ bpgm.decls } + let newPgm : Core.Program := { decls := preludePgm.decls ++ bpgm.decls } if verbose then IO.print newPgm - match Boogie.Transform.runProgram - (Boogie.ProcedureInlining.inlineCallCmd (excluded_calls := ["main"])) + match Core.Transform.runProgram + (Core.ProcedureInlining.inlineCallCmd (excluded_calls := ["main"])) newPgm .emp with | ⟨.error e, _⟩ => panic! e | ⟨.ok newPgm, _⟩ => @@ -213,7 +213,7 @@ def pyAnalyzeCommand : Command where IO.print newPgm let solverName : String := "Strata/Languages/Python/z3_parallel.py" let vcResults ← EIO.toIO (fun f => IO.Error.userError (toString f)) - (Boogie.verify solverName newPgm { Options.default with stopOnFirstError := false, verbose, removeIrrelevantAxioms := true } + (Core.verify solverName newPgm { Options.default with stopOnFirstError := false, verbose, removeIrrelevantAxioms := true } (moreFns := Strata.Python.ReFactory)) let mut s := "" for vcResult in vcResults do diff --git a/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean b/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean index a3035cbce..49f5d6c0b 100644 --- a/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean +++ b/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean @@ -21,7 +21,7 @@ model-check a Strata-generated GOTO binary. ------------------------------------------------------------------------------- -abbrev BoogieParams : Lambda.LExprParams := ⟨Unit, Boogie.Visibility⟩ +abbrev BoogieParams : Lambda.LExprParams := ⟨Unit, Core.Visibility⟩ abbrev Boogie.ExprStr : Imperative.PureExpr := { Ident := BoogieParams.Identifier, @@ -32,9 +32,9 @@ abbrev Boogie.ExprStr : Imperative.PureExpr := EvalEnv := Lambda.LState BoogieParams EqIdent := inferInstanceAs (DecidableEq BoogieParams.Identifier) } -namespace BoogieToGOTO +namespace CoreToGOTO -private def lookupType (T : Boogie.Expression.TyEnv) (i : Boogie.Expression.Ident) : +private def lookupType (T : Core.Expression.TyEnv) (i : Core.Expression.Ident) : Except Format CProverGOTO.Ty := match T.context.types.find? i with | none => .error s!"Cannot find {i} in the type context!" @@ -44,11 +44,11 @@ private def lookupType (T : Boogie.Expression.TyEnv) (i : Boogie.Expression.Iden ty.toGotoType else .error f!"Poly-type unexpected in the context for {i}: {ty}" -private def updateType (T : Boogie.Expression.TyEnv) (i : Boogie.Expression.Ident) - (ty : Boogie.Expression.Ty) : Boogie.Expression.TyEnv := - @Lambda.TEnv.insertInContext ⟨Boogie.ExpressionMetadata, Boogie.Visibility⟩ _ T i ty +private def updateType (T : Core.Expression.TyEnv) (i : Core.Expression.Ident) + (ty : Core.Expression.Ty) : Core.Expression.TyEnv := + @Lambda.TEnv.insertInContext ⟨Core.ExpressionMetadata, Core.Visibility⟩ _ T i ty -instance : Imperative.ToGoto Boogie.Expression where +instance : Imperative.ToGoto Core.Expression where lookupType := lookupType updateType := updateType identToString := (fun i => i.toPretty) @@ -78,36 +78,36 @@ instance : Imperative.ToGoto Boogie.ExprStr where open Lambda in def substVarNames {Metadata IDMeta: Type} [DecidableEq IDMeta] - (e : LExpr ⟨⟨Metadata, IDMeta⟩, LMonoTy⟩) (frto : Map String String) : (LExpr ⟨⟨Unit, Boogie.Visibility⟩, LMonoTy⟩) := + (e : LExpr ⟨⟨Metadata, IDMeta⟩, LMonoTy⟩) (frto : Map String String) : (LExpr ⟨⟨Unit, Core.Visibility⟩, LMonoTy⟩) := match e with | .const _ c => .const () c | .bvar _ b => .bvar () b - | .op _ o ty => .op () (Lambda.Identifier.mk o.name Boogie.Visibility.unres) ty + | .op _ o ty => .op () (Lambda.Identifier.mk o.name Core.Visibility.unres) ty | .fvar _ name ty => let name_alt := frto.find? name.name - .fvar () (Lambda.Identifier.mk (name_alt.getD name.name) Boogie.Visibility.unres) ty + .fvar () (Lambda.Identifier.mk (name_alt.getD name.name) Core.Visibility.unres) ty | .abs _ ty e' => .abs () ty (substVarNames e' frto) | .quant _ qk ty tr' e' => .quant () qk ty (substVarNames tr' frto) (substVarNames e' frto) | .app _ f e' => .app () (substVarNames f frto) (substVarNames e' frto) | .ite _ c t e' => .ite () (substVarNames c frto) (substVarNames t frto) (substVarNames e' frto) | .eq _ e1 e2 => .eq () (substVarNames e1 frto) (substVarNames e2 frto) -def Boogie.Cmd.renameVars (frto : Map String String) (c : Imperative.Cmd Boogie.Expression) +def Boogie.Cmd.renameVars (frto : Map String String) (c : Imperative.Cmd Core.Expression) : Imperative.Cmd Boogie.ExprStr := match c with | .init name ty e _ => let e' := substVarNames e frto - let name_alt := frto.find? (Boogie.BoogieIdent.toPretty name) - let new := name_alt.getD (Boogie.BoogieIdent.toPretty name) + let name_alt := frto.find? (Core.BoogieIdent.toPretty name) + let new := name_alt.getD (Core.BoogieIdent.toPretty name) .init new ty e' .empty | .set name e _ => let e' := substVarNames e frto - let name_alt := frto.find? (Boogie.BoogieIdent.toPretty name) - let new := name_alt.getD (Boogie.BoogieIdent.toPretty name) + let name_alt := frto.find? (Core.BoogieIdent.toPretty name) + let new := name_alt.getD (Core.BoogieIdent.toPretty name) .set new e' .empty | .havoc name _ => - let name_alt := frto.find? (Boogie.BoogieIdent.toPretty name) - let new := name_alt.getD (Boogie.BoogieIdent.toPretty name) + let name_alt := frto.find? (Core.BoogieIdent.toPretty name) + let new := name_alt.getD (Core.BoogieIdent.toPretty name) .havoc new .empty | .assume label e _ => let e' := substVarNames e frto @@ -120,7 +120,7 @@ def Boogie.Cmd.renameVars (frto : Map String String) (c : Imperative.Cmd Boogie. .cover label e' .empty def Boogie.Cmds.renameVars (frto : Map String String) - (cs : Imperative.Cmds Boogie.Expression) : Imperative.Cmds Boogie.ExprStr := + (cs : Imperative.Cmds Core.Expression) : Imperative.Cmds Boogie.ExprStr := match cs with | [] => [] | c :: crest => [(Boogie.Cmd.renameVars frto c)] ++ (renameVars frto crest) @@ -155,18 +155,18 @@ def CProverGOTO.Context.toJson (programName : String) (ctx : CProverGOTO.Context { symtab := symbols, goto := goto_functions } open Lambda.LTy.Syntax in -def transformToGoto (boogie : Boogie.Program) : Except Format CProverGOTO.Context := do - let Ctx := { Lambda.LContext.default with functions := Boogie.Factory, knownTypes := Boogie.KnownTypes } +def transformToGoto (boogie : Core.Program) : Except Format CProverGOTO.Context := do + let Ctx := { Lambda.LContext.default with functions := Core.Factory, knownTypes := Core.KnownTypes } let Env := Lambda.TEnv.default - let (boogie, _Env) ← Boogie.Program.typeCheck Ctx Env boogie - dbg_trace f!"[Strata.Boogie] Type Checking Succeeded!" + let (boogie, _Env) ← Core.Program.typeCheck Ctx Env boogie + dbg_trace f!"[Strata.Core] Type Checking Succeeded!" if h : boogie.decls.length = 1 then let decl := boogie.decls[0]'(by exact Nat.lt_of_sub_eq_succ h) match decl.getProc? with - | none => .error f!"[transformToGoto] We can process only Boogie procedures at this time. \ + | none => .error f!"[transformToGoto] We can process only Strata Core procedures at this time. \ Declaration encountered: {decl}" | some p => - let pname := Boogie.BoogieIdent.toPretty p.header.name + let pname := Core.BoogieIdent.toPretty p.header.name if !p.header.typeArgs.isEmpty then .error f!"[transformToGoto] Translation for polymorphic Boogie procedures is unimplemented." @@ -182,13 +182,13 @@ def transformToGoto (boogie : Boogie.Program) : Except Format CProverGOTO.Contex let ret_tys ← p.header.outputs.values.mapM (fun ty => Lambda.LMonoTy.toGotoType ty) let ret_ty := if ret_tys.isEmpty then CProverGOTO.Ty.Empty else ret_tys[0]! - let formals := p.header.inputs.keys.map Boogie.BoogieIdent.toPretty + let formals := p.header.inputs.keys.map Core.BoogieIdent.toPretty let formals_tys ← p.header.inputs.values.mapM (fun ty => Lambda.LMonoTy.toGotoType ty) let new_formals := formals.map (fun f => CProverGOTO.mkFormalSymbol pname f) let formals_renamed := formals.zip new_formals let formals_tys : Map String CProverGOTO.Ty := formals.zip formals_tys - let locals := (Imperative.Block.definedVars p.body).map Boogie.BoogieIdent.toPretty + let locals := (Imperative.Block.definedVars p.body).map Core.BoogieIdent.toPretty let new_locals := locals.map (fun l => CProverGOTO.mkLocalSymbol pname l) let locals_renamed := locals.zip new_locals @@ -196,7 +196,7 @@ def transformToGoto (boogie : Boogie.Program) : Except Format CProverGOTO.Contex let cmds := Boogie.Cmds.renameVars args_renamed cmds let ans ← @Imperative.Cmds.toGotoTransform Boogie.ExprStr - BoogieToGOTO.instToGotoExprStr _ Env pname cmds (loc := 0) + CoreToGOTO.instToGotoExprStr _ Env pname cmds (loc := 0) let ending_insts : Array CProverGOTO.Instruction := #[ -- (FIXME): Add lifetime markers. -- { type := .DEAD, locationNum := ans.nextLoc + 1, @@ -204,7 +204,7 @@ def transformToGoto (boogie : Boogie.Program) : Except Format CProverGOTO.Contex { type := .END_FUNCTION, locationNum := ans.nextLoc + 1}] let insts := ans.instructions ++ ending_insts - let pgm := { name := Boogie.BoogieIdent.toPretty p.header.name, + let pgm := { name := Core.BoogieIdent.toPretty p.header.name, parameterIdentifiers := new_formals.toArray, instructions := insts } @@ -220,7 +220,7 @@ open Strata in def getGotoJson (programName : String) (env : Program) : IO CProverGOTO.Json := do let (program, errors) := TransM.run Inhabited.default (translateProgram env) if errors.isEmpty then - (match (BoogieToGOTO.transformToGoto program) with + (match (CoreToGOTO.transformToGoto program) with | .error e => dbg_trace s!"{e}" return {} @@ -235,6 +235,6 @@ def writeToGotoJson (programName symTabFileName gotoFileName : String) (env : Pr IO.FS.writeFile symTabFileName json.symtab.pretty IO.FS.writeFile gotoFileName json.goto.pretty -end BoogieToGOTO +end CoreToGOTO ------------------------------------------------------------------------------- diff --git a/StrataTest/DDM/Integration/Java/TestGen.lean b/StrataTest/DDM/Integration/Java/TestGen.lean index 40d390af4..01c08f3be 100644 --- a/StrataTest/DDM/Integration/Java/TestGen.lean +++ b/StrataTest/DDM/Integration/Java/TestGen.lean @@ -223,19 +223,19 @@ def check (s sub : String) : Bool := (s.splitOn sub).length > 1 assert! files.interfaces.any (fun i => check i.2 "non-sealed interface Expr") pure () --- Test 10: Boogie dialect returns error (has type/function declarations not yet supported) -elab "#testBoogieError" : command => do +-- Test 10: Core dialect returns error (has type/function declarations not yet supported) +elab "#testCoreError" : command => do let env ← Lean.getEnv let state := Strata.dialectExt.getState env - let some boogie := state.loaded.dialects["Boogie"]? - | Lean.logError "Boogie dialect not found"; return - match generateDialect boogie "com.strata.boogie" with + let some core := state.loaded.dialects["Core"]? + | Lean.logError "Core dialect not found"; return + match generateDialect core "com.strata.core" with | .error msg => if !(check msg "type declaration" || check msg "function declaration") then Lean.logError s!"Expected error about type/function declaration, got: {msg}" - | .ok _ => Lean.logError "Expected error for Boogie dialect" + | .ok _ => Lean.logError "Expected error for Core dialect" -#testBoogieError +#testCoreError -- Test 11: Cross-dialect name collision (A.Num vs B.Num) #eval do diff --git a/StrataTest/Internal/InternalBoogiePrelude.lean b/StrataTest/Internal/InternalBoogiePrelude.lean index f44231686..f617f6920 100644 --- a/StrataTest/Internal/InternalBoogiePrelude.lean +++ b/StrataTest/Internal/InternalBoogiePrelude.lean @@ -14,7 +14,7 @@ namespace Strata namespace Python namespace Internal -def Boogie.prelude : Boogie.Program := Strata.Boogie.prelude +def Boogie.prelude : Core.Program := Strata.Boogie.prelude end Internal end Python diff --git a/StrataTest/Languages/Boogie/DatatypeVerificationTests.lean b/StrataTest/Languages/Boogie/DatatypeVerificationTests.lean index 6eaa6f5f9..8db0230a1 100644 --- a/StrataTest/Languages/Boogie/DatatypeVerificationTests.lean +++ b/StrataTest/Languages/Boogie/DatatypeVerificationTests.lean @@ -11,10 +11,10 @@ import Strata.DL.Lambda.TypeFactory /-! # Datatype Verification Integration Tests -Verify Boogie programs with datatypes, encoding with declare-datatype +Verify Strata Core programs with datatypes, encoding with declare-datatype -/ -namespace Boogie.DatatypeVerificationTests +namespace Core.DatatypeVerificationTests open Lambda open Std (ToFormat Format) @@ -108,7 +108,7 @@ Run verification and return a summary string. -/ def runVerificationTest (testName : String) (program : Program) : IO String := do try - match ← EIO.toIO' (Boogie.verify "cvc5" program Options.quiet) with + match ← EIO.toIO' (Core.verify "cvc5" program Options.quiet) with | .error err => return s!"{testName}: FAILED\n Error: {err}" | .ok results => @@ -614,4 +614,4 @@ info: "Test 8 - Hidden Type Recursion: PASSED\n Verified 1 obligation(s)\n" #eval test8_hiddenTypeRecursion -end Boogie.DatatypeVerificationTests +end Core.DatatypeVerificationTests diff --git a/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean b/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean index 6b848a7b0..6c6776ba8 100644 --- a/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean +++ b/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean @@ -82,7 +82,7 @@ Errors: #[] #eval TransM.run Inhabited.default (translateProgram mapPgm) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean b/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean index 648523d18..fefbed66e 100644 --- a/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean +++ b/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean @@ -25,7 +25,7 @@ spec { /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean b/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean index 149edadc8..3fb9a542c 100644 --- a/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean +++ b/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean @@ -41,7 +41,7 @@ Errors: #[] #eval TransM.run Inhabited.default (translateProgram assertionNames) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/Axioms.lean b/StrataTest/Languages/Boogie/Examples/Axioms.lean index 86c11367c..6d967c819 100644 --- a/StrataTest/Languages/Boogie/Examples/Axioms.lean +++ b/StrataTest/Languages/Boogie/Examples/Axioms.lean @@ -42,7 +42,7 @@ procedure P2() returns () #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: @@ -130,10 +130,10 @@ assert [axiomPgm2_main_assert]: (x >= 0 ==> f(x) > x); /-- info: [] -/ #guard_msgs in #eval let (program, _) := Boogie.getProgram axiomPgm2 - Std.format (Boogie.Program.getIrrelevantAxioms program ["f"]) + Std.format (Core.Program.getIrrelevantAxioms program ["f"]) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/BitVecParse.lean b/StrataTest/Languages/Boogie/Examples/BitVecParse.lean index 467cd7f87..488698897 100644 --- a/StrataTest/Languages/Boogie/Examples/BitVecParse.lean +++ b/StrataTest/Languages/Boogie/Examples/BitVecParse.lean @@ -23,7 +23,7 @@ procedure bitVecParseTest() returns () { #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean b/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean index e448ed2ce..b030c92c7 100644 --- a/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean +++ b/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean @@ -23,8 +23,8 @@ axiom [updatePreserves]: forall m: Map k v, okk: k, kk: k, vv: v :: m[kk := vv][ /-- This function extracts the Boogie.Decl in the given program that are axiom declarations -/ -def extractAxiomsDecl (prg: Boogie.Program) : (List Boogie.Decl) := - let rec loop (acc: List Boogie.Decl) (l: List Boogie.Decl): List Boogie.Decl := +def extractAxiomsDecl (prg: Core.Program) : (List Core.Decl) := + let rec loop (acc: List Core.Decl) (l: List Core.Decl): List Core.Decl := match l with | [] => acc | hd :: tl => @@ -36,7 +36,7 @@ def extractAxiomsDecl (prg: Boogie.Program) : (List Boogie.Decl) := /-- Extract the body LExpr from the axiom declaration -/ -def extractExpr (axDecl: Boogie.Decl): Boogie.Expression.Expr := +def extractExpr (axDecl: Core.Decl): Core.Expression.Expr := match axDecl with | .ax a _ => a.e | _ => panic "Can be called only on axiom declaration" @@ -61,7 +61,7 @@ def transformSimpleTypeToFreeVariable (ty: Lambda.LMonoTy) (to_replace: List Str Transform all occurences of types of the form LMonoTy.tcons name [] into ftvar name, if name is in to_replace in the given expression -/ -def replaceTypesByFTV (expr: Boogie.Expression.Expr) (to_replace: List String): Boogie.Expression.Expr := +def replaceTypesByFTV (expr: Core.Expression.Expr) (to_replace: List String): Core.Expression.Expr := match expr with | .const m c => .const m c | .op m o oty => .op m o (oty.map (fun t => transformSimpleTypeToFreeVariable t to_replace)) @@ -77,8 +77,8 @@ def replaceTypesByFTV (expr: Boogie.Expression.Expr) (to_replace: List String): Extract all axioms from the given environment by first translating it into a Boogie Program. It then extracts LExpr body from the axioms, and replace all occurences of the typeArgs by a ftvar with the same name -/ -def extractAxiomsWithFreeTypeVars (pgm: Program) (typeArgs: List String): (List Boogie.Expression.Expr) := - let prg: Boogie.Program := (TransM.run Inhabited.default (translateProgram pgm)).fst +def extractAxiomsWithFreeTypeVars (pgm: Program) (typeArgs: List String): (List Core.Expression.Expr) := + let prg: Core.Program := (TransM.run Inhabited.default (translateProgram pgm)).fst let axiomsDecls := extractAxiomsDecl prg let axioms := axiomsDecls.map extractExpr axioms.map (fun a => replaceTypesByFTV a typeArgs) @@ -94,302 +94,302 @@ axiom [updatePreserves]:forall((((m):(Map v k)),((okk):(k))),((kk):(k))),((vv):( #eval IO.println examplePgm.format.render /-- -info: #[{ ann := { start := { byteIdx := 295 }, stop := { byteIdx := 302 } }, - name := { dialect := "Boogie", name := "command_typedecl" }, +info: #[{ ann := { start := { byteIdx := 293 }, stop := { byteIdx := 300 } }, + name := { dialect := "Core", name := "command_typedecl" }, args := - ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 300 }, stop := { byteIdx := 301 } } "k")).push - (ArgF.option { start := { byteIdx := 301 }, stop := { byteIdx := 301 } } none) }, - { ann := { start := { byteIdx := 303 }, stop := { byteIdx := 310 } }, - name := { dialect := "Boogie", name := "command_typedecl" }, + ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 298 }, stop := { byteIdx := 299 } } "k")).push + (ArgF.option { start := { byteIdx := 299 }, stop := { byteIdx := 299 } } none) }, + { ann := { start := { byteIdx := 301 }, stop := { byteIdx := 308 } }, + name := { dialect := "Core", name := "command_typedecl" }, args := - ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 308 }, stop := { byteIdx := 309 } } "v")).push - (ArgF.option { start := { byteIdx := 309 }, stop := { byteIdx := 309 } } none) }, - { ann := { start := { byteIdx := 311 }, stop := { byteIdx := 390 } }, - name := { dialect := "Boogie", name := "command_axiom" }, + ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 306 }, stop := { byteIdx := 307 } } "v")).push + (ArgF.option { start := { byteIdx := 307 }, stop := { byteIdx := 307 } } none) }, + { ann := { start := { byteIdx := 309 }, stop := { byteIdx := 388 } }, + name := { dialect := "Core", name := "command_axiom" }, args := ((Array.mkEmpty 2).push - (ArgF.option { start := { byteIdx := 317 }, stop := { byteIdx := 332 } } + (ArgF.option { start := { byteIdx := 315 }, stop := { byteIdx := 330 } } (some (ArgF.op - { ann := { start := { byteIdx := 317 }, stop := { byteIdx := 332 } }, - name := { dialect := "Boogie", name := "label" }, + { ann := { start := { byteIdx := 315 }, stop := { byteIdx := 330 } }, + name := { dialect := "Core", name := "label" }, args := (Array.mkEmpty 1).push - (ArgF.ident { start := { byteIdx := 318 }, stop := { byteIdx := 330 } } + (ArgF.ident { start := { byteIdx := 316 }, stop := { byteIdx := 328 } } "updateSelect") })))).push (ArgF.expr - (ExprF.app { start := { byteIdx := 333 }, stop := { byteIdx := 389 } } - (ExprF.app { start := { byteIdx := 333 }, stop := { byteIdx := 389 } } - (ExprF.fn { start := { byteIdx := 333 }, stop := { byteIdx := 389 } } - { dialect := "Boogie", name := "forall" }) + (ExprF.app { start := { byteIdx := 331 }, stop := { byteIdx := 387 } } + (ExprF.app { start := { byteIdx := 331 }, stop := { byteIdx := 387 } } + (ExprF.fn { start := { byteIdx := 331 }, stop := { byteIdx := 387 } } + { dialect := "Core", name := "forall" }) (ArgF.op - { ann := { start := { byteIdx := 340 }, stop := { byteIdx := 364 } }, - name := { dialect := "Boogie", name := "declPush" }, + { ann := { start := { byteIdx := 338 }, stop := { byteIdx := 362 } }, + name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 340 }, stop := { byteIdx := 357 } }, - name := { dialect := "Boogie", name := "declPush" }, + { ann := { start := { byteIdx := 338 }, stop := { byteIdx := 355 } }, + name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 340 }, stop := { byteIdx := 350 } }, - name := { dialect := "Boogie", name := "declAtom" }, + { ann := { start := { byteIdx := 338 }, stop := { byteIdx := 348 } }, + name := { dialect := "Core", name := "declAtom" }, args := (Array.mkEmpty 1).push (ArgF.op - { ann := { start := { byteIdx := 340 }, stop := { byteIdx := 350 } }, - name := { dialect := "Boogie", name := "bind_mk" }, + { ann := { start := { byteIdx := 338 }, stop := { byteIdx := 348 } }, + name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 340 }, - stop := { byteIdx := 341 } } + { start := { byteIdx := 338 }, + stop := { byteIdx := 339 } } "m")).push (ArgF.option - { start := { byteIdx := 343 }, stop := { byteIdx := 343 } } + { start := { byteIdx := 341 }, stop := { byteIdx := 341 } } none)).push (ArgF.type (TypeExprF.ident - { start := { byteIdx := 343 }, stop := { byteIdx := 346 } } - { dialect := "Boogie", name := "Map" } + { start := { byteIdx := 341 }, stop := { byteIdx := 344 } } + { dialect := "Core", name := "Map" } (((Array.mkEmpty 2).push (TypeExprF.fvar - { start := { byteIdx := 349 }, - stop := { byteIdx := 350 } } + { start := { byteIdx := 347 }, + stop := { byteIdx := 348 } } 1 (Array.mkEmpty 0))).push (TypeExprF.fvar - { start := { byteIdx := 347 }, - stop := { byteIdx := 348 } } + { start := { byteIdx := 345 }, + stop := { byteIdx := 346 } } 0 (Array.mkEmpty 0))))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 352 }, stop := { byteIdx := 357 } }, - name := { dialect := "Boogie", name := "bind_mk" }, + { ann := { start := { byteIdx := 350 }, stop := { byteIdx := 355 } }, + name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 352 }, stop := { byteIdx := 354 } } + { start := { byteIdx := 350 }, stop := { byteIdx := 352 } } "kk")).push - (ArgF.option { start := { byteIdx := 356 }, stop := { byteIdx := 356 } } + (ArgF.option { start := { byteIdx := 354 }, stop := { byteIdx := 354 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 356 }, stop := { byteIdx := 357 } } + (TypeExprF.fvar { start := { byteIdx := 354 }, stop := { byteIdx := 355 } } 0 (Array.mkEmpty 0))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 359 }, stop := { byteIdx := 364 } }, - name := { dialect := "Boogie", name := "bind_mk" }, + { ann := { start := { byteIdx := 357 }, stop := { byteIdx := 362 } }, + name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push - (ArgF.ident { start := { byteIdx := 359 }, stop := { byteIdx := 361 } } + (ArgF.ident { start := { byteIdx := 357 }, stop := { byteIdx := 359 } } "vv")).push - (ArgF.option { start := { byteIdx := 363 }, stop := { byteIdx := 363 } } none)).push + (ArgF.option { start := { byteIdx := 361 }, stop := { byteIdx := 361 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 363 }, stop := { byteIdx := 364 } } 1 + (TypeExprF.fvar { start := { byteIdx := 361 }, stop := { byteIdx := 362 } } 1 (Array.mkEmpty 0))) }) })) (ArgF.expr - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 389 } } - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 389 } } - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 389 } } - (ExprF.fn { start := { byteIdx := 368 }, stop := { byteIdx := 389 } } - { dialect := "Boogie", name := "equal" }) + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 387 } } + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 387 } } + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 387 } } + (ExprF.fn { start := { byteIdx := 366 }, stop := { byteIdx := 387 } } + { dialect := "Core", name := "equal" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 349 }, stop := { byteIdx := 350 } } 1 (Array.mkEmpty 0)))) + (TypeExprF.fvar { start := { byteIdx := 347 }, stop := { byteIdx := 348 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 383 } } - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 383 } } - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 383 } } - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 383 } } - (ExprF.fn { start := { byteIdx := 368 }, stop := { byteIdx := 383 } } - { dialect := "Boogie", name := "map_get" }) + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 381 } } + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 381 } } + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 381 } } + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 381 } } + (ExprF.fn { start := { byteIdx := 366 }, stop := { byteIdx := 381 } } + { dialect := "Core", name := "map_get" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 347 }, stop := { byteIdx := 348 } } 0 + (TypeExprF.fvar { start := { byteIdx := 345 }, stop := { byteIdx := 346 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 349 }, stop := { byteIdx := 350 } } 1 + (TypeExprF.fvar { start := { byteIdx := 347 }, stop := { byteIdx := 348 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 379 } } - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 379 } } - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 379 } } - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 379 } } - (ExprF.app { start := { byteIdx := 368 }, stop := { byteIdx := 379 } } - (ExprF.fn { start := { byteIdx := 368 }, stop := { byteIdx := 379 } } - { dialect := "Boogie", name := "map_set" }) + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } + (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } + (ExprF.fn { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } + { dialect := "Core", name := "map_set" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 347 }, stop := { byteIdx := 348 } } 0 + (TypeExprF.fvar { start := { byteIdx := 345 }, stop := { byteIdx := 346 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 349 }, stop := { byteIdx := 350 } } 1 + (TypeExprF.fvar { start := { byteIdx := 347 }, stop := { byteIdx := 348 } } 1 (Array.mkEmpty 0)))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 368 }, stop := { byteIdx := 369 } } 2))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 370 }, stop := { byteIdx := 372 } } 1))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 376 }, stop := { byteIdx := 378 } } 0))))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 380 }, stop := { byteIdx := 382 } } 1))))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 387 }, stop := { byteIdx := 389 } } 0)))))) }, - { ann := { start := { byteIdx := 391 }, stop := { byteIdx := 486 } }, - name := { dialect := "Boogie", name := "command_axiom" }, + (ArgF.expr (ExprF.bvar { start := { byteIdx := 366 }, stop := { byteIdx := 367 } } 2))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 368 }, stop := { byteIdx := 370 } } 1))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 374 }, stop := { byteIdx := 376 } } 0))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 378 }, stop := { byteIdx := 380 } } 1))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 385 }, stop := { byteIdx := 387 } } 0)))))) }, + { ann := { start := { byteIdx := 389 }, stop := { byteIdx := 484 } }, + name := { dialect := "Core", name := "command_axiom" }, args := ((Array.mkEmpty 2).push - (ArgF.option { start := { byteIdx := 397 }, stop := { byteIdx := 415 } } + (ArgF.option { start := { byteIdx := 395 }, stop := { byteIdx := 413 } } (some (ArgF.op - { ann := { start := { byteIdx := 397 }, stop := { byteIdx := 415 } }, - name := { dialect := "Boogie", name := "label" }, + { ann := { start := { byteIdx := 395 }, stop := { byteIdx := 413 } }, + name := { dialect := "Core", name := "label" }, args := (Array.mkEmpty 1).push - (ArgF.ident { start := { byteIdx := 398 }, stop := { byteIdx := 413 } } + (ArgF.ident { start := { byteIdx := 396 }, stop := { byteIdx := 411 } } "updatePreserves") })))).push (ArgF.expr - (ExprF.app { start := { byteIdx := 416 }, stop := { byteIdx := 485 } } - (ExprF.app { start := { byteIdx := 416 }, stop := { byteIdx := 485 } } - (ExprF.fn { start := { byteIdx := 416 }, stop := { byteIdx := 485 } } - { dialect := "Boogie", name := "forall" }) + (ExprF.app { start := { byteIdx := 414 }, stop := { byteIdx := 483 } } + (ExprF.app { start := { byteIdx := 414 }, stop := { byteIdx := 483 } } + (ExprF.fn { start := { byteIdx := 414 }, stop := { byteIdx := 483 } } + { dialect := "Core", name := "forall" }) (ArgF.op - { ann := { start := { byteIdx := 423 }, stop := { byteIdx := 455 } }, - name := { dialect := "Boogie", name := "declPush" }, + { ann := { start := { byteIdx := 421 }, stop := { byteIdx := 453 } }, + name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 423 }, stop := { byteIdx := 448 } }, - name := { dialect := "Boogie", name := "declPush" }, + { ann := { start := { byteIdx := 421 }, stop := { byteIdx := 446 } }, + name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 423 }, stop := { byteIdx := 441 } }, - name := { dialect := "Boogie", name := "declPush" }, + { ann := { start := { byteIdx := 421 }, stop := { byteIdx := 439 } }, + name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op { ann := - { start := { byteIdx := 423 }, stop := { byteIdx := 433 } }, - name := { dialect := "Boogie", name := "declAtom" }, + { start := { byteIdx := 421 }, stop := { byteIdx := 431 } }, + name := { dialect := "Core", name := "declAtom" }, args := (Array.mkEmpty 1).push (ArgF.op { ann := - { start := { byteIdx := 423 }, - stop := { byteIdx := 433 } }, - name := { dialect := "Boogie", name := "bind_mk" }, + { start := { byteIdx := 421 }, + stop := { byteIdx := 431 } }, + name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 423 }, - stop := { byteIdx := 424 } } + { start := { byteIdx := 421 }, + stop := { byteIdx := 422 } } "m")).push (ArgF.option - { start := { byteIdx := 426 }, - stop := { byteIdx := 426 } } + { start := { byteIdx := 424 }, + stop := { byteIdx := 424 } } none)).push (ArgF.type (TypeExprF.ident - { start := { byteIdx := 426 }, - stop := { byteIdx := 429 } } - { dialect := "Boogie", name := "Map" } + { start := { byteIdx := 424 }, + stop := { byteIdx := 427 } } + { dialect := "Core", name := "Map" } (((Array.mkEmpty 2).push (TypeExprF.fvar - { start := { byteIdx := 432 }, - stop := { byteIdx := 433 } } + { start := { byteIdx := 430 }, + stop := { byteIdx := 431 } } 1 (Array.mkEmpty 0))).push (TypeExprF.fvar - { start := { byteIdx := 430 }, - stop := { byteIdx := 431 } } + { start := { byteIdx := 428 }, + stop := { byteIdx := 429 } } 0 (Array.mkEmpty 0))))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 435 }, stop := { byteIdx := 441 } }, - name := { dialect := "Boogie", name := "bind_mk" }, + { ann := { start := { byteIdx := 433 }, stop := { byteIdx := 439 } }, + name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 435 }, - stop := { byteIdx := 438 } } + { start := { byteIdx := 433 }, + stop := { byteIdx := 436 } } "okk")).push (ArgF.option - { start := { byteIdx := 440 }, stop := { byteIdx := 440 } } + { start := { byteIdx := 438 }, stop := { byteIdx := 438 } } none)).push (ArgF.type (TypeExprF.fvar - { start := { byteIdx := 440 }, stop := { byteIdx := 441 } } 0 + { start := { byteIdx := 438 }, stop := { byteIdx := 439 } } 0 (Array.mkEmpty 0))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 443 }, stop := { byteIdx := 448 } }, - name := { dialect := "Boogie", name := "bind_mk" }, + { ann := { start := { byteIdx := 441 }, stop := { byteIdx := 446 } }, + name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 443 }, stop := { byteIdx := 445 } } + { start := { byteIdx := 441 }, stop := { byteIdx := 443 } } "kk")).push - (ArgF.option { start := { byteIdx := 447 }, stop := { byteIdx := 447 } } + (ArgF.option { start := { byteIdx := 445 }, stop := { byteIdx := 445 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 447 }, stop := { byteIdx := 448 } } + (TypeExprF.fvar { start := { byteIdx := 445 }, stop := { byteIdx := 446 } } 0 (Array.mkEmpty 0))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 450 }, stop := { byteIdx := 455 } }, - name := { dialect := "Boogie", name := "bind_mk" }, + { ann := { start := { byteIdx := 448 }, stop := { byteIdx := 453 } }, + name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push - (ArgF.ident { start := { byteIdx := 450 }, stop := { byteIdx := 452 } } + (ArgF.ident { start := { byteIdx := 448 }, stop := { byteIdx := 450 } } "vv")).push - (ArgF.option { start := { byteIdx := 454 }, stop := { byteIdx := 454 } } none)).push + (ArgF.option { start := { byteIdx := 452 }, stop := { byteIdx := 452 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 454 }, stop := { byteIdx := 455 } } 1 + (TypeExprF.fvar { start := { byteIdx := 452 }, stop := { byteIdx := 453 } } 1 (Array.mkEmpty 0))) }) })) (ArgF.expr - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 485 } } - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 485 } } - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 485 } } - (ExprF.fn { start := { byteIdx := 459 }, stop := { byteIdx := 485 } } - { dialect := "Boogie", name := "equal" }) + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 483 } } + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 483 } } + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 483 } } + (ExprF.fn { start := { byteIdx := 457 }, stop := { byteIdx := 483 } } + { dialect := "Core", name := "equal" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 432 }, stop := { byteIdx := 433 } } 1 (Array.mkEmpty 0)))) + (TypeExprF.fvar { start := { byteIdx := 430 }, stop := { byteIdx := 431 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 475 } } - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 475 } } - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 475 } } - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 475 } } - (ExprF.fn { start := { byteIdx := 459 }, stop := { byteIdx := 475 } } - { dialect := "Boogie", name := "map_get" }) + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 473 } } + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 473 } } + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 473 } } + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 473 } } + (ExprF.fn { start := { byteIdx := 457 }, stop := { byteIdx := 473 } } + { dialect := "Core", name := "map_get" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 430 }, stop := { byteIdx := 431 } } 0 + (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 432 }, stop := { byteIdx := 433 } } 1 + (TypeExprF.fvar { start := { byteIdx := 430 }, stop := { byteIdx := 431 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 470 } } - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 470 } } - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 470 } } - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 470 } } - (ExprF.app { start := { byteIdx := 459 }, stop := { byteIdx := 470 } } - (ExprF.fn { start := { byteIdx := 459 }, stop := { byteIdx := 470 } } - { dialect := "Boogie", name := "map_set" }) + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } + (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } + (ExprF.fn { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } + { dialect := "Core", name := "map_set" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 430 }, stop := { byteIdx := 431 } } 0 + (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 432 }, stop := { byteIdx := 433 } } 1 + (TypeExprF.fvar { start := { byteIdx := 430 }, stop := { byteIdx := 431 } } 1 (Array.mkEmpty 0)))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 459 }, stop := { byteIdx := 460 } } 3))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 461 }, stop := { byteIdx := 463 } } 1))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 467 }, stop := { byteIdx := 469 } } 0))))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 471 }, stop := { byteIdx := 474 } } 2))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 457 }, stop := { byteIdx := 458 } } 3))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 459 }, stop := { byteIdx := 461 } } 1))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 465 }, stop := { byteIdx := 467 } } 0))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 469 }, stop := { byteIdx := 472 } } 2))))) (ArgF.expr - (ExprF.app { start := { byteIdx := 479 }, stop := { byteIdx := 485 } } - (ExprF.app { start := { byteIdx := 479 }, stop := { byteIdx := 485 } } - (ExprF.app { start := { byteIdx := 479 }, stop := { byteIdx := 485 } } - (ExprF.app { start := { byteIdx := 479 }, stop := { byteIdx := 485 } } - (ExprF.fn { start := { byteIdx := 479 }, stop := { byteIdx := 485 } } - { dialect := "Boogie", name := "map_get" }) + (ExprF.app { start := { byteIdx := 477 }, stop := { byteIdx := 483 } } + (ExprF.app { start := { byteIdx := 477 }, stop := { byteIdx := 483 } } + (ExprF.app { start := { byteIdx := 477 }, stop := { byteIdx := 483 } } + (ExprF.app { start := { byteIdx := 477 }, stop := { byteIdx := 483 } } + (ExprF.fn { start := { byteIdx := 477 }, stop := { byteIdx := 483 } } + { dialect := "Core", name := "map_get" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 430 }, stop := { byteIdx := 431 } } 0 + (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 432 }, stop := { byteIdx := 433 } } 1 + (TypeExprF.fvar { start := { byteIdx := 430 }, stop := { byteIdx := 431 } } 1 (Array.mkEmpty 0)))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 479 }, stop := { byteIdx := 480 } } 3))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 481 }, stop := { byteIdx := 484 } } 2)))))))) }] + (ArgF.expr (ExprF.bvar { start := { byteIdx := 477 }, stop := { byteIdx := 478 } } 3))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 479 }, stop := { byteIdx := 482 } } 2)))))))) }] -/ #guard_msgs in #eval examplePgm.commands @@ -402,7 +402,7 @@ info: [LExpr.quant () QuantifierKind.all (some Lambda.LMonoTy.tcons "v"]) (LExpr.bvar () 0) (LExpr.quant () QuantifierKind.all (some Lambda.LMonoTy.ftvar "k") (LExpr.bvar () 0) (LExpr.quant () QuantifierKind.all (some Lambda.LMonoTy.ftvar "v") (LExpr.bvar () 0) (LExpr.eq () (LExpr.app () (LExpr.app () (LExpr.op () { name := "select", - metadata := Boogie.Visibility.unres } (some Lambda.LMonoTy.tcons + metadata := Core.Visibility.unres } (some Lambda.LMonoTy.tcons "arrow" [Lambda.LMonoTy.tcons "Map" [Lambda.LMonoTy.ftvar "k", Lambda.LMonoTy.ftvar "v"], Lambda.LMonoTy.tcons @@ -410,7 +410,7 @@ info: [LExpr.quant () QuantifierKind.all (some Lambda.LMonoTy.tcons [Lambda.LMonoTy.ftvar "k", Lambda.LMonoTy.ftvar "v"]])) (LExpr.app () (LExpr.app () (LExpr.app () (LExpr.op () { name := "update", - metadata := Boogie.Visibility.unres } (some Lambda.LMonoTy.tcons + metadata := Core.Visibility.unres } (some Lambda.LMonoTy.tcons "arrow" [Lambda.LMonoTy.tcons "Map" [Lambda.LMonoTy.ftvar "k", Lambda.LMonoTy.ftvar "v"], Lambda.LMonoTy.tcons @@ -432,7 +432,7 @@ info: [LExpr.quant () QuantifierKind.all (some Lambda.LMonoTy.tcons "k") (LExpr.bvar () 0) (LExpr.quant () QuantifierKind.all (some Lambda.LMonoTy.ftvar "k") (LExpr.bvar () 0) (LExpr.quant () QuantifierKind.all (some Lambda.LMonoTy.ftvar "v") (LExpr.bvar () 0) (LExpr.eq () (LExpr.app () (LExpr.app () (LExpr.op () { name := "select", - metadata := Boogie.Visibility.unres } (some Lambda.LMonoTy.tcons + metadata := Core.Visibility.unres } (some Lambda.LMonoTy.tcons "arrow" [Lambda.LMonoTy.tcons "Map" [Lambda.LMonoTy.ftvar "k", Lambda.LMonoTy.ftvar "v"], Lambda.LMonoTy.tcons @@ -440,7 +440,7 @@ info: [LExpr.quant () QuantifierKind.all (some Lambda.LMonoTy.tcons [Lambda.LMonoTy.ftvar "k", Lambda.LMonoTy.ftvar "v"]])) (LExpr.app () (LExpr.app () (LExpr.app () (LExpr.op () { name := "update", - metadata := Boogie.Visibility.unres } (some Lambda.LMonoTy.tcons + metadata := Core.Visibility.unres } (some Lambda.LMonoTy.tcons "arrow" [Lambda.LMonoTy.tcons "Map" [Lambda.LMonoTy.ftvar "k", Lambda.LMonoTy.ftvar "v"], Lambda.LMonoTy.tcons @@ -454,7 +454,7 @@ info: [LExpr.quant () QuantifierKind.all (some Lambda.LMonoTy.tcons [Lambda.LMonoTy.ftvar "k", Lambda.LMonoTy.ftvar "v"]]]])) (LExpr.bvar () 3)) (LExpr.bvar () 1)) (LExpr.bvar () 0))) (LExpr.bvar () 2)) (LExpr.app () (LExpr.app () (LExpr.op () { name := "select", - metadata := Boogie.Visibility.unres } (some Lambda.LMonoTy.tcons + metadata := Core.Visibility.unres } (some Lambda.LMonoTy.tcons "arrow" [Lambda.LMonoTy.tcons "Map" [Lambda.LMonoTy.ftvar "k", Lambda.LMonoTy.ftvar "v"], Lambda.LMonoTy.tcons diff --git a/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean b/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean index 93bdfe212..0a8abba68 100644 --- a/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean +++ b/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean @@ -49,7 +49,7 @@ Errors: #[] #eval TransM.run Inhabited.default (translateProgram failing) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean b/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean index a9918f8c7..eff6ab7df 100644 --- a/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean +++ b/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean @@ -33,7 +33,7 @@ procedure ProcCaller () returns (x : int) { #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. Obligation (Origin_Proc_Requires)g_eq_15 is free! @@ -79,8 +79,8 @@ Evaluated program: var (g : int) := init_g_0 (procedure Proc : () → ()) modifies: [g] -preconditions: (g_eq_15, ((g : int) == #15) (Attribute: Boogie.Procedure.CheckAttr.Free)) -postconditions: (g_lt_10, (((~Int.Lt : (arrow int (arrow int bool))) (g : int)) #10) (Attribute: Boogie.Procedure.CheckAttr.Free)) +preconditions: (g_eq_15, ((g : int) == #15) (Attribute: Core.Procedure.CheckAttr.Free)) +postconditions: (g_lt_10, (((~Int.Lt : (arrow int (arrow int bool))) (g : int)) #10) (Attribute: Core.Procedure.CheckAttr.Free)) body: assume [g_eq_15] ($__g0 == #15) assert [g_gt_10_internal] ((~Int.Gt $__g0) #10) g := ((~Int.Add $__g0) #1) diff --git a/StrataTest/Languages/Boogie/Examples/Functions.lean b/StrataTest/Languages/Boogie/Examples/Functions.lean index e08c743d1..8d6a9f633 100644 --- a/StrataTest/Languages/Boogie/Examples/Functions.lean +++ b/StrataTest/Languages/Boogie/Examples/Functions.lean @@ -36,16 +36,16 @@ fooConst callees: [] -/ #guard_msgs in #eval let (program, _) := Boogie.getProgram funcPgm - let cg := (Boogie.Program.toFunctionCG program) - let ans1 := Boogie.CallGraph.getCalleesClosure cg "barTest4" - let ans2 := Boogie.CallGraph.getCallersClosure cg "barTest1" - let ans3 := Boogie.CallGraph.getCalleesClosure cg "fooConst" + let cg := (Core.Program.toFunctionCG program) + let ans1 := Core.CallGraph.getCalleesClosure cg "barTest4" + let ans2 := Core.CallGraph.getCallersClosure cg "barTest1" + let ans3 := Core.CallGraph.getCalleesClosure cg "fooConst" Std.format f!"barTest4 callees: {ans1}\n\ barTest1 callers: {ans2}\n\ fooConst callees: {ans3}" /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean b/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean index 425687526..75635e30e 100644 --- a/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean +++ b/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean @@ -34,8 +34,8 @@ procedure test(h: Heap, ref: Ref, field: Field) returns () #end /-- -info: type Boogie.Boundedness.Infinite Ref [] -type Boogie.Boundedness.Infinite Field [] +info: type Core.Boundedness.Infinite Ref [] +type Core.Boundedness.Infinite Field [] type Struct := (Map Field int) type Heap := (Map Ref Struct) axiom axiom_0: (∀ (∀ (∀ (∀ (((~Bool.Implies : (arrow bool (arrow bool bool))) ((~Bool.Not : (arrow bool bool)) (%2 == %1))) ((((~select : (arrow (Map Field int) (arrow Field int))) %3) %2) == (((~select : (arrow (Map Field int) (arrow Field int))) ((((~update : (arrow (Map Field int) (arrow Field (arrow int (Map Field int))))) %3) %1) %0)) %2))))))); @@ -53,7 +53,7 @@ assert [assert_0] ((((~select : (arrow (Map Field int) (arrow Field int))) (((~s #eval (TransM.run Inhabited.default (translateProgram genLabelsPgm) |>.fst) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/Goto.lean b/StrataTest/Languages/Boogie/Examples/Goto.lean index 962a00af7..9cd19c05c 100644 --- a/StrataTest/Languages/Boogie/Examples/Goto.lean +++ b/StrataTest/Languages/Boogie/Examples/Goto.lean @@ -54,10 +54,10 @@ procedure Test2(x : int) returns (y : bool) #end -- def p := (translateProgram gotoEnv.commands).run --- def err := Boogie.typeCheckAndPartialEval p.fst +-- def err := Core.typeCheckAndPartialEval p.fst /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/Havoc.lean b/StrataTest/Languages/Boogie/Examples/Havoc.lean index 7fc609aa5..60b106d58 100644 --- a/StrataTest/Languages/Boogie/Examples/Havoc.lean +++ b/StrataTest/Languages/Boogie/Examples/Havoc.lean @@ -42,7 +42,7 @@ Errors: #[] #eval TransM.run Inhabited.default (translateProgram havocPgm) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/Loops.lean b/StrataTest/Languages/Boogie/Examples/Loops.lean index df816c5e9..347d83bbb 100644 --- a/StrataTest/Languages/Boogie/Examples/Loops.lean +++ b/StrataTest/Languages/Boogie/Examples/Loops.lean @@ -34,7 +34,7 @@ spec { #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/Map.lean b/StrataTest/Languages/Boogie/Examples/Map.lean index 3854acd8c..6c758e707 100644 --- a/StrataTest/Languages/Boogie/Examples/Map.lean +++ b/StrataTest/Languages/Boogie/Examples/Map.lean @@ -44,7 +44,7 @@ Errors: #[] #eval TransM.run Inhabited.default (translateProgram mapPgm) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/Min.lean b/StrataTest/Languages/Boogie/Examples/Min.lean index cdc9d5433..4b010b949 100644 --- a/StrataTest/Languages/Boogie/Examples/Min.lean +++ b/StrataTest/Languages/Boogie/Examples/Min.lean @@ -25,7 +25,7 @@ spec { /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/OldExpressions.lean b/StrataTest/Languages/Boogie/Examples/OldExpressions.lean index 40fb79623..0bc4a5bec 100644 --- a/StrataTest/Languages/Boogie/Examples/OldExpressions.lean +++ b/StrataTest/Languages/Boogie/Examples/OldExpressions.lean @@ -50,7 +50,7 @@ spec { #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean b/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean index 608e61418..233376527 100644 --- a/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean +++ b/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean @@ -34,7 +34,7 @@ procedure TestFoo () returns () { #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean b/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean index 98f74663d..6cdc7d45f 100644 --- a/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean +++ b/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean @@ -55,10 +55,10 @@ info: { callees := Std.HashMap.ofList [("Inc", []), ("Q2", ["Q1"]), ("P", ["Inc" -/ #guard_msgs in #eval let (program, _) := Boogie.getProgram globalCounterPgm - Boogie.Program.toProcedureCG program + Core.Program.toProcedureCG program /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/Quantifiers.lean b/StrataTest/Languages/Boogie/Examples/Quantifiers.lean index c486096f7..83e2c3058 100644 --- a/StrataTest/Languages/Boogie/Examples/Quantifiers.lean +++ b/StrataTest/Languages/Boogie/Examples/Quantifiers.lean @@ -47,7 +47,7 @@ spec { #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: @@ -117,7 +117,7 @@ Model: #eval verify "cvc5" quantPgm Inhabited.default Options.default /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean b/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean index 8016a38d8..38c1770b7 100644 --- a/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean +++ b/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean @@ -36,8 +36,8 @@ procedure test(h: Heap, ref: Ref, field: Field) returns () #guard TransM.run Inhabited.default (translateProgram QuantTypeAliases) |>.snd |>.isEmpty /-- -info: type Boogie.Boundedness.Infinite Ref [] -type Boogie.Boundedness.Infinite Field [] +info: type Core.Boundedness.Infinite Ref [] +type Core.Boundedness.Infinite Field [] type Struct := (Map Field int) type Heap := (Map Ref Struct) axiom axiom_0: (∀ (∀ (∀ (∀ (((~Bool.Implies : (arrow bool (arrow bool bool))) ((~Bool.Not : (arrow bool bool)) (%2 == %1))) ((((~select : (arrow (Map Field int) (arrow Field int))) %3) %2) == (((~select : (arrow (Map Field int) (arrow Field int))) ((((~update : (arrow (Map Field int) (arrow Field (arrow int (Map Field int))))) %3) %1) %0)) %2))))))); @@ -58,7 +58,7 @@ Errors: #[] /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/RealBitVector.lean b/StrataTest/Languages/Boogie/Examples/RealBitVector.lean index 864ae3b10..87b61d4fb 100644 --- a/StrataTest/Languages/Boogie/Examples/RealBitVector.lean +++ b/StrataTest/Languages/Boogie/Examples/RealBitVector.lean @@ -49,7 +49,7 @@ Errors: #[] #eval TransM.run Inhabited.default (translateProgram realPgm) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: @@ -158,7 +158,7 @@ Errors: #[] #eval TransM.run Inhabited.default (translateProgram bvPgm) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean b/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean index d5557203c..ae98cb931 100644 --- a/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean +++ b/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean @@ -32,7 +32,7 @@ spec { #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/Regex.lean b/StrataTest/Languages/Boogie/Examples/Regex.lean index d17944055..1f5b896d0 100644 --- a/StrataTest/Languages/Boogie/Examples/Regex.lean +++ b/StrataTest/Languages/Boogie/Examples/Regex.lean @@ -48,7 +48,7 @@ procedure main() returns () { /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: @@ -200,7 +200,7 @@ procedure main(n : int) returns () { #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: @@ -290,7 +290,7 @@ procedure main(n : int) returns () { #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/SimpleProc.lean b/StrataTest/Languages/Boogie/Examples/SimpleProc.lean index e22f8638e..75e2d52ed 100644 --- a/StrataTest/Languages/Boogie/Examples/SimpleProc.lean +++ b/StrataTest/Languages/Boogie/Examples/SimpleProc.lean @@ -45,7 +45,7 @@ Errors: #[] #eval TransM.run Inhabited.default (translateProgram simpleProcPgm) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/String.lean b/StrataTest/Languages/Boogie/Examples/String.lean index fcbe0fc74..93943886a 100644 --- a/StrataTest/Languages/Boogie/Examples/String.lean +++ b/StrataTest/Languages/Boogie/Examples/String.lean @@ -37,7 +37,7 @@ procedure main() returns () { #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/TypeAlias.lean b/StrataTest/Languages/Boogie/Examples/TypeAlias.lean index 9aef9feed..73fa7fe53 100644 --- a/StrataTest/Languages/Boogie/Examples/TypeAlias.lean +++ b/StrataTest/Languages/Boogie/Examples/TypeAlias.lean @@ -57,7 +57,7 @@ procedure P () returns () { #eval TransM.run Inhabited.default (translateProgram goodTypeAlias) |>.snd /-- -info: type Boogie.Boundedness.Infinite Foo [_, _] +info: type Core.Boundedness.Infinite Foo [_, _] type FooAlias a := (Foo int bool) type FooAlias2 a := (FooAlias (FooAlias bool)) func fooVal : () → (FooAlias2 (Foo int int)); @@ -75,7 +75,7 @@ assert [fooAssertion] ((~fooConst1 : (Foo int bool)) == (~fooConst2 : (Foo int b #eval TransM.run Inhabited.default (translateProgram goodTypeAlias) |>.fst /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: @@ -120,7 +120,7 @@ procedure test () returns () { #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/TypeDecl.lean b/StrataTest/Languages/Boogie/Examples/TypeDecl.lean index 20d685cb0..d4878a83e 100644 --- a/StrataTest/Languages/Boogie/Examples/TypeDecl.lean +++ b/StrataTest/Languages/Boogie/Examples/TypeDecl.lean @@ -28,7 +28,7 @@ procedure P () returns () { #eval TransM.run Inhabited.default (translateProgram typeDeclPgm1) |>.snd /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: @@ -91,7 +91,7 @@ procedure P () returns () { #eval TransM.run Inhabited.default (translateProgram typeDeclPgm3) |>.snd /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean b/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean index 49d43b046..03d5e4ede 100644 --- a/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean +++ b/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean @@ -37,7 +37,7 @@ def boogie_pgm := TransM.run Inhabited.default (translateProgram pgm) #eval boogie_pgm.snd.isEmpty /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. --- info: ok: type set := (Map int bool) @@ -47,4 +47,4 @@ axiom a1: (∀ (∀ ((((~diff : (arrow (Map int bool) (arrow (Map int bool) (Map axiom a2: (∀ (∀ (∀ (∀ ((((~select : (arrow (Map int int) (arrow int int))) ((((~lambda_0 : (arrow bool (arrow int (arrow int (Map int int))))) %3) %2) %1)) %0) == (((~select : (arrow (Map int int) (arrow int int))) ((((~lambda_0 : (arrow bool (arrow int (arrow int (Map int int))))) %3) %1) %2)) %0)))))); -/ #guard_msgs in -#eval Boogie.typeCheck Options.default boogie_pgm.fst +#eval Core.typeCheck Options.default boogie_pgm.fst diff --git a/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean b/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean index fd5ebb504..666a5b707 100644 --- a/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean +++ b/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean @@ -28,7 +28,7 @@ procedure R() returns () #end /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/Boogie/ExprEvalTest.lean b/StrataTest/Languages/Boogie/ExprEvalTest.lean index 477df201d..d89fe7399 100644 --- a/StrataTest/Languages/Boogie/ExprEvalTest.lean +++ b/StrataTest/Languages/Boogie/ExprEvalTest.lean @@ -28,7 +28,7 @@ import Plausible.Gen the SMT expression. -/ -namespace Boogie +namespace Core section Tests @@ -40,16 +40,16 @@ def encode (e:LExpr BoogieLParams.mono) (init_state:LState BoogieLParams): Except Format (Option (Strata.SMT.Term × SMT.Context)) := do - let init_state ← init_state.addFactory Boogie.Factory + let init_state ← init_state.addFactory Core.Factory let lcont := { Lambda.LContext.default with - functions := Boogie.Factory, knownTypes := Boogie.KnownTypes } + functions := Core.Factory, knownTypes := Core.KnownTypes } let (e,_T) ← LExpr.annotate lcont tenv e let e_res := LExpr.eval init_state.config.fuel init_state e match e_res with | .const _ _ => - let env := Boogie.Env.init - let (smt_term_lhs,ctx) ← Boogie.toSMTTerm env [] e SMT.Context.default - let (smt_term_rhs,ctx) ← Boogie.toSMTTerm env [] e_res ctx + let env := Core.Env.init + let (smt_term_lhs,ctx) ← Core.toSMTTerm env [] e SMT.Context.default + let (smt_term_rhs,ctx) ← Core.toSMTTerm env [] e_res ctx let smt_term_eq := Strata.SMT.Factory.eq smt_term_lhs smt_term_rhs return (.some (smt_term_eq, ctx)) | _ => return .none @@ -65,7 +65,7 @@ def checkValid (e:LExpr BoogieLParams.mono): IO Bool := do | .error msg => throw (IO.userError s!"error: {msg}") | .ok (.none) => return false | .ok (.some (smt_term, ctx)) => - let ans ← Boogie.SMT.dischargeObligation + let ans ← Core.SMT.dischargeObligation { Options.default with verbose := false } (LExpr.freeVars e) "z3" s!"exprEvalTest.smt2" [smt_term] ctx @@ -129,7 +129,7 @@ private def mkRandConst (ty:LMonoTy): IO (Option (LExpr BoogieLParams.mono)) return .none def checkFactoryOps (verbose:Bool): IO Unit := do - let arr:Array (LFunc BoogieLParams) := Boogie.Factory + let arr:Array (LFunc BoogieLParams) := Core.Factory let print (f:Format): IO Unit := if verbose then IO.println f else return () @@ -215,4 +215,4 @@ abbrev test_ty : LTy := .forAll [] <| .tcons "bool" [] end Tests -end Boogie +end Core diff --git a/StrataTest/Languages/Boogie/ProcedureEvalTests.lean b/StrataTest/Languages/Boogie/ProcedureEvalTests.lean index dd5d9f47d..f6b56c157 100644 --- a/StrataTest/Languages/Boogie/ProcedureEvalTests.lean +++ b/StrataTest/Languages/Boogie/ProcedureEvalTests.lean @@ -6,13 +6,13 @@ import Strata.Languages.Boogie.ProcedureEval -namespace Boogie +namespace Core --------------------------------------------------------------------- section Tests open Std (ToFormat Format format) -open Procedure Statement Lambda Lambda.LTy.Syntax Lambda.LExpr.SyntaxMono Boogie.Syntax +open Procedure Statement Lambda Lambda.LTy.Syntax Lambda.LExpr.SyntaxMono Core.Syntax /-- info: Error: @@ -240,4 +240,4 @@ Proof Obligation: end Tests --------------------------------------------------------------------- -end Boogie +end Core diff --git a/StrataTest/Languages/Boogie/ProcedureTypeTests.lean b/StrataTest/Languages/Boogie/ProcedureTypeTests.lean index 0f2eb4e10..da4f79740 100644 --- a/StrataTest/Languages/Boogie/ProcedureTypeTests.lean +++ b/StrataTest/Languages/Boogie/ProcedureTypeTests.lean @@ -6,13 +6,13 @@ import Strata.Languages.Boogie.ProcedureType -namespace Boogie +namespace Core --------------------------------------------------------------------- section Tests open Std (ToFormat Format format) -open Procedure Statement Lambda Lambda.LTy.Syntax Lambda.LExpr.SyntaxMono Boogie.Syntax +open Procedure Statement Lambda Lambda.LTy.Syntax Lambda.LExpr.SyntaxMono Core.Syntax /-- info: ok: ((procedure P : ((x : int)) → ((y : int))) @@ -26,7 +26,7 @@ info: ok: ((procedure P : ((x : int)) → ((y : int))) aliases: [] state: tyGen: 6 tyPrefix: $__ty exprGen: 0 exprPrefix: $__var subst: []) -/ #guard_msgs in -#eval do let ans ← typeCheck { LContext.default with functions := Boogie.Factory } TEnv.default +#eval do let ans ← typeCheck { LContext.default with functions := Core.Factory } TEnv.default Program.init { header := {name := "P", typeArgs := [], @@ -54,7 +54,7 @@ body: g := (((~Int.Add : (arrow int (arrow int int))) (a : int)) (g : int)) let g : TGenEnv Visibility := { @TGenEnv.default Visibility with context := {types := [[("g", t[int])]] }}; let ans ← typeCheck { @LContext.default ⟨Unit, Visibility⟩ with - functions := Boogie.Factory} {@TEnv.default Visibility with genEnv := g} + functions := Core.Factory} {@TEnv.default Visibility with genEnv := g} Program.init { header := { name := "P", typeArgs := [], @@ -82,7 +82,7 @@ body: g := (((~Int.Add : (arrow int (arrow int int))) (a : int)) (g : int)) let g : TGenEnv Visibility := { @TGenEnv.default Visibility with context := {types := [[("g", t[int])]] }}; let ans ← typeCheck { @LContext.default ⟨Unit, Visibility⟩ with - functions := Boogie.Factory} + functions := Core.Factory} { @TEnv.default Visibility with genEnv := g} Program.init { header := { name := "P", @@ -102,4 +102,4 @@ body: g := (((~Int.Add : (arrow int (arrow int int))) (a : int)) (g : int)) --------------------------------------------------------------------- end Tests -end Boogie +end Core diff --git a/StrataTest/Languages/Boogie/ProgramTypeTests.lean b/StrataTest/Languages/Boogie/ProgramTypeTests.lean index 4156d3be8..d5da94b54 100644 --- a/StrataTest/Languages/Boogie/ProgramTypeTests.lean +++ b/StrataTest/Languages/Boogie/ProgramTypeTests.lean @@ -6,13 +6,13 @@ import Strata.Languages.Boogie.Boogie -namespace Boogie +namespace Core --------------------------------------------------------------------- section Tests open Std (ToFormat Format format) -open Lambda.LTy.Syntax Lambda.LExpr.SyntaxMono Boogie.Syntax +open Lambda.LTy.Syntax Lambda.LExpr.SyntaxMono Core.Syntax def bad_prog : Program := { decls := [ -- type Foo _ _; @@ -69,7 +69,7 @@ def good_prog : Program := { decls := [ ]} /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: @@ -82,7 +82,7 @@ Proof Obligation: (~fooAliasVal == ~fooVal) --- -info: ok: [(type Boogie.Boundedness.Infinite Foo [_, _] +info: ok: [(type Core.Boundedness.Infinite Foo [_, _] type FooAlias a := (Foo int bool) func fooAliasVal : () → (Foo int bool); func fooVal : () → (Foo int bool); @@ -371,7 +371,7 @@ def polyFuncProg : Program := { decls := [ ]} /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. --- info: ok: func identity : ∀[$__ty0]. ((x : $__ty0)) → $__ty0; @@ -391,4 +391,4 @@ m := (((~makePair : (arrow int (arrow bool (Map int bool)))) ((~identity : (arro --------------------------------------------------------------------- end Tests -end Boogie +end Core diff --git a/StrataTest/Languages/Boogie/SMTEncoderDatatypeTest.lean b/StrataTest/Languages/Boogie/SMTEncoderDatatypeTest.lean index 80f3ba9cb..f5b37574f 100644 --- a/StrataTest/Languages/Boogie/SMTEncoderDatatypeTest.lean +++ b/StrataTest/Languages/Boogie/SMTEncoderDatatypeTest.lean @@ -22,7 +22,7 @@ import Strata.Languages.Boogie.Verifier This file contains unit tests for SMT datatype encoding. -/ -namespace Boogie +namespace Core section DatatypeTests @@ -484,4 +484,4 @@ info: (declare-datatype Root ( end DatatypeTests -end Boogie +end Core diff --git a/StrataTest/Languages/Boogie/StatementEvalTests.lean b/StrataTest/Languages/Boogie/StatementEvalTests.lean index 29c6bead4..2ed497e38 100644 --- a/StrataTest/Languages/Boogie/StatementEvalTests.lean +++ b/StrataTest/Languages/Boogie/StatementEvalTests.lean @@ -6,13 +6,13 @@ import Strata.Languages.Boogie.StatementEval -namespace Boogie +namespace Core --------------------------------------------------------------------- section Tests open Std (ToFormat Format format) -open Statement Lambda Lambda.LTy.Syntax Lambda.LExpr.SyntaxMono Boogie.Syntax +open Statement Lambda Lambda.LTy.Syntax Lambda.LExpr.SyntaxMono Core.Syntax /-- info: Error: @@ -379,4 +379,4 @@ Proof Obligation: end Tests --------------------------------------------------------------------- -end Boogie +end Core diff --git a/StrataTest/Languages/Boogie/StatementTypeTests.lean b/StrataTest/Languages/Boogie/StatementTypeTests.lean index 88f441d27..9141f0a6f 100644 --- a/StrataTest/Languages/Boogie/StatementTypeTests.lean +++ b/StrataTest/Languages/Boogie/StatementTypeTests.lean @@ -6,14 +6,14 @@ import Strata.Languages.Boogie.StatementType -namespace Boogie +namespace Core --------------------------------------------------------------------- section Tests open Std (ToFormat Format format) -open Statement Lambda Lambda.LTy.Syntax Lambda.LExpr.SyntaxMono Boogie.Syntax +open Statement Lambda Lambda.LTy.Syntax Lambda.LExpr.SyntaxMono Core.Syntax /-- info: ok: init (x : int) := (xinit : int) @@ -153,4 +153,4 @@ end Tests --------------------------------------------------------------------- -end Boogie +end Core diff --git a/StrataTest/Languages/C_Simp/Examples/LoopSimple.lean b/StrataTest/Languages/C_Simp/Examples/LoopSimple.lean index a9c9c9b1b..a7c952f0c 100644 --- a/StrataTest/Languages/C_Simp/Examples/LoopSimple.lean +++ b/StrataTest/Languages/C_Simp/Examples/LoopSimple.lean @@ -107,7 +107,7 @@ return := sum #eval Strata.to_boogie (Strata.C_Simp.get_program LoopSimplePgm) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/C_Simp/Examples/LoopTrivial.lean b/StrataTest/Languages/C_Simp/Examples/LoopTrivial.lean index 44220d4c6..64acb39b1 100644 --- a/StrataTest/Languages/C_Simp/Examples/LoopTrivial.lean +++ b/StrataTest/Languages/C_Simp/Examples/LoopTrivial.lean @@ -97,7 +97,7 @@ return := i #eval Strata.to_boogie (Strata.C_Simp.get_program LoopTrivialPgm) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/C_Simp/Examples/Min.lean b/StrataTest/Languages/C_Simp/Examples/Min.lean index 9444362ab..1f0002103 100644 --- a/StrataTest/Languages/C_Simp/Examples/Min.lean +++ b/StrataTest/Languages/C_Simp/Examples/Min.lean @@ -56,7 +56,7 @@ open Strata.C_Simp in #eval TransM.run (translateProgram (MinPgm.commands)) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/C_Simp/Examples/SimpleTest.lean b/StrataTest/Languages/C_Simp/Examples/SimpleTest.lean index 4dfdfa61f..ab7a8b1b2 100644 --- a/StrataTest/Languages/C_Simp/Examples/SimpleTest.lean +++ b/StrataTest/Languages/C_Simp/Examples/SimpleTest.lean @@ -72,7 +72,7 @@ open Strata.C_Simp in #eval TransM.run (translateProgram (SimpleTestEnv.commands)) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Languages/C_Simp/Examples/Trivial.lean b/StrataTest/Languages/C_Simp/Examples/Trivial.lean index 2c9d38a7a..51c715077 100644 --- a/StrataTest/Languages/C_Simp/Examples/Trivial.lean +++ b/StrataTest/Languages/C_Simp/Examples/Trivial.lean @@ -45,7 +45,7 @@ Errors: #[] #eval Strata.C_Simp.TransM.run (Strata.C_Simp.translateProgram (TrivialPgm.commands)) /-- -info: [Strata.Boogie] Type checking succeeded. +info: [Strata.Core] Type checking succeeded. VCs: diff --git a/StrataTest/Transform/CallElim.lean b/StrataTest/Transform/CallElim.lean index 8fc36dd82..13874230c 100644 --- a/StrataTest/Transform/CallElim.lean +++ b/StrataTest/Transform/CallElim.lean @@ -15,8 +15,8 @@ import Strata.Transform.CoreTransform import Strata.Transform.CallElim -open Boogie -open Boogie.Transform +open Core +open Core.Transform open CallElim open Strata @@ -177,9 +177,9 @@ procedure h() returns () spec { }; #end -def translate (t : Strata.Program) : Boogie.Program := (TransM.run Inhabited.default (translateProgram t)).fst +def translate (t : Strata.Program) : Core.Program := (TransM.run Inhabited.default (translateProgram t)).fst -def env := (Lambda.LContext.default.addFactoryFunctions Boogie.Factory) +def env := (Lambda.LContext.default.addFactoryFunctions Core.Factory) def translateWF (t : Strata.Program) : WF.WFProgram := let p := translate t @@ -187,14 +187,14 @@ def translateWF (t : Strata.Program) : WF.WFProgram := | .error e => panic! "Well, " ++ Std.format e |> toString | .ok res => { self := p, prop := by exact WF.Program.typeCheckWF H } -def tests : List (Boogie.Program × Boogie.Program) := [ +def tests : List (Core.Program × Core.Program) := [ (CallElimTest1, CallElimTest1Ans), (CallElimTest2, CallElimTest2Ans), (CallElimTest3, CallElimTest3Ans), ].map (Prod.map translate translate) -def callElim (p : Boogie.Program) - : Boogie.Program := +def callElim (p : Core.Program) + : Core.Program := match (run p callElim') with | .ok res => res | .error e => panic! e diff --git a/StrataTest/Transform/DetToNondet.lean b/StrataTest/Transform/DetToNondet.lean index 4c95af7fb..362160f66 100644 --- a/StrataTest/Transform/DetToNondet.lean +++ b/StrataTest/Transform/DetToNondet.lean @@ -10,7 +10,7 @@ import Strata.Languages.Boogie.ProgramType import Strata.Languages.Boogie.ProgramWF import Strata.DL.Lambda.IntBoolFactory -open Boogie +open Core /-! ## Deterministic-to-Nondeterministic Examples -/ section NondetExamples diff --git a/StrataTest/Transform/ProcedureInlining.lean b/StrataTest/Transform/ProcedureInlining.lean index a0f98a464..499d2fbd0 100644 --- a/StrataTest/Transform/ProcedureInlining.lean +++ b/StrataTest/Transform/ProcedureInlining.lean @@ -14,8 +14,8 @@ import Strata.Languages.Boogie.ProgramWF import Strata.Transform.CoreTransform import Strata.Transform.ProcedureInlining -open Boogie -open Boogie.Transform +open Core +open Core.Transform open ProcedureInlining open Strata open Std @@ -107,7 +107,7 @@ private def alphaEquivIdents (e1 e2: Expression.Ident) (map:IdMap) mutual -def alphaEquivBlock (b1 b2: Boogie.Block) (map:IdMap) +def alphaEquivBlock (b1 b2: Core.Block) (map:IdMap) : Except Format IdMap := do if b1.length ≠ b2.length then .error "Block lengths do not match" @@ -120,7 +120,7 @@ def alphaEquivBlock (b1 b2: Boogie.Block) (map:IdMap) termination_by b1.sizeOf decreasing_by cases st1; apply Imperative.sizeOf_stmt_in_block; assumption -def alphaEquivStatement (s1 s2: Boogie.Statement) (map:IdMap) +def alphaEquivStatement (s1 s2: Core.Statement) (map:IdMap) : Except Format IdMap := do let mk_err (s:Format): Except Format IdMap := .error (f!"{s}\ns1:{s1}\ns2:{s2}\nmap:{map.vars}") @@ -207,7 +207,7 @@ def alphaEquivStatement (s1 s2: Boogie.Statement) (map:IdMap) end -private def alphaEquiv (p1 p2:Boogie.Procedure):Except Format Bool := do +private def alphaEquiv (p1 p2:Core.Procedure):Except Format Bool := do if p1.body.length ≠ p2.body.length then .error (s!"# statements do not match: in {p1.header.name}, " ++ s!"inlined fn one has {p1.body.length}" @@ -223,15 +223,15 @@ private def alphaEquiv (p1 p2:Boogie.Procedure):Except Format Bool := do -def translate (t : Strata.Program) : Boogie.Program := +def translate (t : Strata.Program) : Core.Program := (TransM.run Inhabited.default (translateProgram t)).fst -def runInlineCall (p : Boogie.Program) : Boogie.Program := +def runInlineCall (p : Core.Program) : Core.Program := match (runProgram inlineCallCmd p .emp) with | ⟨.ok res, _⟩ => res | ⟨.error e, _⟩ => panic! e -def checkInlining (prog : Boogie.Program) (progAns : Boogie.Program) +def checkInlining (prog : Core.Program) (progAns : Core.Program) : Except Format Bool := do let prog' := runInlineCall prog let pp' := prog'.decls.zip progAns.decls diff --git a/StrataToCBMC.lean b/StrataToCBMC.lean index 3e7ec634b..0d91ca0fb 100644 --- a/StrataToCBMC.lean +++ b/StrataToCBMC.lean @@ -36,7 +36,7 @@ def main (args : List String) : IO Unit := do else if file.endsWith ".core.st" then let boogie_prog := (Boogie.getProgram pgm inputCtx).fst match boogie_prog.decls.head! with - | .proc f => IO.println (Boogie.testSymbols f) + | .proc f => IO.println (Core.testSymbols f) | _ => IO.println "Error: expected boogie procedure" else IO.println "Error: Unrecognized file extension" diff --git a/StrataVerify.lean b/StrataVerify.lean index 065b8dc36..14da55153 100644 --- a/StrataVerify.lean +++ b/StrataVerify.lean @@ -82,7 +82,7 @@ def main (args : List String) : IO UInt32 := do for vcResult in vcResults do let posStr := Imperative.MetaData.formatFileRangeD vcResult.obligation.metadata println! f!"{posStr} [{vcResult.obligation.label}]: {vcResult.result}" - let success := vcResults.all Boogie.VCResult.isSuccess + let success := vcResults.all Core.VCResult.isSuccess if success && !opts.checkOnly then println! f!"All {vcResults.size} goals passed." return 0 @@ -90,8 +90,8 @@ def main (args : List String) : IO UInt32 := do println! f!"Skipping verification." return 0 else - let provedGoalCount := (vcResults.filter Boogie.VCResult.isSuccess).size - let failedGoalCount := (vcResults.filter Boogie.VCResult.isNotSuccess).size + let provedGoalCount := (vcResults.filter Core.VCResult.isSuccess).size + let failedGoalCount := (vcResults.filter Core.VCResult.isNotSuccess).size println! f!"Finished with {provedGoalCount} goals passed, {failedGoalCount} failed." return 1 -- Strata.Elab.elabProgram From 075b942b6d99a2b87aee4adc2810fb0a035af9b6 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 15:00:35 -0600 Subject: [PATCH 05/19] Rename Strata/Languages/Boogie to Strata/Languages/Core --- Strata.lean | 2 +- Strata/Backends/CBMC/BoogieToCBMC.lean | 8 +- Strata/Languages/C_Simp/Verify.lean | 2 +- Strata/Languages/{Boogie => Core}/Axiom.lean | 2 +- Strata/Languages/{Boogie => Core}/Boogie.lean | 6 +- .../Languages/{Boogie => Core}/BoogieGen.lean | 2 +- .../Languages/{Boogie => Core}/CallGraph.lean | 2 +- .../Languages/{Boogie => Core}/CmdEval.lean | 6 +- .../Languages/{Boogie => Core}/CmdType.lean | 4 +- .../{Boogie => Core}/DDMTransform/Parse.lean | 2 +- .../DDMTransform/Translate.lean | 4 +- Strata/Languages/{Boogie => Core}/Env.lean | 2 +- .../{Boogie => Core}/Expressions.lean | 2 +- .../Languages/{Boogie => Core}/Factory.lean | 4 +- .../Languages/{Boogie => Core}/Function.lean | 2 +- .../{Boogie => Core}/FunctionType.lean | 4 +- .../{Boogie => Core}/Identifiers.lean | 0 .../{Boogie => Core}/OldExpressions.lean | 4 +- .../Languages/{Boogie => Core}/Options.lean | 0 .../Languages/{Boogie => Core}/Procedure.lean | 2 +- .../{Boogie => Core}/ProcedureEval.lean | 8 +- .../{Boogie => Core}/ProcedureType.lean | 6 +- .../{Boogie => Core}/ProcedureWF.lean | 8 +- .../Languages/{Boogie => Core}/Program.lean | 8 +- .../{Boogie => Core}/ProgramEval.lean | 4 +- .../{Boogie => Core}/ProgramType.lean | 6 +- .../Languages/{Boogie => Core}/ProgramWF.lean | 8 +- .../{Boogie => Core}/SMTEncoder.lean | 2 +- .../Languages/{Boogie => Core}/Statement.lean | 6 +- .../{Boogie => Core}/StatementEval.lean | 10 +- .../{Boogie => Core}/StatementSemantics.lean | 2 +- .../StatementSemanticsProps.lean | 8 +- .../{Boogie => Core}/StatementType.lean | 8 +- .../{Boogie => Core}/StatementWF.lean | 6 +- .../Languages/{Boogie => Core}/TypeDecl.lean | 2 +- .../Languages/{Boogie => Core}/Verifier.lean | 8 +- Strata/Languages/{Boogie => Core}/WF.lean | 4 +- .../ConcreteToAbstractTreeTranslator.lean | 2 +- Strata/Languages/Laurel/Laurel.lean | 4 +- .../Laurel/LaurelToBoogieTranslator.lean | 10 +- Strata/Languages/Python/BoogiePrelude.lean | 4 +- .../Languages/Python/FunctionSignatures.lean | 2 +- Strata/Languages/Python/PyFactory.lean | 2 +- Strata/Languages/Python/PythonToBoogie.lean | 4 +- Strata/Languages/Python/Regex/ReToBoogie.lean | 2 +- Strata/Transform/CallElimCorrect.lean | 14 +- Strata/Transform/CoreTransform.lean | 6 +- Strata/Transform/DetToNondet.lean | 2 +- Strata/Transform/ProcedureInlining.lean | 10 +- .../Backends/CBMC/BoogieToCProverGOTO.lean | 2 +- StrataTest/DDM/Integration/Java/TestGen.lean | 2 +- .../Internal/InternalBoogiePrelude.lean | 4 +- .../Internal/InternalFunctionSignatures.lean | 2 +- .../Boogie/DatatypeVerificationTests.lean | 4 +- .../Boogie/Examples/AdvancedMaps.lean | 2 +- .../Boogie/Examples/AdvancedQuantifiers.lean | 2 +- .../Examples/AssertionDefaultNames.lean | 2 +- .../Languages/Boogie/Examples/Axioms.lean | 4 +- .../Boogie/Examples/BitVecParse.lean | 2 +- .../Languages/Boogie/Examples/Cover.lean | 2 +- .../Boogie/Examples/DDMAxiomsExtraction.lean | 256 +++++++++--------- .../Boogie/Examples/DDMTransform.lean | 2 +- .../Boogie/Examples/DatatypeEnum.lean | 2 +- .../Boogie/Examples/DatatypeList.lean | 2 +- .../Boogie/Examples/DatatypeOption.lean | 2 +- .../Boogie/Examples/DatatypeTree.lean | 2 +- .../Boogie/Examples/FailingAssertion.lean | 2 +- .../Boogie/Examples/FreeRequireEnsure.lean | 2 +- .../Languages/Boogie/Examples/Functions.lean | 4 +- .../Boogie/Examples/GeneratedLabels.lean | 2 +- .../Languages/Boogie/Examples/Goto.lean | 4 +- .../Languages/Boogie/Examples/Havoc.lean | 2 +- .../Languages/Boogie/Examples/Loops.lean | 2 +- StrataTest/Languages/Boogie/Examples/Map.lean | 2 +- StrataTest/Languages/Boogie/Examples/Min.lean | 2 +- .../Boogie/Examples/OldExpressions.lean | 2 +- .../Boogie/Examples/PrecedenceCheck.lean | 2 +- .../Boogie/Examples/ProcedureCall.lean | 4 +- .../Boogie/Examples/Quantifiers.lean | 2 +- .../Examples/QuantifiersWithTypeAliases.lean | 2 +- .../Boogie/Examples/RealBitVector.lean | 2 +- .../Boogie/Examples/RecursiveProcIte.lean | 2 +- .../Languages/Boogie/Examples/Regex.lean | 2 +- .../Examples/RemoveIrrelevantAxioms.lean | 2 +- .../Languages/Boogie/Examples/SimpleProc.lean | 2 +- .../Languages/Boogie/Examples/String.lean | 2 +- .../Languages/Boogie/Examples/TypeAlias.lean | 2 +- .../Languages/Boogie/Examples/TypeDecl.lean | 2 +- .../Examples/TypeVarImplicitlyQuantified.lean | 2 +- .../Boogie/Examples/UnreachableAssert.lean | 2 +- StrataTest/Languages/Boogie/ExprEvalTest.lean | 12 +- .../Languages/Boogie/ProcedureEvalTests.lean | 2 +- .../Languages/Boogie/ProcedureTypeTests.lean | 2 +- .../Languages/Boogie/ProgramTypeTests.lean | 2 +- .../Boogie/SMTEncoderDatatypeTest.lean | 12 +- .../Languages/Boogie/StatementEvalTests.lean | 2 +- .../Languages/Boogie/StatementTypeTests.lean | 2 +- StrataTest/Transform/CallElim.lean | 10 +- StrataTest/Transform/DetToNondet.lean | 6 +- StrataTest/Transform/ProcedureInlining.lean | 10 +- StrataTest/Util/TestDiagnostics.lean | 2 +- StrataToCBMC.lean | 2 +- StrataVerify.lean | 2 +- 103 files changed, 320 insertions(+), 320 deletions(-) rename Strata/Languages/{Boogie => Core}/Axiom.lean (96%) rename Strata/Languages/{Boogie => Core}/Boogie.lean (95%) rename Strata/Languages/{Boogie => Core}/BoogieGen.lean (98%) rename Strata/Languages/{Boogie => Core}/CallGraph.lean (99%) rename Strata/Languages/{Boogie => Core}/CmdEval.lean (97%) rename Strata/Languages/{Boogie => Core}/CmdType.lean (97%) rename Strata/Languages/{Boogie => Core}/DDMTransform/Parse.lean (99%) rename Strata/Languages/{Boogie => Core}/DDMTransform/Translate.lean (99%) rename Strata/Languages/{Boogie => Core}/Env.lean (99%) rename Strata/Languages/{Boogie => Core}/Expressions.lean (96%) rename Strata/Languages/{Boogie => Core}/Factory.lean (99%) rename Strata/Languages/{Boogie => Core}/Function.lean (96%) rename Strata/Languages/{Boogie => Core}/FunctionType.lean (96%) rename Strata/Languages/{Boogie => Core}/Identifiers.lean (100%) rename Strata/Languages/{Boogie => Core}/OldExpressions.lean (99%) rename Strata/Languages/{Boogie => Core}/Options.lean (100%) rename Strata/Languages/{Boogie => Core}/Procedure.lean (99%) rename Strata/Languages/{Boogie => Core}/ProcedureEval.lean (95%) rename Strata/Languages/{Boogie => Core}/ProcedureType.lean (97%) rename Strata/Languages/{Boogie => Core}/ProcedureWF.lean (96%) rename Strata/Languages/{Boogie => Core}/Program.lean (98%) rename Strata/Languages/{Boogie => Core}/ProgramEval.lean (97%) rename Strata/Languages/{Boogie => Core}/ProgramType.lean (96%) rename Strata/Languages/{Boogie => Core}/ProgramWF.lean (98%) rename Strata/Languages/{Boogie => Core}/SMTEncoder.lean (99%) rename Strata/Languages/{Boogie => Core}/Statement.lean (99%) rename Strata/Languages/{Boogie => Core}/StatementEval.lean (99%) rename Strata/Languages/{Boogie => Core}/StatementSemantics.lean (99%) rename Strata/Languages/{Boogie => Core}/StatementSemanticsProps.lean (99%) rename Strata/Languages/{Boogie => Core}/StatementType.lean (98%) rename Strata/Languages/{Boogie => Core}/StatementWF.lean (98%) rename Strata/Languages/{Boogie => Core}/TypeDecl.lean (98%) rename Strata/Languages/{Boogie => Core}/Verifier.lean (99%) rename Strata/Languages/{Boogie => Core}/WF.lean (98%) diff --git a/Strata.lean b/Strata.lean index 5c5225eef..c53656403 100644 --- a/Strata.lean +++ b/Strata.lean @@ -16,7 +16,7 @@ import Strata.DL.Lambda.Lambda import Strata.DL.Imperative.Imperative /- Boogie -/ -import Strata.Languages.Boogie.StatementSemantics +import Strata.Languages.Core.StatementSemantics /- Code Transforms -/ import Strata.Transform.CallElimCorrect diff --git a/Strata/Backends/CBMC/BoogieToCBMC.lean b/Strata/Backends/CBMC/BoogieToCBMC.lean index 95aaa169d..86ccaa1e7 100644 --- a/Strata/Backends/CBMC/BoogieToCBMC.lean +++ b/Strata/Backends/CBMC/BoogieToCBMC.lean @@ -5,11 +5,11 @@ -/ import Lean.Data.Json -import Strata.Languages.Boogie.Env -import Strata.Languages.Boogie.DDMTransform.Parse -import Strata.Languages.Boogie.DDMTransform.Translate +import Strata.Languages.Core.Env +import Strata.Languages.Core.DDMTransform.Parse +import Strata.Languages.Core.DDMTransform.Translate import Strata.DL.Util.Map -import Strata.Languages.Boogie.Boogie +import Strata.Languages.Core.Boogie import Strata.Backends.CBMC.Common open Lean diff --git a/Strata/Languages/C_Simp/Verify.lean b/Strata/Languages/C_Simp/Verify.lean index 1db01f008..3bea85a1c 100644 --- a/Strata/Languages/C_Simp/Verify.lean +++ b/Strata/Languages/C_Simp/Verify.lean @@ -6,7 +6,7 @@ import Strata.Languages.C_Simp.C_Simp import Strata.Languages.C_Simp.DDMTransform.Translate -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier import Strata.DL.Imperative.Stmt namespace Strata diff --git a/Strata/Languages/Boogie/Axiom.lean b/Strata/Languages/Core/Axiom.lean similarity index 96% rename from Strata/Languages/Boogie/Axiom.lean rename to Strata/Languages/Core/Axiom.lean index 4a63bae4a..e1b981f56 100644 --- a/Strata/Languages/Boogie/Axiom.lean +++ b/Strata/Languages/Core/Axiom.lean @@ -7,7 +7,7 @@ -import Strata.Languages.Boogie.Statement +import Strata.Languages.Core.Statement import Strata.DL.Lambda.LTy import Strata.DL.Lambda.LExpr diff --git a/Strata/Languages/Boogie/Boogie.lean b/Strata/Languages/Core/Boogie.lean similarity index 95% rename from Strata/Languages/Boogie/Boogie.lean rename to Strata/Languages/Core/Boogie.lean index ee55f8df9..d2eea88ef 100644 --- a/Strata/Languages/Boogie/Boogie.lean +++ b/Strata/Languages/Core/Boogie.lean @@ -5,9 +5,9 @@ -/ -import Strata.Languages.Boogie.Options -import Strata.Languages.Boogie.ProgramEval -import Strata.Languages.Boogie.ProgramType +import Strata.Languages.Core.Options +import Strata.Languages.Core.ProgramEval +import Strata.Languages.Core.ProgramType --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/BoogieGen.lean b/Strata/Languages/Core/BoogieGen.lean similarity index 98% rename from Strata/Languages/Boogie/BoogieGen.lean rename to Strata/Languages/Core/BoogieGen.lean index f4a9fe539..e547321a0 100644 --- a/Strata/Languages/Boogie/BoogieGen.lean +++ b/Strata/Languages/Core/BoogieGen.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Statement +import Strata.Languages.Core.Statement import Strata.DL.Util.LabelGen import Strata.DL.Util.StringGen import Strata.DL.Util.ListUtils diff --git a/Strata/Languages/Boogie/CallGraph.lean b/Strata/Languages/Core/CallGraph.lean similarity index 99% rename from Strata/Languages/Boogie/CallGraph.lean rename to Strata/Languages/Core/CallGraph.lean index 2b5340c53..2c595f7e4 100644 --- a/Strata/Languages/Boogie/CallGraph.lean +++ b/Strata/Languages/Core/CallGraph.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Program +import Strata.Languages.Core.Program --------------------------------------------------------------------- namespace Core diff --git a/Strata/Languages/Boogie/CmdEval.lean b/Strata/Languages/Core/CmdEval.lean similarity index 97% rename from Strata/Languages/Boogie/CmdEval.lean rename to Strata/Languages/Core/CmdEval.lean index 870d3b1db..edf82f1e0 100644 --- a/Strata/Languages/Boogie/CmdEval.lean +++ b/Strata/Languages/Core/CmdEval.lean @@ -6,9 +6,9 @@ -import Strata.Languages.Boogie.OldExpressions -import Strata.Languages.Boogie.Expressions -import Strata.Languages.Boogie.Env +import Strata.Languages.Core.OldExpressions +import Strata.Languages.Core.Expressions +import Strata.Languages.Core.Env import Strata.DL.Imperative.EvalContext import Strata.DL.Imperative.CmdEval diff --git a/Strata/Languages/Boogie/CmdType.lean b/Strata/Languages/Core/CmdType.lean similarity index 97% rename from Strata/Languages/Boogie/CmdType.lean rename to Strata/Languages/Core/CmdType.lean index 1bbbfbef3..e8d31d8f3 100644 --- a/Strata/Languages/Boogie/CmdType.lean +++ b/Strata/Languages/Core/CmdType.lean @@ -6,8 +6,8 @@ -import Strata.Languages.Boogie.OldExpressions -import Strata.Languages.Boogie.Expressions +import Strata.Languages.Core.OldExpressions +import Strata.Languages.Core.Expressions import Strata.DL.Imperative.TypeContext import Strata.DL.Lambda.Factory diff --git a/Strata/Languages/Boogie/DDMTransform/Parse.lean b/Strata/Languages/Core/DDMTransform/Parse.lean similarity index 99% rename from Strata/Languages/Boogie/DDMTransform/Parse.lean rename to Strata/Languages/Core/DDMTransform/Parse.lean index e21eb2a71..dd6238af3 100644 --- a/Strata/Languages/Boogie/DDMTransform/Parse.lean +++ b/Strata/Languages/Core/DDMTransform/Parse.lean @@ -6,7 +6,7 @@ import Strata.DDM.Integration.Lean import Strata.DDM.Util.Format -import Strata.Languages.Boogie.Boogie +import Strata.Languages.Core.Boogie --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/DDMTransform/Translate.lean b/Strata/Languages/Core/DDMTransform/Translate.lean similarity index 99% rename from Strata/Languages/Boogie/DDMTransform/Translate.lean rename to Strata/Languages/Core/DDMTransform/Translate.lean index 4704bb2f3..d6cb86bb7 100644 --- a/Strata/Languages/Boogie/DDMTransform/Translate.lean +++ b/Strata/Languages/Core/DDMTransform/Translate.lean @@ -5,8 +5,8 @@ -/ import Strata.DDM.AST -import Strata.Languages.Boogie.DDMTransform.Parse -import Strata.Languages.Boogie.BoogieGen +import Strata.Languages.Core.DDMTransform.Parse +import Strata.Languages.Core.BoogieGen import Strata.DDM.Util.DecimalRat diff --git a/Strata/Languages/Boogie/Env.lean b/Strata/Languages/Core/Env.lean similarity index 99% rename from Strata/Languages/Boogie/Env.lean rename to Strata/Languages/Core/Env.lean index 55eaec1c8..a91c629be 100644 --- a/Strata/Languages/Boogie/Env.lean +++ b/Strata/Languages/Core/Env.lean @@ -6,7 +6,7 @@ -import Strata.Languages.Boogie.Program +import Strata.Languages.Core.Program import Strata.DL.Imperative.EvalContext namespace Core diff --git a/Strata/Languages/Boogie/Expressions.lean b/Strata/Languages/Core/Expressions.lean similarity index 96% rename from Strata/Languages/Boogie/Expressions.lean rename to Strata/Languages/Core/Expressions.lean index fdd3e11a5..00844a955 100644 --- a/Strata/Languages/Boogie/Expressions.lean +++ b/Strata/Languages/Core/Expressions.lean @@ -8,7 +8,7 @@ import Strata.DL.Lambda.Lambda import Strata.DL.Imperative.PureExpr -import Strata.Languages.Boogie.Identifiers +import Strata.Languages.Core.Identifiers import Strata.DL.Imperative.HasVars namespace Core diff --git a/Strata/Languages/Boogie/Factory.lean b/Strata/Languages/Core/Factory.lean similarity index 99% rename from Strata/Languages/Boogie/Factory.lean rename to Strata/Languages/Core/Factory.lean index ec5fef6f2..b0e21aa5d 100644 --- a/Strata/Languages/Boogie/Factory.lean +++ b/Strata/Languages/Core/Factory.lean @@ -5,8 +5,8 @@ -/ import Lean.Elab.Command -import Strata.Languages.Boogie.Identifiers -import Strata.Languages.Boogie.Expressions +import Strata.Languages.Core.Identifiers +import Strata.Languages.Core.Expressions import Strata.DL.Lambda.Factory import Strata.DL.Lambda.IntBoolFactory --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/Function.lean b/Strata/Languages/Core/Function.lean similarity index 96% rename from Strata/Languages/Boogie/Function.lean rename to Strata/Languages/Core/Function.lean index 9a33b9d88..ce149121b 100644 --- a/Strata/Languages/Boogie/Function.lean +++ b/Strata/Languages/Core/Function.lean @@ -6,7 +6,7 @@ -import Strata.Languages.Boogie.Statement +import Strata.Languages.Core.Statement --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/FunctionType.lean b/Strata/Languages/Core/FunctionType.lean similarity index 96% rename from Strata/Languages/Boogie/FunctionType.lean rename to Strata/Languages/Core/FunctionType.lean index 0dd00d412..76d4af933 100644 --- a/Strata/Languages/Boogie/FunctionType.lean +++ b/Strata/Languages/Core/FunctionType.lean @@ -6,8 +6,8 @@ -import Strata.Languages.Boogie.Function -import Strata.Languages.Boogie.Program +import Strata.Languages.Core.Function +import Strata.Languages.Core.Program --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/Identifiers.lean b/Strata/Languages/Core/Identifiers.lean similarity index 100% rename from Strata/Languages/Boogie/Identifiers.lean rename to Strata/Languages/Core/Identifiers.lean diff --git a/Strata/Languages/Boogie/OldExpressions.lean b/Strata/Languages/Core/OldExpressions.lean similarity index 99% rename from Strata/Languages/Boogie/OldExpressions.lean rename to Strata/Languages/Core/OldExpressions.lean index 01d90a533..ee34c80ea 100644 --- a/Strata/Languages/Boogie/OldExpressions.lean +++ b/Strata/Languages/Core/OldExpressions.lean @@ -4,8 +4,8 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.BoogieGen -import Strata.Languages.Boogie.Procedure +import Strata.Languages.Core.BoogieGen +import Strata.Languages.Core.Procedure namespace Core diff --git a/Strata/Languages/Boogie/Options.lean b/Strata/Languages/Core/Options.lean similarity index 100% rename from Strata/Languages/Boogie/Options.lean rename to Strata/Languages/Core/Options.lean diff --git a/Strata/Languages/Boogie/Procedure.lean b/Strata/Languages/Core/Procedure.lean similarity index 99% rename from Strata/Languages/Boogie/Procedure.lean rename to Strata/Languages/Core/Procedure.lean index 71bedc36b..66beb9d24 100644 --- a/Strata/Languages/Boogie/Procedure.lean +++ b/Strata/Languages/Core/Procedure.lean @@ -7,7 +7,7 @@ import Strata.DL.Imperative.HasVars -import Strata.Languages.Boogie.Statement +import Strata.Languages.Core.Statement --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/ProcedureEval.lean b/Strata/Languages/Core/ProcedureEval.lean similarity index 95% rename from Strata/Languages/Boogie/ProcedureEval.lean rename to Strata/Languages/Core/ProcedureEval.lean index 4a0b09467..1ed7e6a4b 100644 --- a/Strata/Languages/Boogie/ProcedureEval.lean +++ b/Strata/Languages/Core/ProcedureEval.lean @@ -6,10 +6,10 @@ -import Strata.Languages.Boogie.Procedure -import Strata.Languages.Boogie.Statement -import Strata.Languages.Boogie.StatementEval -import Strata.Languages.Boogie.StatementSemantics +import Strata.Languages.Core.Procedure +import Strata.Languages.Core.Statement +import Strata.Languages.Core.StatementEval +import Strata.Languages.Core.StatementSemantics import Strata.Transform.LoopElim --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/ProcedureType.lean b/Strata/Languages/Core/ProcedureType.lean similarity index 97% rename from Strata/Languages/Boogie/ProcedureType.lean rename to Strata/Languages/Core/ProcedureType.lean index a78d63e2d..4e1a9495e 100644 --- a/Strata/Languages/Boogie/ProcedureType.lean +++ b/Strata/Languages/Core/ProcedureType.lean @@ -6,10 +6,10 @@ -import Strata.Languages.Boogie.Procedure +import Strata.Languages.Core.Procedure import Strata.DL.Imperative.HasVars -import Strata.Languages.Boogie.StatementType -import Strata.Languages.Boogie.OldExpressions +import Strata.Languages.Core.StatementType +import Strata.Languages.Core.OldExpressions --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/ProcedureWF.lean b/Strata/Languages/Core/ProcedureWF.lean similarity index 96% rename from Strata/Languages/Boogie/ProcedureWF.lean rename to Strata/Languages/Core/ProcedureWF.lean index 9ad899e8f..8fc806ccc 100644 --- a/Strata/Languages/Boogie/ProcedureWF.lean +++ b/Strata/Languages/Core/ProcedureWF.lean @@ -7,10 +7,10 @@ import Strata.DL.Util.ListUtils -import Strata.Languages.Boogie.Program -import Strata.Languages.Boogie.ProcedureType -import Strata.Languages.Boogie.WF -import Strata.Languages.Boogie.StatementWF +import Strata.Languages.Core.Program +import Strata.Languages.Core.ProcedureType +import Strata.Languages.Core.WF +import Strata.Languages.Core.StatementWF namespace Core namespace WF diff --git a/Strata/Languages/Boogie/Program.lean b/Strata/Languages/Core/Program.lean similarity index 98% rename from Strata/Languages/Boogie/Program.lean rename to Strata/Languages/Core/Program.lean index e9c864a03..a8cd2dee3 100644 --- a/Strata/Languages/Boogie/Program.lean +++ b/Strata/Languages/Core/Program.lean @@ -6,10 +6,10 @@ -import Strata.Languages.Boogie.Procedure -import Strata.Languages.Boogie.Function -import Strata.Languages.Boogie.TypeDecl -import Strata.Languages.Boogie.Axiom +import Strata.Languages.Core.Procedure +import Strata.Languages.Core.Function +import Strata.Languages.Core.TypeDecl +import Strata.Languages.Core.Axiom --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/ProgramEval.lean b/Strata/Languages/Core/ProgramEval.lean similarity index 97% rename from Strata/Languages/Boogie/ProgramEval.lean rename to Strata/Languages/Core/ProgramEval.lean index 4109842ad..f16f8230f 100644 --- a/Strata/Languages/Boogie/ProgramEval.lean +++ b/Strata/Languages/Core/ProgramEval.lean @@ -6,8 +6,8 @@ -import Strata.Languages.Boogie.Program -import Strata.Languages.Boogie.ProcedureEval +import Strata.Languages.Core.Program +import Strata.Languages.Core.ProcedureEval --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/ProgramType.lean b/Strata/Languages/Core/ProgramType.lean similarity index 96% rename from Strata/Languages/Boogie/ProgramType.lean rename to Strata/Languages/Core/ProgramType.lean index bb24e8ca5..c28b88b27 100644 --- a/Strata/Languages/Boogie/ProgramType.lean +++ b/Strata/Languages/Core/ProgramType.lean @@ -7,9 +7,9 @@ import Strata.DL.Lambda.LExprType -import Strata.Languages.Boogie.Program -import Strata.Languages.Boogie.FunctionType -import Strata.Languages.Boogie.ProcedureType +import Strata.Languages.Core.Program +import Strata.Languages.Core.FunctionType +import Strata.Languages.Core.ProcedureType --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/ProgramWF.lean b/Strata/Languages/Core/ProgramWF.lean similarity index 98% rename from Strata/Languages/Boogie/ProgramWF.lean rename to Strata/Languages/Core/ProgramWF.lean index 1b59634d8..cffd48aed 100644 --- a/Strata/Languages/Boogie/ProgramWF.lean +++ b/Strata/Languages/Core/ProgramWF.lean @@ -5,10 +5,10 @@ -/ import Strata.DL.Util.ListUtils -import Strata.Languages.Boogie.ProgramType -import Strata.Languages.Boogie.WF -import Strata.Languages.Boogie.StatementWF -import Strata.Languages.Boogie.ProcedureWF +import Strata.Languages.Core.ProgramType +import Strata.Languages.Core.WF +import Strata.Languages.Core.StatementWF +import Strata.Languages.Core.ProcedureWF /-! ## Well-Formedness for Programs This file is the entry point of typechecker correctness proofs. Specifically, diff --git a/Strata/Languages/Boogie/SMTEncoder.lean b/Strata/Languages/Core/SMTEncoder.lean similarity index 99% rename from Strata/Languages/Boogie/SMTEncoder.lean rename to Strata/Languages/Core/SMTEncoder.lean index 72b6ef9f7..965f3d961 100644 --- a/Strata/Languages/Boogie/SMTEncoder.lean +++ b/Strata/Languages/Core/SMTEncoder.lean @@ -6,7 +6,7 @@ -import Strata.Languages.Boogie.Boogie +import Strata.Languages.Core.Boogie import Strata.DL.SMT.SMT import Init.Data.String.Extra import Strata.DDM.Util.DecimalRat diff --git a/Strata/Languages/Boogie/Statement.lean b/Strata/Languages/Core/Statement.lean similarity index 99% rename from Strata/Languages/Boogie/Statement.lean rename to Strata/Languages/Core/Statement.lean index 8bf5ecc59..da9300829 100644 --- a/Strata/Languages/Boogie/Statement.lean +++ b/Strata/Languages/Core/Statement.lean @@ -6,10 +6,10 @@ -import Strata.Languages.Boogie.Expressions +import Strata.Languages.Core.Expressions import Strata.DL.Imperative.PureExpr -import Strata.Languages.Boogie.Identifiers -import Strata.Languages.Boogie.Factory +import Strata.Languages.Core.Identifiers +import Strata.Languages.Core.Factory import Strata.DL.Imperative.Stmt import Strata.DL.Imperative.HasVars import Strata.DL.Lambda.LExpr diff --git a/Strata/Languages/Boogie/StatementEval.lean b/Strata/Languages/Core/StatementEval.lean similarity index 99% rename from Strata/Languages/Boogie/StatementEval.lean rename to Strata/Languages/Core/StatementEval.lean index b2eedd6cb..76de86875 100644 --- a/Strata/Languages/Boogie/StatementEval.lean +++ b/Strata/Languages/Core/StatementEval.lean @@ -6,11 +6,11 @@ -import Strata.Languages.Boogie.Statement -import Strata.Languages.Boogie.Program -import Strata.Languages.Boogie.OldExpressions -import Strata.Languages.Boogie.Env -import Strata.Languages.Boogie.CmdEval +import Strata.Languages.Core.Statement +import Strata.Languages.Core.Program +import Strata.Languages.Core.OldExpressions +import Strata.Languages.Core.Env +import Strata.Languages.Core.CmdEval --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/StatementSemantics.lean b/Strata/Languages/Core/StatementSemantics.lean similarity index 99% rename from Strata/Languages/Boogie/StatementSemantics.lean rename to Strata/Languages/Core/StatementSemantics.lean index 9d716fe63..1a71386e0 100644 --- a/Strata/Languages/Boogie/StatementSemantics.lean +++ b/Strata/Languages/Core/StatementSemantics.lean @@ -6,7 +6,7 @@ import Strata.DL.Lambda.LExpr import Strata.DL.Imperative.StmtSemantics -import Strata.Languages.Boogie.OldExpressions +import Strata.Languages.Core.OldExpressions --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/StatementSemanticsProps.lean b/Strata/Languages/Core/StatementSemanticsProps.lean similarity index 99% rename from Strata/Languages/Boogie/StatementSemanticsProps.lean rename to Strata/Languages/Core/StatementSemanticsProps.lean index 7312f6ade..c931a5814 100644 --- a/Strata/Languages/Boogie/StatementSemanticsProps.lean +++ b/Strata/Languages/Core/StatementSemanticsProps.lean @@ -9,10 +9,10 @@ import Strata.DL.Imperative.StmtSemantics import Strata.DL.Imperative.HasVars import Strata.DL.Util.Nodup import Strata.DL.Util.ListUtils -import Strata.Languages.Boogie.Procedure -import Strata.Languages.Boogie.Statement -import Strata.Languages.Boogie.OldExpressions -import Strata.Languages.Boogie.StatementSemantics +import Strata.Languages.Core.Procedure +import Strata.Languages.Core.Statement +import Strata.Languages.Core.OldExpressions +import Strata.Languages.Core.StatementSemantics /-! ## Theorems related to StatementSemantics -/ diff --git a/Strata/Languages/Boogie/StatementType.lean b/Strata/Languages/Core/StatementType.lean similarity index 98% rename from Strata/Languages/Boogie/StatementType.lean rename to Strata/Languages/Core/StatementType.lean index 4c87657eb..e904cc428 100644 --- a/Strata/Languages/Boogie/StatementType.lean +++ b/Strata/Languages/Core/StatementType.lean @@ -6,10 +6,10 @@ -import Strata.Languages.Boogie.Statement -import Strata.Languages.Boogie.CmdType -import Strata.Languages.Boogie.Program -import Strata.Languages.Boogie.OldExpressions +import Strata.Languages.Core.Statement +import Strata.Languages.Core.CmdType +import Strata.Languages.Core.Program +import Strata.Languages.Core.OldExpressions import Strata.DL.Imperative.CmdType namespace Core diff --git a/Strata/Languages/Boogie/StatementWF.lean b/Strata/Languages/Core/StatementWF.lean similarity index 98% rename from Strata/Languages/Boogie/StatementWF.lean rename to Strata/Languages/Core/StatementWF.lean index 52d65f1c0..faaee29ce 100644 --- a/Strata/Languages/Boogie/StatementWF.lean +++ b/Strata/Languages/Core/StatementWF.lean @@ -7,9 +7,9 @@ import Strata.DL.Util.ListUtils -import Strata.Languages.Boogie.Program -import Strata.Languages.Boogie.WF -import Strata.Languages.Boogie.StatementType +import Strata.Languages.Core.Program +import Strata.Languages.Core.WF +import Strata.Languages.Core.StatementType --------------------------------------------------------------------- namespace Core diff --git a/Strata/Languages/Boogie/TypeDecl.lean b/Strata/Languages/Core/TypeDecl.lean similarity index 98% rename from Strata/Languages/Boogie/TypeDecl.lean rename to Strata/Languages/Core/TypeDecl.lean index 8da7df873..65fdac52b 100644 --- a/Strata/Languages/Boogie/TypeDecl.lean +++ b/Strata/Languages/Core/TypeDecl.lean @@ -6,7 +6,7 @@ -import Strata.Languages.Boogie.Statement +import Strata.Languages.Core.Statement --------------------------------------------------------------------- diff --git a/Strata/Languages/Boogie/Verifier.lean b/Strata/Languages/Core/Verifier.lean similarity index 99% rename from Strata/Languages/Boogie/Verifier.lean rename to Strata/Languages/Core/Verifier.lean index c23505dce..3a46dc574 100644 --- a/Strata/Languages/Boogie/Verifier.lean +++ b/Strata/Languages/Core/Verifier.lean @@ -4,10 +4,10 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.DDMTransform.Translate -import Strata.Languages.Boogie.Options -import Strata.Languages.Boogie.CallGraph -import Strata.Languages.Boogie.SMTEncoder +import Strata.Languages.Core.DDMTransform.Translate +import Strata.Languages.Core.Options +import Strata.Languages.Core.CallGraph +import Strata.Languages.Core.SMTEncoder import Strata.DL.Imperative.MetaData import Strata.DL.Imperative.SMTUtils import Strata.DL.SMT.CexParser diff --git a/Strata/Languages/Boogie/WF.lean b/Strata/Languages/Core/WF.lean similarity index 98% rename from Strata/Languages/Boogie/WF.lean rename to Strata/Languages/Core/WF.lean index 05294d53d..6f07c95db 100644 --- a/Strata/Languages/Boogie/WF.lean +++ b/Strata/Languages/Core/WF.lean @@ -5,8 +5,8 @@ -/ import Strata.DL.Util.ListUtils -import Strata.Languages.Boogie.Program -import Strata.Languages.Boogie.OldExpressions +import Strata.Languages.Core.Program +import Strata.Languages.Core.OldExpressions /-! # Well-Formedness of Boogie Programs This file contains well-formedness definitions of Boogie `Program`s Note that diff --git a/Strata/Languages/Laurel/Grammar/ConcreteToAbstractTreeTranslator.lean b/Strata/Languages/Laurel/Grammar/ConcreteToAbstractTreeTranslator.lean index 4e4f32ac9..6ba5474f3 100644 --- a/Strata/Languages/Laurel/Grammar/ConcreteToAbstractTreeTranslator.lean +++ b/Strata/Languages/Laurel/Grammar/ConcreteToAbstractTreeTranslator.lean @@ -8,7 +8,7 @@ import Strata.DDM.AST import Strata.Languages.Laurel.Grammar.LaurelGrammar import Strata.Languages.Laurel.Laurel import Strata.DL.Imperative.MetaData -import Strata.Languages.Boogie.Expressions +import Strata.Languages.Core.Expressions namespace Laurel diff --git a/Strata/Languages/Laurel/Laurel.lean b/Strata/Languages/Laurel/Laurel.lean index f8e084f04..03819e523 100644 --- a/Strata/Languages/Laurel/Laurel.lean +++ b/Strata/Languages/Laurel/Laurel.lean @@ -5,8 +5,8 @@ -/ import Strata.DL.Imperative.MetaData -import Strata.Languages.Boogie.Expressions -import Strata.Languages.Boogie.Procedure +import Strata.Languages.Core.Expressions +import Strata.Languages.Core.Procedure /- The Laurel language is supposed to serve as an intermediate verification language for at least Java, Python, JavaScript. diff --git a/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean b/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean index 3ac92b678..bf4af7d06 100644 --- a/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean +++ b/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean @@ -4,11 +4,11 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Program -import Strata.Languages.Boogie.Verifier -import Strata.Languages.Boogie.Statement -import Strata.Languages.Boogie.Procedure -import Strata.Languages.Boogie.Options +import Strata.Languages.Core.Program +import Strata.Languages.Core.Verifier +import Strata.Languages.Core.Statement +import Strata.Languages.Core.Procedure +import Strata.Languages.Core.Options import Strata.Languages.Laurel.Laurel import Strata.Languages.Laurel.LiftExpressionAssignments import Strata.DL.Imperative.Stmt diff --git a/Strata/Languages/Python/BoogiePrelude.lean b/Strata/Languages/Python/BoogiePrelude.lean index 37f24d314..b6c5bf399 100644 --- a/Strata/Languages/Python/BoogiePrelude.lean +++ b/Strata/Languages/Python/BoogiePrelude.lean @@ -6,8 +6,8 @@ import Strata.DDM.Elab import Strata.DDM.AST -import Strata.Languages.Boogie.DDMTransform.Parse -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.DDMTransform.Parse +import Strata.Languages.Core.Verifier namespace Strata diff --git a/Strata/Languages/Python/FunctionSignatures.lean b/Strata/Languages/Python/FunctionSignatures.lean index 9d9b1be19..b003d0d3f 100644 --- a/Strata/Languages/Python/FunctionSignatures.lean +++ b/Strata/Languages/Python/FunctionSignatures.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Boogie +import Strata.Languages.Core.Boogie namespace Strata namespace Python diff --git a/Strata/Languages/Python/PyFactory.lean b/Strata/Languages/Python/PyFactory.lean index 66a0cb32a..2baf98fd9 100644 --- a/Strata/Languages/Python/PyFactory.lean +++ b/Strata/Languages/Python/PyFactory.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier import Strata.Languages.Python.Regex.ReToBoogie namespace Strata diff --git a/Strata/Languages/Python/PythonToBoogie.lean b/Strata/Languages/Python/PythonToBoogie.lean index c0da98039..1af566c15 100644 --- a/Strata/Languages/Python/PythonToBoogie.lean +++ b/Strata/Languages/Python/PythonToBoogie.lean @@ -7,9 +7,9 @@ import Strata.DDM.Elab import Strata.DDM.AST -import Strata.Languages.Boogie.DDMTransform.Parse +import Strata.Languages.Core.DDMTransform.Parse -import Strata.Languages.Boogie.Boogie +import Strata.Languages.Core.Boogie import Strata.Languages.Python.PythonDialect import Strata.Languages.Python.FunctionSignatures import Strata.Languages.Python.Regex.ReToBoogie diff --git a/Strata/Languages/Python/Regex/ReToBoogie.lean b/Strata/Languages/Python/Regex/ReToBoogie.lean index 575218e66..581fde622 100644 --- a/Strata/Languages/Python/Regex/ReToBoogie.lean +++ b/Strata/Languages/Python/Regex/ReToBoogie.lean @@ -5,7 +5,7 @@ -/ import Strata.Languages.Python.Regex.ReParser -import Strata.Languages.Boogie.Factory +import Strata.Languages.Core.Factory namespace Strata namespace Python diff --git a/Strata/Transform/CallElimCorrect.lean b/Strata/Transform/CallElimCorrect.lean index 2a8594bee..5c1875e53 100644 --- a/Strata/Transform/CallElimCorrect.lean +++ b/Strata/Transform/CallElimCorrect.lean @@ -6,17 +6,17 @@ import Init.Data.List.Basic import Init.Data.List.Lemmas -import Strata.Languages.Boogie.Env -import Strata.Languages.Boogie.Identifiers -import Strata.Languages.Boogie.Program -import Strata.Languages.Boogie.ProgramType -import Strata.Languages.Boogie.WF +import Strata.Languages.Core.Env +import Strata.Languages.Core.Identifiers +import Strata.Languages.Core.Program +import Strata.Languages.Core.ProgramType +import Strata.Languages.Core.WF import Strata.DL.Lambda.Lambda import Strata.Transform.CoreTransform import Strata.Transform.CallElim import Strata.DL.Imperative.CmdSemantics -import Strata.Languages.Boogie.StatementSemantics -import Strata.Languages.Boogie.StatementSemanticsProps +import Strata.Languages.Core.StatementSemantics +import Strata.Languages.Core.StatementSemanticsProps import Strata.DL.Util.ListUtils /-! # Call Elimination Correctness Proof diff --git a/Strata/Transform/CoreTransform.lean b/Strata/Transform/CoreTransform.lean index ba508be33..6a9cdd986 100644 --- a/Strata/Transform/CoreTransform.lean +++ b/Strata/Transform/CoreTransform.lean @@ -4,9 +4,9 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Statement -import Strata.Languages.Boogie.Boogie -import Strata.Languages.Boogie.BoogieGen +import Strata.Languages.Core.Statement +import Strata.Languages.Core.Boogie +import Strata.Languages.Core.BoogieGen import Strata.DL.Util.LabelGen /-! # Utility functions for program transformation in Strata Core -/ diff --git a/Strata/Transform/DetToNondet.lean b/Strata/Transform/DetToNondet.lean index 37313a927..ec163de41 100644 --- a/Strata/Transform/DetToNondet.lean +++ b/Strata/Transform/DetToNondet.lean @@ -7,7 +7,7 @@ import Strata.DL.Imperative.Cmd import Strata.DL.Imperative.Stmt import Strata.DL.Imperative.NondetStmt -import Strata.Languages.Boogie.StatementType +import Strata.Languages.Core.StatementType /-! # Deterministic-to-Nondeterministic Transformation -/ diff --git a/Strata/Transform/ProcedureInlining.lean b/Strata/Transform/ProcedureInlining.lean index 54578c7a3..c5c2ff9b2 100644 --- a/Strata/Transform/ProcedureInlining.lean +++ b/Strata/Transform/ProcedureInlining.lean @@ -6,10 +6,10 @@ import Strata.DL.Util.LabelGen import Strata.DL.Util.ListUtils -import Strata.Languages.Boogie.Boogie -import Strata.Languages.Boogie.BoogieGen -import Strata.Languages.Boogie.ProgramWF -import Strata.Languages.Boogie.Statement +import Strata.Languages.Core.Boogie +import Strata.Languages.Core.BoogieGen +import Strata.Languages.Core.ProgramWF +import Strata.Languages.Core.Statement import Strata.Transform.CoreTransform /-! # Procedure Inlining Transformation -/ @@ -223,7 +223,7 @@ def inlineCallCmd (excluded_calls:List String := []) -- set x1 := out1 --- outputSetStmts -- set x2 := out2 -- `init outN` is not necessary because calls are only allowed to use - -- already declared variables (per Boogie.typeCheck) + -- already declared variables (per Core.typeCheck) -- Create a fresh var statement for each LHS let outputTrips ← genOutExprIdentsTrip sigOutputs sigOutputs.unzip.fst diff --git a/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean b/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean index 49f5d6c0b..715708d00 100644 --- a/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean +++ b/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier import Strata.Backends.CBMC.GOTO.InstToJson import StrataTest.Backends.CBMC.ToCProverGOTO diff --git a/StrataTest/DDM/Integration/Java/TestGen.lean b/StrataTest/DDM/Integration/Java/TestGen.lean index 01c08f3be..2711bae0e 100644 --- a/StrataTest/DDM/Integration/Java/TestGen.lean +++ b/StrataTest/DDM/Integration/Java/TestGen.lean @@ -7,7 +7,7 @@ import Strata.DDM.Integration.Java import Strata.DDM.Integration.Lean.Env -- For dialectExt import Strata.DDM.Integration.Lean.HashCommands -- For #load_dialect -import Strata.Languages.Boogie.DDMTransform.Parse -- Loads Boogie dialect into env +import Strata.Languages.Core.DDMTransform.Parse -- Loads Boogie dialect into env namespace Strata.Java.Test diff --git a/StrataTest/Internal/InternalBoogiePrelude.lean b/StrataTest/Internal/InternalBoogiePrelude.lean index f617f6920..5f441c05d 100644 --- a/StrataTest/Internal/InternalBoogiePrelude.lean +++ b/StrataTest/Internal/InternalBoogiePrelude.lean @@ -6,8 +6,8 @@ import Strata.DDM.Elab import Strata.DDM.AST -import Strata.Languages.Boogie.DDMTransform.Parse -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.DDMTransform.Parse +import Strata.Languages.Core.Verifier import Strata.Languages.Python.BoogiePrelude namespace Strata diff --git a/StrataTest/Internal/InternalFunctionSignatures.lean b/StrataTest/Internal/InternalFunctionSignatures.lean index a286a750c..30183d033 100644 --- a/StrataTest/Internal/InternalFunctionSignatures.lean +++ b/StrataTest/Internal/InternalFunctionSignatures.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Boogie +import Strata.Languages.Core.Boogie import Strata.Languages.Python.FunctionSignatures namespace Strata diff --git a/StrataTest/Languages/Boogie/DatatypeVerificationTests.lean b/StrataTest/Languages/Boogie/DatatypeVerificationTests.lean index 8db0230a1..13ddcd229 100644 --- a/StrataTest/Languages/Boogie/DatatypeVerificationTests.lean +++ b/StrataTest/Languages/Boogie/DatatypeVerificationTests.lean @@ -4,8 +4,8 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Boogie -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Verifier import Strata.DL.Lambda.TypeFactory /-! diff --git a/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean b/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean index 6c6776ba8..13378be99 100644 --- a/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean +++ b/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean @@ -5,7 +5,7 @@ -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- open Strata diff --git a/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean b/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean index fefbed66e..76264f40f 100644 --- a/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean +++ b/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean b/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean index 3fb9a542c..94404cb6a 100644 --- a/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean +++ b/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/Axioms.lean b/StrataTest/Languages/Boogie/Examples/Axioms.lean index 6d967c819..df3cb302a 100644 --- a/StrataTest/Languages/Boogie/Examples/Axioms.lean +++ b/StrataTest/Languages/Boogie/Examples/Axioms.lean @@ -5,8 +5,8 @@ -/ -import Strata.Languages.Boogie.Verifier -import Strata.Languages.Boogie.CallGraph +import Strata.Languages.Core.Verifier +import Strata.Languages.Core.CallGraph --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/BitVecParse.lean b/StrataTest/Languages/Boogie/Examples/BitVecParse.lean index 488698897..d990ae5c8 100644 --- a/StrataTest/Languages/Boogie/Examples/BitVecParse.lean +++ b/StrataTest/Languages/Boogie/Examples/BitVecParse.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/Cover.lean b/StrataTest/Languages/Boogie/Examples/Cover.lean index f8192d358..445cd3d07 100644 --- a/StrataTest/Languages/Boogie/Examples/Cover.lean +++ b/StrataTest/Languages/Boogie/Examples/Cover.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean b/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean index b030c92c7..cfbe54864 100644 --- a/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean +++ b/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean @@ -5,7 +5,7 @@ -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata @@ -94,302 +94,302 @@ axiom [updatePreserves]:forall((((m):(Map v k)),((okk):(k))),((kk):(k))),((vv):( #eval IO.println examplePgm.format.render /-- -info: #[{ ann := { start := { byteIdx := 293 }, stop := { byteIdx := 300 } }, +info: #[{ ann := { start := { byteIdx := 291 }, stop := { byteIdx := 298 } }, name := { dialect := "Core", name := "command_typedecl" }, args := - ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 298 }, stop := { byteIdx := 299 } } "k")).push - (ArgF.option { start := { byteIdx := 299 }, stop := { byteIdx := 299 } } none) }, - { ann := { start := { byteIdx := 301 }, stop := { byteIdx := 308 } }, + ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 296 }, stop := { byteIdx := 297 } } "k")).push + (ArgF.option { start := { byteIdx := 297 }, stop := { byteIdx := 297 } } none) }, + { ann := { start := { byteIdx := 299 }, stop := { byteIdx := 306 } }, name := { dialect := "Core", name := "command_typedecl" }, args := - ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 306 }, stop := { byteIdx := 307 } } "v")).push - (ArgF.option { start := { byteIdx := 307 }, stop := { byteIdx := 307 } } none) }, - { ann := { start := { byteIdx := 309 }, stop := { byteIdx := 388 } }, + ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 304 }, stop := { byteIdx := 305 } } "v")).push + (ArgF.option { start := { byteIdx := 305 }, stop := { byteIdx := 305 } } none) }, + { ann := { start := { byteIdx := 307 }, stop := { byteIdx := 386 } }, name := { dialect := "Core", name := "command_axiom" }, args := ((Array.mkEmpty 2).push - (ArgF.option { start := { byteIdx := 315 }, stop := { byteIdx := 330 } } + (ArgF.option { start := { byteIdx := 313 }, stop := { byteIdx := 328 } } (some (ArgF.op - { ann := { start := { byteIdx := 315 }, stop := { byteIdx := 330 } }, + { ann := { start := { byteIdx := 313 }, stop := { byteIdx := 328 } }, name := { dialect := "Core", name := "label" }, args := (Array.mkEmpty 1).push - (ArgF.ident { start := { byteIdx := 316 }, stop := { byteIdx := 328 } } + (ArgF.ident { start := { byteIdx := 314 }, stop := { byteIdx := 326 } } "updateSelect") })))).push (ArgF.expr - (ExprF.app { start := { byteIdx := 331 }, stop := { byteIdx := 387 } } - (ExprF.app { start := { byteIdx := 331 }, stop := { byteIdx := 387 } } - (ExprF.fn { start := { byteIdx := 331 }, stop := { byteIdx := 387 } } + (ExprF.app { start := { byteIdx := 329 }, stop := { byteIdx := 385 } } + (ExprF.app { start := { byteIdx := 329 }, stop := { byteIdx := 385 } } + (ExprF.fn { start := { byteIdx := 329 }, stop := { byteIdx := 385 } } { dialect := "Core", name := "forall" }) (ArgF.op - { ann := { start := { byteIdx := 338 }, stop := { byteIdx := 362 } }, + { ann := { start := { byteIdx := 336 }, stop := { byteIdx := 360 } }, name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 338 }, stop := { byteIdx := 355 } }, + { ann := { start := { byteIdx := 336 }, stop := { byteIdx := 353 } }, name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 338 }, stop := { byteIdx := 348 } }, + { ann := { start := { byteIdx := 336 }, stop := { byteIdx := 346 } }, name := { dialect := "Core", name := "declAtom" }, args := (Array.mkEmpty 1).push (ArgF.op - { ann := { start := { byteIdx := 338 }, stop := { byteIdx := 348 } }, + { ann := { start := { byteIdx := 336 }, stop := { byteIdx := 346 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 338 }, - stop := { byteIdx := 339 } } + { start := { byteIdx := 336 }, + stop := { byteIdx := 337 } } "m")).push (ArgF.option - { start := { byteIdx := 341 }, stop := { byteIdx := 341 } } + { start := { byteIdx := 339 }, stop := { byteIdx := 339 } } none)).push (ArgF.type (TypeExprF.ident - { start := { byteIdx := 341 }, stop := { byteIdx := 344 } } + { start := { byteIdx := 339 }, stop := { byteIdx := 342 } } { dialect := "Core", name := "Map" } (((Array.mkEmpty 2).push (TypeExprF.fvar - { start := { byteIdx := 347 }, - stop := { byteIdx := 348 } } + { start := { byteIdx := 345 }, + stop := { byteIdx := 346 } } 1 (Array.mkEmpty 0))).push (TypeExprF.fvar - { start := { byteIdx := 345 }, - stop := { byteIdx := 346 } } + { start := { byteIdx := 343 }, + stop := { byteIdx := 344 } } 0 (Array.mkEmpty 0))))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 350 }, stop := { byteIdx := 355 } }, + { ann := { start := { byteIdx := 348 }, stop := { byteIdx := 353 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 350 }, stop := { byteIdx := 352 } } + { start := { byteIdx := 348 }, stop := { byteIdx := 350 } } "kk")).push - (ArgF.option { start := { byteIdx := 354 }, stop := { byteIdx := 354 } } + (ArgF.option { start := { byteIdx := 352 }, stop := { byteIdx := 352 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 354 }, stop := { byteIdx := 355 } } + (TypeExprF.fvar { start := { byteIdx := 352 }, stop := { byteIdx := 353 } } 0 (Array.mkEmpty 0))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 357 }, stop := { byteIdx := 362 } }, + { ann := { start := { byteIdx := 355 }, stop := { byteIdx := 360 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push - (ArgF.ident { start := { byteIdx := 357 }, stop := { byteIdx := 359 } } + (ArgF.ident { start := { byteIdx := 355 }, stop := { byteIdx := 357 } } "vv")).push - (ArgF.option { start := { byteIdx := 361 }, stop := { byteIdx := 361 } } none)).push + (ArgF.option { start := { byteIdx := 359 }, stop := { byteIdx := 359 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 361 }, stop := { byteIdx := 362 } } 1 + (TypeExprF.fvar { start := { byteIdx := 359 }, stop := { byteIdx := 360 } } 1 (Array.mkEmpty 0))) }) })) (ArgF.expr - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 387 } } - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 387 } } - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 387 } } - (ExprF.fn { start := { byteIdx := 366 }, stop := { byteIdx := 387 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 385 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 385 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 385 } } + (ExprF.fn { start := { byteIdx := 364 }, stop := { byteIdx := 385 } } { dialect := "Core", name := "equal" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 347 }, stop := { byteIdx := 348 } } 1 (Array.mkEmpty 0)))) + (TypeExprF.fvar { start := { byteIdx := 345 }, stop := { byteIdx := 346 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 381 } } - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 381 } } - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 381 } } - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 381 } } - (ExprF.fn { start := { byteIdx := 366 }, stop := { byteIdx := 381 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 379 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 379 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 379 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 379 } } + (ExprF.fn { start := { byteIdx := 364 }, stop := { byteIdx := 379 } } { dialect := "Core", name := "map_get" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 345 }, stop := { byteIdx := 346 } } 0 + (TypeExprF.fvar { start := { byteIdx := 343 }, stop := { byteIdx := 344 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 347 }, stop := { byteIdx := 348 } } 1 + (TypeExprF.fvar { start := { byteIdx := 345 }, stop := { byteIdx := 346 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } - (ExprF.app { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } - (ExprF.fn { start := { byteIdx := 366 }, stop := { byteIdx := 377 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } + (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } + (ExprF.fn { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } { dialect := "Core", name := "map_set" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 345 }, stop := { byteIdx := 346 } } 0 + (TypeExprF.fvar { start := { byteIdx := 343 }, stop := { byteIdx := 344 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 347 }, stop := { byteIdx := 348 } } 1 + (TypeExprF.fvar { start := { byteIdx := 345 }, stop := { byteIdx := 346 } } 1 (Array.mkEmpty 0)))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 366 }, stop := { byteIdx := 367 } } 2))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 368 }, stop := { byteIdx := 370 } } 1))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 374 }, stop := { byteIdx := 376 } } 0))))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 378 }, stop := { byteIdx := 380 } } 1))))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 385 }, stop := { byteIdx := 387 } } 0)))))) }, - { ann := { start := { byteIdx := 389 }, stop := { byteIdx := 484 } }, + (ArgF.expr (ExprF.bvar { start := { byteIdx := 364 }, stop := { byteIdx := 365 } } 2))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 366 }, stop := { byteIdx := 368 } } 1))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 372 }, stop := { byteIdx := 374 } } 0))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 376 }, stop := { byteIdx := 378 } } 1))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 383 }, stop := { byteIdx := 385 } } 0)))))) }, + { ann := { start := { byteIdx := 387 }, stop := { byteIdx := 482 } }, name := { dialect := "Core", name := "command_axiom" }, args := ((Array.mkEmpty 2).push - (ArgF.option { start := { byteIdx := 395 }, stop := { byteIdx := 413 } } + (ArgF.option { start := { byteIdx := 393 }, stop := { byteIdx := 411 } } (some (ArgF.op - { ann := { start := { byteIdx := 395 }, stop := { byteIdx := 413 } }, + { ann := { start := { byteIdx := 393 }, stop := { byteIdx := 411 } }, name := { dialect := "Core", name := "label" }, args := (Array.mkEmpty 1).push - (ArgF.ident { start := { byteIdx := 396 }, stop := { byteIdx := 411 } } + (ArgF.ident { start := { byteIdx := 394 }, stop := { byteIdx := 409 } } "updatePreserves") })))).push (ArgF.expr - (ExprF.app { start := { byteIdx := 414 }, stop := { byteIdx := 483 } } - (ExprF.app { start := { byteIdx := 414 }, stop := { byteIdx := 483 } } - (ExprF.fn { start := { byteIdx := 414 }, stop := { byteIdx := 483 } } + (ExprF.app { start := { byteIdx := 412 }, stop := { byteIdx := 481 } } + (ExprF.app { start := { byteIdx := 412 }, stop := { byteIdx := 481 } } + (ExprF.fn { start := { byteIdx := 412 }, stop := { byteIdx := 481 } } { dialect := "Core", name := "forall" }) (ArgF.op - { ann := { start := { byteIdx := 421 }, stop := { byteIdx := 453 } }, + { ann := { start := { byteIdx := 419 }, stop := { byteIdx := 451 } }, name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 421 }, stop := { byteIdx := 446 } }, + { ann := { start := { byteIdx := 419 }, stop := { byteIdx := 444 } }, name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 421 }, stop := { byteIdx := 439 } }, + { ann := { start := { byteIdx := 419 }, stop := { byteIdx := 437 } }, name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op { ann := - { start := { byteIdx := 421 }, stop := { byteIdx := 431 } }, + { start := { byteIdx := 419 }, stop := { byteIdx := 429 } }, name := { dialect := "Core", name := "declAtom" }, args := (Array.mkEmpty 1).push (ArgF.op { ann := - { start := { byteIdx := 421 }, - stop := { byteIdx := 431 } }, + { start := { byteIdx := 419 }, + stop := { byteIdx := 429 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 421 }, - stop := { byteIdx := 422 } } + { start := { byteIdx := 419 }, + stop := { byteIdx := 420 } } "m")).push (ArgF.option - { start := { byteIdx := 424 }, - stop := { byteIdx := 424 } } + { start := { byteIdx := 422 }, + stop := { byteIdx := 422 } } none)).push (ArgF.type (TypeExprF.ident - { start := { byteIdx := 424 }, - stop := { byteIdx := 427 } } + { start := { byteIdx := 422 }, + stop := { byteIdx := 425 } } { dialect := "Core", name := "Map" } (((Array.mkEmpty 2).push (TypeExprF.fvar - { start := { byteIdx := 430 }, - stop := { byteIdx := 431 } } + { start := { byteIdx := 428 }, + stop := { byteIdx := 429 } } 1 (Array.mkEmpty 0))).push (TypeExprF.fvar - { start := { byteIdx := 428 }, - stop := { byteIdx := 429 } } + { start := { byteIdx := 426 }, + stop := { byteIdx := 427 } } 0 (Array.mkEmpty 0))))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 433 }, stop := { byteIdx := 439 } }, + { ann := { start := { byteIdx := 431 }, stop := { byteIdx := 437 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 433 }, - stop := { byteIdx := 436 } } + { start := { byteIdx := 431 }, + stop := { byteIdx := 434 } } "okk")).push (ArgF.option - { start := { byteIdx := 438 }, stop := { byteIdx := 438 } } + { start := { byteIdx := 436 }, stop := { byteIdx := 436 } } none)).push (ArgF.type (TypeExprF.fvar - { start := { byteIdx := 438 }, stop := { byteIdx := 439 } } 0 + { start := { byteIdx := 436 }, stop := { byteIdx := 437 } } 0 (Array.mkEmpty 0))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 441 }, stop := { byteIdx := 446 } }, + { ann := { start := { byteIdx := 439 }, stop := { byteIdx := 444 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 441 }, stop := { byteIdx := 443 } } + { start := { byteIdx := 439 }, stop := { byteIdx := 441 } } "kk")).push - (ArgF.option { start := { byteIdx := 445 }, stop := { byteIdx := 445 } } + (ArgF.option { start := { byteIdx := 443 }, stop := { byteIdx := 443 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 445 }, stop := { byteIdx := 446 } } + (TypeExprF.fvar { start := { byteIdx := 443 }, stop := { byteIdx := 444 } } 0 (Array.mkEmpty 0))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 448 }, stop := { byteIdx := 453 } }, + { ann := { start := { byteIdx := 446 }, stop := { byteIdx := 451 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push - (ArgF.ident { start := { byteIdx := 448 }, stop := { byteIdx := 450 } } + (ArgF.ident { start := { byteIdx := 446 }, stop := { byteIdx := 448 } } "vv")).push - (ArgF.option { start := { byteIdx := 452 }, stop := { byteIdx := 452 } } none)).push + (ArgF.option { start := { byteIdx := 450 }, stop := { byteIdx := 450 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 452 }, stop := { byteIdx := 453 } } 1 + (TypeExprF.fvar { start := { byteIdx := 450 }, stop := { byteIdx := 451 } } 1 (Array.mkEmpty 0))) }) })) (ArgF.expr - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 483 } } - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 483 } } - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 483 } } - (ExprF.fn { start := { byteIdx := 457 }, stop := { byteIdx := 483 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 481 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 481 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 481 } } + (ExprF.fn { start := { byteIdx := 455 }, stop := { byteIdx := 481 } } { dialect := "Core", name := "equal" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 430 }, stop := { byteIdx := 431 } } 1 (Array.mkEmpty 0)))) + (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 473 } } - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 473 } } - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 473 } } - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 473 } } - (ExprF.fn { start := { byteIdx := 457 }, stop := { byteIdx := 473 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 471 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 471 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 471 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 471 } } + (ExprF.fn { start := { byteIdx := 455 }, stop := { byteIdx := 471 } } { dialect := "Core", name := "map_get" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 0 + (TypeExprF.fvar { start := { byteIdx := 426 }, stop := { byteIdx := 427 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 430 }, stop := { byteIdx := 431 } } 1 + (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } - (ExprF.app { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } - (ExprF.fn { start := { byteIdx := 457 }, stop := { byteIdx := 468 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } + (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } + (ExprF.fn { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } { dialect := "Core", name := "map_set" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 0 + (TypeExprF.fvar { start := { byteIdx := 426 }, stop := { byteIdx := 427 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 430 }, stop := { byteIdx := 431 } } 1 + (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 1 (Array.mkEmpty 0)))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 457 }, stop := { byteIdx := 458 } } 3))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 459 }, stop := { byteIdx := 461 } } 1))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 465 }, stop := { byteIdx := 467 } } 0))))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 469 }, stop := { byteIdx := 472 } } 2))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 455 }, stop := { byteIdx := 456 } } 3))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 457 }, stop := { byteIdx := 459 } } 1))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 463 }, stop := { byteIdx := 465 } } 0))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 467 }, stop := { byteIdx := 470 } } 2))))) (ArgF.expr - (ExprF.app { start := { byteIdx := 477 }, stop := { byteIdx := 483 } } - (ExprF.app { start := { byteIdx := 477 }, stop := { byteIdx := 483 } } - (ExprF.app { start := { byteIdx := 477 }, stop := { byteIdx := 483 } } - (ExprF.app { start := { byteIdx := 477 }, stop := { byteIdx := 483 } } - (ExprF.fn { start := { byteIdx := 477 }, stop := { byteIdx := 483 } } + (ExprF.app { start := { byteIdx := 475 }, stop := { byteIdx := 481 } } + (ExprF.app { start := { byteIdx := 475 }, stop := { byteIdx := 481 } } + (ExprF.app { start := { byteIdx := 475 }, stop := { byteIdx := 481 } } + (ExprF.app { start := { byteIdx := 475 }, stop := { byteIdx := 481 } } + (ExprF.fn { start := { byteIdx := 475 }, stop := { byteIdx := 481 } } { dialect := "Core", name := "map_get" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 0 + (TypeExprF.fvar { start := { byteIdx := 426 }, stop := { byteIdx := 427 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 430 }, stop := { byteIdx := 431 } } 1 + (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 1 (Array.mkEmpty 0)))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 477 }, stop := { byteIdx := 478 } } 3))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 479 }, stop := { byteIdx := 482 } } 2)))))))) }] + (ArgF.expr (ExprF.bvar { start := { byteIdx := 475 }, stop := { byteIdx := 476 } } 3))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 477 }, stop := { byteIdx := 480 } } 2)))))))) }] -/ #guard_msgs in #eval examplePgm.commands diff --git a/StrataTest/Languages/Boogie/Examples/DDMTransform.lean b/StrataTest/Languages/Boogie/Examples/DDMTransform.lean index 11fb72a7d..517455cea 100644 --- a/StrataTest/Languages/Boogie/Examples/DDMTransform.lean +++ b/StrataTest/Languages/Boogie/Examples/DDMTransform.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeEnum.lean b/StrataTest/Languages/Boogie/Examples/DatatypeEnum.lean index f17055baf..ab5c5aa0a 100644 --- a/StrataTest/Languages/Boogie/Examples/DatatypeEnum.lean +++ b/StrataTest/Languages/Boogie/Examples/DatatypeEnum.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier /-! # Datatype Enum Integration Test diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeList.lean b/StrataTest/Languages/Boogie/Examples/DatatypeList.lean index 4f2db3ded..1cdaa36a1 100644 --- a/StrataTest/Languages/Boogie/Examples/DatatypeList.lean +++ b/StrataTest/Languages/Boogie/Examples/DatatypeList.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier /-! # Datatype List Integration Test diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeOption.lean b/StrataTest/Languages/Boogie/Examples/DatatypeOption.lean index c9ae8c4e3..c0572d6d4 100644 --- a/StrataTest/Languages/Boogie/Examples/DatatypeOption.lean +++ b/StrataTest/Languages/Boogie/Examples/DatatypeOption.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier /-! # Datatype Option Integration Test diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeTree.lean b/StrataTest/Languages/Boogie/Examples/DatatypeTree.lean index 8f83eaff5..055653804 100644 --- a/StrataTest/Languages/Boogie/Examples/DatatypeTree.lean +++ b/StrataTest/Languages/Boogie/Examples/DatatypeTree.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier /-! # Datatype Tree Integration Test diff --git a/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean b/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean index 0a8abba68..94a130a95 100644 --- a/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean +++ b/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean @@ -5,7 +5,7 @@ -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- open Strata diff --git a/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean b/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean index eff6ab7df..bb5f4abc0 100644 --- a/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean +++ b/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/Functions.lean b/StrataTest/Languages/Boogie/Examples/Functions.lean index 8d6a9f633..9fa0aaf30 100644 --- a/StrataTest/Languages/Boogie/Examples/Functions.lean +++ b/StrataTest/Languages/Boogie/Examples/Functions.lean @@ -4,8 +4,8 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier -import Strata.Languages.Boogie.CallGraph +import Strata.Languages.Core.Verifier +import Strata.Languages.Core.CallGraph --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean b/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean index 75635e30e..a7216e97e 100644 --- a/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean +++ b/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/Goto.lean b/StrataTest/Languages/Boogie/Examples/Goto.lean index 9cd19c05c..7b245bd2e 100644 --- a/StrataTest/Languages/Boogie/Examples/Goto.lean +++ b/StrataTest/Languages/Boogie/Examples/Goto.lean @@ -4,8 +4,8 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Boogie -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/Havoc.lean b/StrataTest/Languages/Boogie/Examples/Havoc.lean index 60b106d58..b93308057 100644 --- a/StrataTest/Languages/Boogie/Examples/Havoc.lean +++ b/StrataTest/Languages/Boogie/Examples/Havoc.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/Loops.lean b/StrataTest/Languages/Boogie/Examples/Loops.lean index 347d83bbb..1395186fd 100644 --- a/StrataTest/Languages/Boogie/Examples/Loops.lean +++ b/StrataTest/Languages/Boogie/Examples/Loops.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/Map.lean b/StrataTest/Languages/Boogie/Examples/Map.lean index 6c758e707..1c970ffd7 100644 --- a/StrataTest/Languages/Boogie/Examples/Map.lean +++ b/StrataTest/Languages/Boogie/Examples/Map.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier open Strata diff --git a/StrataTest/Languages/Boogie/Examples/Min.lean b/StrataTest/Languages/Boogie/Examples/Min.lean index 4b010b949..c344dc1a4 100644 --- a/StrataTest/Languages/Boogie/Examples/Min.lean +++ b/StrataTest/Languages/Boogie/Examples/Min.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/OldExpressions.lean b/StrataTest/Languages/Boogie/Examples/OldExpressions.lean index 0bc4a5bec..6e3004ae0 100644 --- a/StrataTest/Languages/Boogie/Examples/OldExpressions.lean +++ b/StrataTest/Languages/Boogie/Examples/OldExpressions.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean b/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean index 233376527..b8f969f17 100644 --- a/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean +++ b/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean b/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean index 6cdc7d45f..55f51bf13 100644 --- a/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean +++ b/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean @@ -4,8 +4,8 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier -import Strata.Languages.Boogie.CallGraph +import Strata.Languages.Core.Verifier +import Strata.Languages.Core.CallGraph --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/Quantifiers.lean b/StrataTest/Languages/Boogie/Examples/Quantifiers.lean index 83e2c3058..d154ec6ad 100644 --- a/StrataTest/Languages/Boogie/Examples/Quantifiers.lean +++ b/StrataTest/Languages/Boogie/Examples/Quantifiers.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean b/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean index 38c1770b7..2b837a884 100644 --- a/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean +++ b/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/RealBitVector.lean b/StrataTest/Languages/Boogie/Examples/RealBitVector.lean index 87b61d4fb..a5b51bf5d 100644 --- a/StrataTest/Languages/Boogie/Examples/RealBitVector.lean +++ b/StrataTest/Languages/Boogie/Examples/RealBitVector.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean b/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean index ae98cb931..6019e1eb9 100644 --- a/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean +++ b/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/Regex.lean b/StrataTest/Languages/Boogie/Examples/Regex.lean index 1f5b896d0..e633d74bb 100644 --- a/StrataTest/Languages/Boogie/Examples/Regex.lean +++ b/StrataTest/Languages/Boogie/Examples/Regex.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/RemoveIrrelevantAxioms.lean b/StrataTest/Languages/Boogie/Examples/RemoveIrrelevantAxioms.lean index b7b020030..90a10b922 100644 --- a/StrataTest/Languages/Boogie/Examples/RemoveIrrelevantAxioms.lean +++ b/StrataTest/Languages/Boogie/Examples/RemoveIrrelevantAxioms.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/SimpleProc.lean b/StrataTest/Languages/Boogie/Examples/SimpleProc.lean index 75e2d52ed..39ab804c0 100644 --- a/StrataTest/Languages/Boogie/Examples/SimpleProc.lean +++ b/StrataTest/Languages/Boogie/Examples/SimpleProc.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/String.lean b/StrataTest/Languages/Boogie/Examples/String.lean index 93943886a..cdf268c83 100644 --- a/StrataTest/Languages/Boogie/Examples/String.lean +++ b/StrataTest/Languages/Boogie/Examples/String.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/TypeAlias.lean b/StrataTest/Languages/Boogie/Examples/TypeAlias.lean index 73fa7fe53..2ffaa3a29 100644 --- a/StrataTest/Languages/Boogie/Examples/TypeAlias.lean +++ b/StrataTest/Languages/Boogie/Examples/TypeAlias.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/TypeDecl.lean b/StrataTest/Languages/Boogie/Examples/TypeDecl.lean index d4878a83e..59cb82f2c 100644 --- a/StrataTest/Languages/Boogie/Examples/TypeDecl.lean +++ b/StrataTest/Languages/Boogie/Examples/TypeDecl.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean b/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean index 03d5e4ede..cbc304291 100644 --- a/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean +++ b/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean @@ -6,7 +6,7 @@ -- Fix for https://github.com/strata-org/Strata/issues/105. -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier namespace Strata diff --git a/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean b/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean index 666a5b707..fa71d5647 100644 --- a/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean +++ b/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata diff --git a/StrataTest/Languages/Boogie/ExprEvalTest.lean b/StrataTest/Languages/Boogie/ExprEvalTest.lean index d89fe7399..1d2eeadaf 100644 --- a/StrataTest/Languages/Boogie/ExprEvalTest.lean +++ b/StrataTest/Languages/Boogie/ExprEvalTest.lean @@ -10,12 +10,12 @@ import Strata.DL.Lambda.LState import Strata.DL.Lambda.LTy import Strata.DL.SMT.Term import Strata.DL.SMT.Encoder -import Strata.Languages.Boogie.Env -import Strata.Languages.Boogie.Factory -import Strata.Languages.Boogie.Identifiers -import Strata.Languages.Boogie.Options -import Strata.Languages.Boogie.SMTEncoder -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Env +import Strata.Languages.Core.Factory +import Strata.Languages.Core.Identifiers +import Strata.Languages.Core.Options +import Strata.Languages.Core.SMTEncoder +import Strata.Languages.Core.Verifier import Strata.DL.Lambda.TestGen import Strata.DL.Lambda.PlausibleHelpers import Plausible.Gen diff --git a/StrataTest/Languages/Boogie/ProcedureEvalTests.lean b/StrataTest/Languages/Boogie/ProcedureEvalTests.lean index f6b56c157..f716dee51 100644 --- a/StrataTest/Languages/Boogie/ProcedureEvalTests.lean +++ b/StrataTest/Languages/Boogie/ProcedureEvalTests.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.ProcedureEval +import Strata.Languages.Core.ProcedureEval namespace Core diff --git a/StrataTest/Languages/Boogie/ProcedureTypeTests.lean b/StrataTest/Languages/Boogie/ProcedureTypeTests.lean index da4f79740..7379b45d9 100644 --- a/StrataTest/Languages/Boogie/ProcedureTypeTests.lean +++ b/StrataTest/Languages/Boogie/ProcedureTypeTests.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.ProcedureType +import Strata.Languages.Core.ProcedureType namespace Core diff --git a/StrataTest/Languages/Boogie/ProgramTypeTests.lean b/StrataTest/Languages/Boogie/ProgramTypeTests.lean index d5da94b54..618e8d1b4 100644 --- a/StrataTest/Languages/Boogie/ProgramTypeTests.lean +++ b/StrataTest/Languages/Boogie/ProgramTypeTests.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Boogie +import Strata.Languages.Core.Boogie namespace Core diff --git a/StrataTest/Languages/Boogie/SMTEncoderDatatypeTest.lean b/StrataTest/Languages/Boogie/SMTEncoderDatatypeTest.lean index f5b37574f..7e2f5ce5a 100644 --- a/StrataTest/Languages/Boogie/SMTEncoderDatatypeTest.lean +++ b/StrataTest/Languages/Boogie/SMTEncoderDatatypeTest.lean @@ -11,12 +11,12 @@ import Strata.DL.Lambda.LTy import Strata.DL.Lambda.TypeFactory import Strata.DL.SMT.Term import Strata.DL.SMT.Encoder -import Strata.Languages.Boogie.Env -import Strata.Languages.Boogie.Factory -import Strata.Languages.Boogie.Identifiers -import Strata.Languages.Boogie.Options -import Strata.Languages.Boogie.SMTEncoder -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Env +import Strata.Languages.Core.Factory +import Strata.Languages.Core.Identifiers +import Strata.Languages.Core.Options +import Strata.Languages.Core.SMTEncoder +import Strata.Languages.Core.Verifier /-! This file contains unit tests for SMT datatype encoding. diff --git a/StrataTest/Languages/Boogie/StatementEvalTests.lean b/StrataTest/Languages/Boogie/StatementEvalTests.lean index 2ed497e38..8281bec1c 100644 --- a/StrataTest/Languages/Boogie/StatementEvalTests.lean +++ b/StrataTest/Languages/Boogie/StatementEvalTests.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.StatementEval +import Strata.Languages.Core.StatementEval namespace Core --------------------------------------------------------------------- diff --git a/StrataTest/Languages/Boogie/StatementTypeTests.lean b/StrataTest/Languages/Boogie/StatementTypeTests.lean index 9141f0a6f..bc41e1cc6 100644 --- a/StrataTest/Languages/Boogie/StatementTypeTests.lean +++ b/StrataTest/Languages/Boogie/StatementTypeTests.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.StatementType +import Strata.Languages.Core.StatementType namespace Core --------------------------------------------------------------------- diff --git a/StrataTest/Transform/CallElim.lean b/StrataTest/Transform/CallElim.lean index 13874230c..160e6774d 100644 --- a/StrataTest/Transform/CallElim.lean +++ b/StrataTest/Transform/CallElim.lean @@ -6,11 +6,11 @@ import Strata.DDM.Integration.Lean import Strata.DDM.Util.Format -import Strata.Languages.Boogie.Boogie -import Strata.Languages.Boogie.DDMTransform.Translate -import Strata.Languages.Boogie.ProgramType -import Strata.Languages.Boogie.ProgramWF -import Strata.Languages.Boogie.StatementSemantics +import Strata.Languages.Core.Boogie +import Strata.Languages.Core.DDMTransform.Translate +import Strata.Languages.Core.ProgramType +import Strata.Languages.Core.ProgramWF +import Strata.Languages.Core.StatementSemantics import Strata.Transform.CoreTransform import Strata.Transform.CallElim diff --git a/StrataTest/Transform/DetToNondet.lean b/StrataTest/Transform/DetToNondet.lean index 362160f66..93d233751 100644 --- a/StrataTest/Transform/DetToNondet.lean +++ b/StrataTest/Transform/DetToNondet.lean @@ -5,9 +5,9 @@ -/ import Strata.Transform.DetToNondet -import Strata.Languages.Boogie.StatementSemantics -import Strata.Languages.Boogie.ProgramType -import Strata.Languages.Boogie.ProgramWF +import Strata.Languages.Core.StatementSemantics +import Strata.Languages.Core.ProgramType +import Strata.Languages.Core.ProgramWF import Strata.DL.Lambda.IntBoolFactory open Core diff --git a/StrataTest/Transform/ProcedureInlining.lean b/StrataTest/Transform/ProcedureInlining.lean index 499d2fbd0..8b1cec2dc 100644 --- a/StrataTest/Transform/ProcedureInlining.lean +++ b/StrataTest/Transform/ProcedureInlining.lean @@ -6,11 +6,11 @@ import Strata.DDM.Integration.Lean import Strata.DDM.Util.Format -import Strata.Languages.Boogie.Boogie -import Strata.Languages.Boogie.DDMTransform.Translate -import Strata.Languages.Boogie.StatementSemantics -import Strata.Languages.Boogie.ProgramType -import Strata.Languages.Boogie.ProgramWF +import Strata.Languages.Core.Boogie +import Strata.Languages.Core.DDMTransform.Translate +import Strata.Languages.Core.StatementSemantics +import Strata.Languages.Core.ProgramType +import Strata.Languages.Core.ProgramWF import Strata.Transform.CoreTransform import Strata.Transform.ProcedureInlining diff --git a/StrataTest/Util/TestDiagnostics.lean b/StrataTest/Util/TestDiagnostics.lean index 312cfe54a..f2cb684c1 100644 --- a/StrataTest/Util/TestDiagnostics.lean +++ b/StrataTest/Util/TestDiagnostics.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier import Lean.Elab.Command open Strata diff --git a/StrataToCBMC.lean b/StrataToCBMC.lean index 0d91ca0fb..7ecf3007e 100644 --- a/StrataToCBMC.lean +++ b/StrataToCBMC.lean @@ -7,7 +7,7 @@ import Lean.Data.Json import Strata.Backends.CBMC.StrataToCBMC import Strata.Backends.CBMC.BoogieToCBMC -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier import Strata.Languages.C_Simp.Verify import Strata.Util.IO import Std.Internal.Parsec diff --git a/StrataVerify.lean b/StrataVerify.lean index 14da55153..f514b9188 100644 --- a/StrataVerify.lean +++ b/StrataVerify.lean @@ -5,7 +5,7 @@ -/ -- Executable for verifying a Strata program from a file. -import Strata.Languages.Boogie.Verifier +import Strata.Languages.Core.Verifier import Strata.Languages.C_Simp.Verify import Strata.Util.IO import Std.Internal.Parsec From ad78a1bfd2a63eb19e6edf513b5ef2add8dc040d Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 15:08:44 -0600 Subject: [PATCH 06/19] Rename StrataTest/Languages/Boogie to StrataTest/Languages/Core --- .../Languages/{Boogie => Core}/DatatypeVerificationTests.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/AdvancedMaps.lean | 0 .../Languages/{Boogie => Core}/Examples/AdvancedQuantifiers.lean | 0 .../{Boogie => Core}/Examples/AssertionDefaultNames.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/Axioms.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/BitVecParse.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/Cover.lean | 0 .../Languages/{Boogie => Core}/Examples/DDMAxiomsExtraction.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/DDMTransform.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/DatatypeEnum.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/DatatypeList.lean | 0 .../Languages/{Boogie => Core}/Examples/DatatypeOption.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/DatatypeTree.lean | 0 .../Languages/{Boogie => Core}/Examples/FailingAssertion.lean | 0 .../Languages/{Boogie => Core}/Examples/FreeRequireEnsure.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/Functions.lean | 0 .../Languages/{Boogie => Core}/Examples/GeneratedLabels.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/Goto.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/Havoc.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/Loops.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/Map.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/Min.lean | 0 .../Languages/{Boogie => Core}/Examples/OldExpressions.lean | 0 .../Languages/{Boogie => Core}/Examples/PrecedenceCheck.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/ProcedureCall.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/Quantifiers.lean | 0 .../{Boogie => Core}/Examples/QuantifiersWithTypeAliases.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/RealBitVector.lean | 0 .../Languages/{Boogie => Core}/Examples/RecursiveProcIte.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/Regex.lean | 0 .../{Boogie => Core}/Examples/RemoveIrrelevantAxioms.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/SimpleProc.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/String.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/TypeAlias.lean | 0 StrataTest/Languages/{Boogie => Core}/Examples/TypeDecl.lean | 0 .../{Boogie => Core}/Examples/TypeVarImplicitlyQuantified.lean | 0 .../Languages/{Boogie => Core}/Examples/UnreachableAssert.lean | 0 StrataTest/Languages/{Boogie => Core}/ExprEvalTest.lean | 0 StrataTest/Languages/{Boogie => Core}/ProcedureEvalTests.lean | 0 StrataTest/Languages/{Boogie => Core}/ProcedureTypeTests.lean | 0 StrataTest/Languages/{Boogie => Core}/ProgramTypeTests.lean | 0 StrataTest/Languages/{Boogie => Core}/SMTEncoderDatatypeTest.lean | 0 StrataTest/Languages/{Boogie => Core}/StatementEvalTests.lean | 0 StrataTest/Languages/{Boogie => Core}/StatementTypeTests.lean | 0 44 files changed, 0 insertions(+), 0 deletions(-) rename StrataTest/Languages/{Boogie => Core}/DatatypeVerificationTests.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/AdvancedMaps.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/AdvancedQuantifiers.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/AssertionDefaultNames.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/Axioms.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/BitVecParse.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/Cover.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/DDMAxiomsExtraction.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/DDMTransform.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/DatatypeEnum.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/DatatypeList.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/DatatypeOption.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/DatatypeTree.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/FailingAssertion.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/FreeRequireEnsure.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/Functions.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/GeneratedLabels.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/Goto.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/Havoc.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/Loops.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/Map.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/Min.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/OldExpressions.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/PrecedenceCheck.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/ProcedureCall.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/Quantifiers.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/QuantifiersWithTypeAliases.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/RealBitVector.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/RecursiveProcIte.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/Regex.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/RemoveIrrelevantAxioms.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/SimpleProc.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/String.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/TypeAlias.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/TypeDecl.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/TypeVarImplicitlyQuantified.lean (100%) rename StrataTest/Languages/{Boogie => Core}/Examples/UnreachableAssert.lean (100%) rename StrataTest/Languages/{Boogie => Core}/ExprEvalTest.lean (100%) rename StrataTest/Languages/{Boogie => Core}/ProcedureEvalTests.lean (100%) rename StrataTest/Languages/{Boogie => Core}/ProcedureTypeTests.lean (100%) rename StrataTest/Languages/{Boogie => Core}/ProgramTypeTests.lean (100%) rename StrataTest/Languages/{Boogie => Core}/SMTEncoderDatatypeTest.lean (100%) rename StrataTest/Languages/{Boogie => Core}/StatementEvalTests.lean (100%) rename StrataTest/Languages/{Boogie => Core}/StatementTypeTests.lean (100%) diff --git a/StrataTest/Languages/Boogie/DatatypeVerificationTests.lean b/StrataTest/Languages/Core/DatatypeVerificationTests.lean similarity index 100% rename from StrataTest/Languages/Boogie/DatatypeVerificationTests.lean rename to StrataTest/Languages/Core/DatatypeVerificationTests.lean diff --git a/StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean b/StrataTest/Languages/Core/Examples/AdvancedMaps.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/AdvancedMaps.lean rename to StrataTest/Languages/Core/Examples/AdvancedMaps.lean diff --git a/StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean b/StrataTest/Languages/Core/Examples/AdvancedQuantifiers.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/AdvancedQuantifiers.lean rename to StrataTest/Languages/Core/Examples/AdvancedQuantifiers.lean diff --git a/StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean b/StrataTest/Languages/Core/Examples/AssertionDefaultNames.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/AssertionDefaultNames.lean rename to StrataTest/Languages/Core/Examples/AssertionDefaultNames.lean diff --git a/StrataTest/Languages/Boogie/Examples/Axioms.lean b/StrataTest/Languages/Core/Examples/Axioms.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/Axioms.lean rename to StrataTest/Languages/Core/Examples/Axioms.lean diff --git a/StrataTest/Languages/Boogie/Examples/BitVecParse.lean b/StrataTest/Languages/Core/Examples/BitVecParse.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/BitVecParse.lean rename to StrataTest/Languages/Core/Examples/BitVecParse.lean diff --git a/StrataTest/Languages/Boogie/Examples/Cover.lean b/StrataTest/Languages/Core/Examples/Cover.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/Cover.lean rename to StrataTest/Languages/Core/Examples/Cover.lean diff --git a/StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean b/StrataTest/Languages/Core/Examples/DDMAxiomsExtraction.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/DDMAxiomsExtraction.lean rename to StrataTest/Languages/Core/Examples/DDMAxiomsExtraction.lean diff --git a/StrataTest/Languages/Boogie/Examples/DDMTransform.lean b/StrataTest/Languages/Core/Examples/DDMTransform.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/DDMTransform.lean rename to StrataTest/Languages/Core/Examples/DDMTransform.lean diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeEnum.lean b/StrataTest/Languages/Core/Examples/DatatypeEnum.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/DatatypeEnum.lean rename to StrataTest/Languages/Core/Examples/DatatypeEnum.lean diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeList.lean b/StrataTest/Languages/Core/Examples/DatatypeList.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/DatatypeList.lean rename to StrataTest/Languages/Core/Examples/DatatypeList.lean diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeOption.lean b/StrataTest/Languages/Core/Examples/DatatypeOption.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/DatatypeOption.lean rename to StrataTest/Languages/Core/Examples/DatatypeOption.lean diff --git a/StrataTest/Languages/Boogie/Examples/DatatypeTree.lean b/StrataTest/Languages/Core/Examples/DatatypeTree.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/DatatypeTree.lean rename to StrataTest/Languages/Core/Examples/DatatypeTree.lean diff --git a/StrataTest/Languages/Boogie/Examples/FailingAssertion.lean b/StrataTest/Languages/Core/Examples/FailingAssertion.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/FailingAssertion.lean rename to StrataTest/Languages/Core/Examples/FailingAssertion.lean diff --git a/StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean b/StrataTest/Languages/Core/Examples/FreeRequireEnsure.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/FreeRequireEnsure.lean rename to StrataTest/Languages/Core/Examples/FreeRequireEnsure.lean diff --git a/StrataTest/Languages/Boogie/Examples/Functions.lean b/StrataTest/Languages/Core/Examples/Functions.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/Functions.lean rename to StrataTest/Languages/Core/Examples/Functions.lean diff --git a/StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean b/StrataTest/Languages/Core/Examples/GeneratedLabels.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/GeneratedLabels.lean rename to StrataTest/Languages/Core/Examples/GeneratedLabels.lean diff --git a/StrataTest/Languages/Boogie/Examples/Goto.lean b/StrataTest/Languages/Core/Examples/Goto.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/Goto.lean rename to StrataTest/Languages/Core/Examples/Goto.lean diff --git a/StrataTest/Languages/Boogie/Examples/Havoc.lean b/StrataTest/Languages/Core/Examples/Havoc.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/Havoc.lean rename to StrataTest/Languages/Core/Examples/Havoc.lean diff --git a/StrataTest/Languages/Boogie/Examples/Loops.lean b/StrataTest/Languages/Core/Examples/Loops.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/Loops.lean rename to StrataTest/Languages/Core/Examples/Loops.lean diff --git a/StrataTest/Languages/Boogie/Examples/Map.lean b/StrataTest/Languages/Core/Examples/Map.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/Map.lean rename to StrataTest/Languages/Core/Examples/Map.lean diff --git a/StrataTest/Languages/Boogie/Examples/Min.lean b/StrataTest/Languages/Core/Examples/Min.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/Min.lean rename to StrataTest/Languages/Core/Examples/Min.lean diff --git a/StrataTest/Languages/Boogie/Examples/OldExpressions.lean b/StrataTest/Languages/Core/Examples/OldExpressions.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/OldExpressions.lean rename to StrataTest/Languages/Core/Examples/OldExpressions.lean diff --git a/StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean b/StrataTest/Languages/Core/Examples/PrecedenceCheck.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/PrecedenceCheck.lean rename to StrataTest/Languages/Core/Examples/PrecedenceCheck.lean diff --git a/StrataTest/Languages/Boogie/Examples/ProcedureCall.lean b/StrataTest/Languages/Core/Examples/ProcedureCall.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/ProcedureCall.lean rename to StrataTest/Languages/Core/Examples/ProcedureCall.lean diff --git a/StrataTest/Languages/Boogie/Examples/Quantifiers.lean b/StrataTest/Languages/Core/Examples/Quantifiers.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/Quantifiers.lean rename to StrataTest/Languages/Core/Examples/Quantifiers.lean diff --git a/StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean b/StrataTest/Languages/Core/Examples/QuantifiersWithTypeAliases.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/QuantifiersWithTypeAliases.lean rename to StrataTest/Languages/Core/Examples/QuantifiersWithTypeAliases.lean diff --git a/StrataTest/Languages/Boogie/Examples/RealBitVector.lean b/StrataTest/Languages/Core/Examples/RealBitVector.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/RealBitVector.lean rename to StrataTest/Languages/Core/Examples/RealBitVector.lean diff --git a/StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean b/StrataTest/Languages/Core/Examples/RecursiveProcIte.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/RecursiveProcIte.lean rename to StrataTest/Languages/Core/Examples/RecursiveProcIte.lean diff --git a/StrataTest/Languages/Boogie/Examples/Regex.lean b/StrataTest/Languages/Core/Examples/Regex.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/Regex.lean rename to StrataTest/Languages/Core/Examples/Regex.lean diff --git a/StrataTest/Languages/Boogie/Examples/RemoveIrrelevantAxioms.lean b/StrataTest/Languages/Core/Examples/RemoveIrrelevantAxioms.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/RemoveIrrelevantAxioms.lean rename to StrataTest/Languages/Core/Examples/RemoveIrrelevantAxioms.lean diff --git a/StrataTest/Languages/Boogie/Examples/SimpleProc.lean b/StrataTest/Languages/Core/Examples/SimpleProc.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/SimpleProc.lean rename to StrataTest/Languages/Core/Examples/SimpleProc.lean diff --git a/StrataTest/Languages/Boogie/Examples/String.lean b/StrataTest/Languages/Core/Examples/String.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/String.lean rename to StrataTest/Languages/Core/Examples/String.lean diff --git a/StrataTest/Languages/Boogie/Examples/TypeAlias.lean b/StrataTest/Languages/Core/Examples/TypeAlias.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/TypeAlias.lean rename to StrataTest/Languages/Core/Examples/TypeAlias.lean diff --git a/StrataTest/Languages/Boogie/Examples/TypeDecl.lean b/StrataTest/Languages/Core/Examples/TypeDecl.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/TypeDecl.lean rename to StrataTest/Languages/Core/Examples/TypeDecl.lean diff --git a/StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean b/StrataTest/Languages/Core/Examples/TypeVarImplicitlyQuantified.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/TypeVarImplicitlyQuantified.lean rename to StrataTest/Languages/Core/Examples/TypeVarImplicitlyQuantified.lean diff --git a/StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean b/StrataTest/Languages/Core/Examples/UnreachableAssert.lean similarity index 100% rename from StrataTest/Languages/Boogie/Examples/UnreachableAssert.lean rename to StrataTest/Languages/Core/Examples/UnreachableAssert.lean diff --git a/StrataTest/Languages/Boogie/ExprEvalTest.lean b/StrataTest/Languages/Core/ExprEvalTest.lean similarity index 100% rename from StrataTest/Languages/Boogie/ExprEvalTest.lean rename to StrataTest/Languages/Core/ExprEvalTest.lean diff --git a/StrataTest/Languages/Boogie/ProcedureEvalTests.lean b/StrataTest/Languages/Core/ProcedureEvalTests.lean similarity index 100% rename from StrataTest/Languages/Boogie/ProcedureEvalTests.lean rename to StrataTest/Languages/Core/ProcedureEvalTests.lean diff --git a/StrataTest/Languages/Boogie/ProcedureTypeTests.lean b/StrataTest/Languages/Core/ProcedureTypeTests.lean similarity index 100% rename from StrataTest/Languages/Boogie/ProcedureTypeTests.lean rename to StrataTest/Languages/Core/ProcedureTypeTests.lean diff --git a/StrataTest/Languages/Boogie/ProgramTypeTests.lean b/StrataTest/Languages/Core/ProgramTypeTests.lean similarity index 100% rename from StrataTest/Languages/Boogie/ProgramTypeTests.lean rename to StrataTest/Languages/Core/ProgramTypeTests.lean diff --git a/StrataTest/Languages/Boogie/SMTEncoderDatatypeTest.lean b/StrataTest/Languages/Core/SMTEncoderDatatypeTest.lean similarity index 100% rename from StrataTest/Languages/Boogie/SMTEncoderDatatypeTest.lean rename to StrataTest/Languages/Core/SMTEncoderDatatypeTest.lean diff --git a/StrataTest/Languages/Boogie/StatementEvalTests.lean b/StrataTest/Languages/Core/StatementEvalTests.lean similarity index 100% rename from StrataTest/Languages/Boogie/StatementEvalTests.lean rename to StrataTest/Languages/Core/StatementEvalTests.lean diff --git a/StrataTest/Languages/Boogie/StatementTypeTests.lean b/StrataTest/Languages/Core/StatementTypeTests.lean similarity index 100% rename from StrataTest/Languages/Boogie/StatementTypeTests.lean rename to StrataTest/Languages/Core/StatementTypeTests.lean From a218478aa1afc872a51c1df06bf8a66f6240c1e5 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 15:22:37 -0600 Subject: [PATCH 07/19] Rename Core/Boogie{Gen}.lean to Core/Core{Gen}.lean, rename BoogieLParams BoogieIdent BoogieExprMetadata BoogieLabem --- Strata/Backends/CBMC/BoogieToCBMC.lean | 20 +- Strata/Languages/C_Simp/Verify.lean | 4 +- Strata/Languages/Core/Axiom.lean | 8 +- Strata/Languages/Core/CallGraph.lean | 10 +- Strata/Languages/Core/CmdType.lean | 18 +- .../Languages/Core/{Boogie.lean => Core.lean} | 4 +- .../Core/{BoogieGen.lean => CoreGen.lean} | 68 +-- Strata/Languages/Core/DDMTransform/Parse.lean | 2 +- .../Core/DDMTransform/Translate.lean | 74 +-- Strata/Languages/Core/Env.lean | 30 +- Strata/Languages/Core/Expressions.lean | 2 +- Strata/Languages/Core/Factory.lean | 160 +++---- Strata/Languages/Core/Function.lean | 16 +- Strata/Languages/Core/Identifiers.lean | 95 ++-- Strata/Languages/Core/OldExpressions.lean | 20 +- Strata/Languages/Core/Procedure.lean | 28 +- Strata/Languages/Core/ProcedureWF.lean | 10 +- Strata/Languages/Core/Program.lean | 4 +- Strata/Languages/Core/ProgramWF.lean | 18 +- Strata/Languages/Core/SMTEncoder.lean | 22 +- Strata/Languages/Core/StatementSemantics.lean | 2 +- Strata/Languages/Core/StatementType.lean | 6 +- Strata/Languages/Core/StatementWF.lean | 4 +- Strata/Languages/Core/Verifier.lean | 8 +- Strata/Languages/Core/WF.lean | 20 +- .../Laurel/LaurelToBoogieTranslator.lean | 14 +- .../Languages/Python/FunctionSignatures.lean | 2 +- Strata/Languages/Python/PyFactory.lean | 4 +- Strata/Languages/Python/PythonToBoogie.lean | 6 +- Strata/Transform/CallElimCorrect.lean | 446 +++++++++--------- Strata/Transform/CoreTransform.lean | 12 +- Strata/Transform/ProcedureInlining.lean | 4 +- .../Backends/CBMC/BoogieToCProverGOTO.lean | 20 +- .../Internal/InternalFunctionSignatures.lean | 2 +- .../Core/DatatypeVerificationTests.lean | 154 +++--- StrataTest/Languages/Core/Examples/Goto.lean | 2 +- StrataTest/Languages/Core/ExprEvalTest.lean | 22 +- .../Languages/Core/ProgramTypeTests.lean | 2 +- .../Core/SMTEncoderDatatypeTest.lean | 48 +- StrataTest/Transform/CallElim.lean | 2 +- StrataTest/Transform/ProcedureInlining.lean | 2 +- 41 files changed, 698 insertions(+), 697 deletions(-) rename Strata/Languages/Core/{Boogie.lean => Core.lean} (94%) rename Strata/Languages/Core/{BoogieGen.lean => CoreGen.lean} (51%) diff --git a/Strata/Backends/CBMC/BoogieToCBMC.lean b/Strata/Backends/CBMC/BoogieToCBMC.lean index 86ccaa1e7..b77b9b755 100644 --- a/Strata/Backends/CBMC/BoogieToCBMC.lean +++ b/Strata/Backends/CBMC/BoogieToCBMC.lean @@ -9,7 +9,7 @@ import Strata.Languages.Core.Env import Strata.Languages.Core.DDMTransform.Parse import Strata.Languages.Core.DDMTransform.Translate import Strata.DL.Util.Map -import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Core import Strata.Backends.CBMC.Common open Lean @@ -45,7 +45,7 @@ def myProc : Core.Procedure := match SimpleTestEnvAST.fst.decls.head!.getProc? w class IdentToStr (I : Type) where toStr : I → String -instance : IdentToStr BoogieIdent where +instance : IdentToStr CoreIdent where toStr id := id.toPretty instance : IdentToStr String where @@ -54,7 +54,7 @@ instance : IdentToStr String where class HasLExpr (P : Imperative.PureExpr) (I : Lambda.LExprParams) where expr_eq : P.Expr = Lambda.LExpr I.mono -instance : HasLExpr Core.Expression BoogieLParams where +instance : HasLExpr Core.Expression CoreLParams where expr_eq := rfl def exprToJson (I : Lambda.LExprParams) [IdentToStr (Lambda.Identifier I.IDMeta)] (e : Lambda.LExpr I.mono) (loc: SourceLoc) : Json := @@ -102,7 +102,7 @@ def cmdToJson (e : Core.Command) (loc: SourceLoc) : Json := mkCodeBlock "expression" "6" loc.functionName #[ mkSideEffect "assign" "6" loc.functionName mkIntType #[ mkLvalueSymbol s!"{loc.functionName}::1::{name.toPretty}" "6" loc.functionName, - exprToJson (I:=BoogieLParams) expr exprLoc + exprToJson (I:=CoreLParams) expr exprLoc ] ] | .assert label expr _ => @@ -127,7 +127,7 @@ def cmdToJson (e : Core.Command) (loc: SourceLoc) : Json := Json.mkObj [ ("id", "arguments"), ("sub", Json.arr #[ - exprToJson (I:=BoogieLParams) expr exprLoc, + exprToJson (I:=CoreLParams) expr exprLoc, mkStringConstant label "7" loc.functionName ]) ] @@ -155,7 +155,7 @@ def cmdToJson (e : Core.Command) (loc: SourceLoc) : Json := Json.mkObj [ ("id", "arguments"), ("sub", Json.arr #[ - exprToJson (I:=BoogieLParams) expr exprLoc + exprToJson (I:=CoreLParams) expr exprLoc ]) ] ] @@ -207,7 +207,7 @@ def stmtToJson {P : Imperative.PureExpr} (I : Lambda.LExprParams) [IdentToStr (L decreasing_by all_goals(simp; omega) end -def listToExpr (l: ListMap BoogieLabel Core.Procedure.Check) : Core.Expression.Expr := +def listToExpr (l: ListMap CoreLabel Core.Procedure.Check) : Core.Expression.Expr := match l with | _ => .true () @@ -254,7 +254,7 @@ def createContractSymbolFromAST (func : Core.Procedure) : CBMCSymbol := ]), ("sub", Json.arr #[ parameterTuple, - exprToJson (I:=BoogieLParams) (listToExpr func.spec.preconditions) {functionName := func.header.name.toPretty, lineNum := "2"} + exprToJson (I:=CoreLParams) (listToExpr func.spec.preconditions) {functionName := func.header.name.toPretty, lineNum := "2"} ]) ] @@ -266,7 +266,7 @@ def createContractSymbolFromAST (func : Core.Procedure) : CBMCSymbol := ]), ("sub", Json.arr #[ parameterTuple, - exprToJson (I:=BoogieLParams) (listToExpr func.spec.postconditions) {functionName := func.header.name.toPretty, lineNum := "2"} + exprToJson (I:=CoreLParams) (listToExpr func.spec.postconditions) {functionName := func.header.name.toPretty, lineNum := "2"} ]) ] @@ -340,7 +340,7 @@ def createImplementationSymbolFromAST (func : Core.Procedure) : CBMCSymbol := -- For now, keep the hardcoded implementation but use function name from AST let loc : SourceLoc := { functionName := (func.header.name.toPretty), lineNum := "1" } - let stmtJsons := (func.body.map (stmtToJson (I:=BoogieLParams) · loc)) + let stmtJsons := (func.body.map (stmtToJson (I:=CoreLParams) · loc)) let implValue := Json.mkObj [ ("id", "code"), diff --git a/Strata/Languages/C_Simp/Verify.lean b/Strata/Languages/C_Simp/Verify.lean index 3bea85a1c..1fa788d8b 100644 --- a/Strata/Languages/C_Simp/Verify.lean +++ b/Strata/Languages/C_Simp/Verify.lean @@ -16,7 +16,7 @@ namespace Strata -- 2. Running SymExec of Lambda and Imp -def translate_expr (e : C_Simp.Expression.Expr) : Lambda.LExpr Core.BoogieLParams.mono := +def translate_expr (e : C_Simp.Expression.Expr) : Lambda.LExpr Core.CoreLParams.mono := match e with | .const m c => .const m c | .op m o ty => .op m ⟨o.name, .unres⟩ ty @@ -28,7 +28,7 @@ def translate_expr (e : C_Simp.Expression.Expr) : Lambda.LExpr Core.BoogieLParam | .ite m c t e => .ite m (translate_expr c) (translate_expr t) (translate_expr e) | .eq m e1 e2 => .eq m (translate_expr e1) (translate_expr e2) -def translate_opt_expr (e : Option C_Simp.Expression.Expr) : Option (Lambda.LExpr Core.BoogieLParams.mono) := +def translate_opt_expr (e : Option C_Simp.Expression.Expr) : Option (Lambda.LExpr Core.CoreLParams.mono) := match e with | some e => translate_expr e | none => none diff --git a/Strata/Languages/Core/Axiom.lean b/Strata/Languages/Core/Axiom.lean index e1b981f56..ea2da837e 100644 --- a/Strata/Languages/Core/Axiom.lean +++ b/Strata/Languages/Core/Axiom.lean @@ -26,11 +26,11 @@ the responsibility of the user to ensure that they are consistent. -/ structure Axiom where - name : BoogieLabel - e : LExpr BoogieLParams.mono + name : CoreLabel + e : LExpr CoreLParams.mono -instance : ToFormat (BoogieLParams.mono : LExprParamsT).base.Identifier := - show ToFormat BoogieIdent from inferInstance +instance : ToFormat (CoreLParams.mono : LExprParamsT).base.Identifier := + show ToFormat CoreIdent from inferInstance instance : ToFormat Axiom where format a := f!"axiom {a.name}: {a.e};" diff --git a/Strata/Languages/Core/CallGraph.lean b/Strata/Languages/Core/CallGraph.lean index 2c595f7e4..e502fd073 100644 --- a/Strata/Languages/Core/CallGraph.lean +++ b/Strata/Languages/Core/CallGraph.lean @@ -76,7 +76,7 @@ def extractFunctionCallsFromExpr (expr : Expression.Expr) : List String := | .fvar _ _ _ => [] | .bvar _ _ => [] | .op _ fname _ => - let fname := BoogieIdent.toPretty fname + let fname := CoreIdent.toPretty fname if builtinFunctions.contains fname then [] else [fname] | .const _ _ => [] | .app _ fn arg => extractFunctionCallsFromExpr fn ++ extractFunctionCallsFromExpr arg @@ -118,14 +118,14 @@ abbrev FunctionCG := CallGraph def Program.toProcedureCG (prog : Program) : ProcedureCG := let procedures := prog.decls.filterMap (fun decl => match decl with - | .proc p _ => some (BoogieIdent.toPretty p.header.name, extractCallsFromProcedure p) + | .proc p _ => some (CoreIdent.toPretty p.header.name, extractCallsFromProcedure p) | _ => none) buildCallGraph procedures def Program.toFunctionCG (prog : Program) : FunctionCG := let functions := prog.decls.filterMap (fun decl => match decl with - | .func f _ => some (BoogieIdent.toPretty f.name, extractCallsFromFunction f) + | .func f _ => some (CoreIdent.toPretty f.name, extractCallsFromFunction f) | _ => none) buildCallGraph functions @@ -170,7 +170,7 @@ def Program.toFunctionAxiomMap (prog : Program) : Std.HashMap String (List Strin let functionAxiomPairs := axioms.flatMap (fun ax => let ops := Lambda.LExpr.getOps ax.e - ops.map (fun op => (BoogieIdent.toPretty op, ax))) + ops.map (fun op => (CoreIdent.toPretty op, ax))) functionAxiomPairs.foldl (fun acc (funcName, ax) => @@ -192,7 +192,7 @@ def Program.getIrrelevantAxioms (prog : Program) (functions : List String) : Lis | .ax a _ => let ops := Lambda.LExpr.getOps a.e let hasRelevantOp := ops.any (fun op => - functionsSet.binSearch (BoogieIdent.toPretty op) (· < ·) |>.isSome) + functionsSet.binSearch (CoreIdent.toPretty op) (· < ·) |>.isSome) if hasRelevantOp then none else some a.name | _ => none) diff --git a/Strata/Languages/Core/CmdType.lean b/Strata/Languages/Core/CmdType.lean index e8d31d8f3..53fd21de8 100644 --- a/Strata/Languages/Core/CmdType.lean +++ b/Strata/Languages/Core/CmdType.lean @@ -24,13 +24,13 @@ def isBoolType (ty : LTy) : Bool := | .forAll [] LMonoTy.bool => true | _ => false -def lookup (Env : TEnv Visibility) (x : BoogieIdent) : Option LTy := +def lookup (Env : TEnv Visibility) (x : CoreIdent) : Option LTy := Env.context.types.find? x -def update (Env : TEnv Visibility) (x : BoogieIdent) (ty : LTy) : TEnv Visibility := - Env.insertInContext (T := BoogieLParams) x ty +def update (Env : TEnv Visibility) (x : CoreIdent) (ty : LTy) : TEnv Visibility := + Env.insertInContext (T := CoreLParams) x ty -def freeVars (e : (LExpr BoogieLParams.mono)) : List BoogieIdent := +def freeVars (e : (LExpr CoreLParams.mono)) : List CoreIdent := (LExpr.freeVars e).map (fun (i, _) => i) /-- @@ -38,12 +38,12 @@ Preprocess a user-facing type in Boogie amounts to converting a poly-type (i.e., `LTy`) to a mono-type (i.e., `LMonoTy`) via instantiation. We still return an `LTy`, with no bound variables. -/ -def preprocess (C: LContext BoogieLParams) (Env : TEnv Visibility) (ty : LTy) : +def preprocess (C: LContext CoreLParams) (Env : TEnv Visibility) (ty : LTy) : Except Format (LTy × TEnv Visibility) := do let (mty, Env) ← ty.instantiateWithCheck C Env return (.forAll [] mty, Env) -def postprocess (_: LContext BoogieLParams) (Env: TEnv Visibility) (ty : LTy) : +def postprocess (_: LContext CoreLParams) (Env: TEnv Visibility) (ty : LTy) : Except Format (LTy × TEnv Visibility) := do if h: ty.isMonoType then let ty := LMonoTy.subst Env.stateSubstInfo.subst (ty.toMonoType h) @@ -55,8 +55,8 @@ def postprocess (_: LContext BoogieLParams) (Env: TEnv Visibility) (ty : LTy) : The inferred type of `e` will be an `LMonoTy`, but we return an `LTy` with no bound variables. -/ -def inferType (C: LContext BoogieLParams) (Env: TEnv Visibility) (c : Cmd Expression) (e : LExpr BoogieLParams.mono) : - Except Format ((LExpr BoogieLParams.mono) × LTy × TEnv Visibility) := do +def inferType (C: LContext CoreLParams) (Env: TEnv Visibility) (c : Cmd Expression) (e : LExpr CoreLParams.mono) : + Except Format ((LExpr CoreLParams.mono) × LTy × TEnv Visibility) := do -- We only allow free variables to appear in `init` statements. Any other -- occurrence leads to an error. let T ← match c with @@ -103,7 +103,7 @@ def typeErrorFmt (e : Format) : Format := --------------------------------------------------------------------- -instance : Imperative.TypeContext Expression (LContext BoogieLParams) (TEnv Visibility) Format where +instance : Imperative.TypeContext Expression (LContext CoreLParams) (TEnv Visibility) Format where isBoolType := CmdType.isBoolType freeVars := CmdType.freeVars preprocess := CmdType.preprocess diff --git a/Strata/Languages/Core/Boogie.lean b/Strata/Languages/Core/Core.lean similarity index 94% rename from Strata/Languages/Core/Boogie.lean rename to Strata/Languages/Core/Core.lean index d2eea88ef..49e8cdbe4 100644 --- a/Strata/Languages/Core/Boogie.lean +++ b/Strata/Languages/Core/Core.lean @@ -32,7 +32,7 @@ namespace Core -/ def typeCheck (options : Options) (program : Program) - (moreFns : @Lambda.Factory BoogieLParams := Lambda.Factory.default) : + (moreFns : @Lambda.Factory CoreLParams := Lambda.Factory.default) : Except Std.Format Program := do let T := Lambda.TEnv.default let factory ← Core.Factory.addFactory moreFns @@ -46,7 +46,7 @@ def typeCheck (options : Options) (program : Program) return program def typeCheckAndPartialEval (options : Options) (program : Program) - (moreFns : @Lambda.Factory BoogieLParams := Lambda.Factory.default) : + (moreFns : @Lambda.Factory CoreLParams := Lambda.Factory.default) : Except Std.Format (List (Program × Env)) := do let program ← typeCheck options program moreFns -- Extract datatypes from program declarations and add to environment diff --git a/Strata/Languages/Core/BoogieGen.lean b/Strata/Languages/Core/CoreGen.lean similarity index 51% rename from Strata/Languages/Core/BoogieGen.lean rename to Strata/Languages/Core/CoreGen.lean index e547321a0..aafa1b1a4 100644 --- a/Strata/Languages/Core/BoogieGen.lean +++ b/Strata/Languages/Core/CoreGen.lean @@ -11,7 +11,7 @@ import Strata.DL.Util.ListUtils open Core Lambda Imperative /-! ## Strata Core Identifier Generator - This file contains a Boogie Identifier generator `BoogieGenState.gen`, where the + This file contains a Boogie Identifier generator `CoreGenState.gen`, where the uniqueness of the generated identifiers is designed to be provable. It relies on a `StringGenState` to generate unique strings (See `StringGen.lean`). @@ -19,52 +19,52 @@ open Core Lambda Imperative -/ namespace Names -def initVarValue (id : BoogieIdent) : Expression.Expr := - .fvar () (BoogieIdent.unres ("init_" ++ id.name)) none +def initVarValue (id : CoreIdent) : Expression.Expr := + .fvar () (CoreIdent.unres ("init_" ++ id.name)) none end Names namespace Core -structure BoogieGenState where +structure CoreGenState where cs : StringGenState - generated : List BoogieIdent := [] + generated : List CoreIdent := [] -def BoogieGenState.WF (σ : BoogieGenState) +def CoreGenState.WF (σ : CoreGenState) := StringGenState.WF σ.cs ∧ - List.map Core.BoogieIdent.temp σ.cs.generated.unzip.snd = σ.generated ∧ + List.map Core.CoreIdent.temp σ.cs.generated.unzip.snd = σ.generated ∧ σ.generated.Nodup ∧ - Forall (BoogieIdent.isTemp ·) σ.generated + Forall (CoreIdent.isTemp ·) σ.generated -instance : HasSubset BoogieGenState where +instance : HasSubset CoreGenState where Subset σ₁ σ₂ := σ₁.generated.Subset σ₂.generated @[simp] -def BoogieGenState.emp : BoogieGenState := { cs := .emp, generated := [] } +def CoreGenState.emp : CoreGenState := { cs := .emp, generated := [] } -/-- A BoogieIdent generator - NOTE: we need to wrap the prefix into a BoogieIdent in order to conform with the interface of UniqueLabelGen.gen +/-- A CoreIdent generator + NOTE: we need to wrap the prefix into a CoreIdent in order to conform with the interface of UniqueLabelGen.gen TODO: Maybe use genIdent or genIdents? -/ -def BoogieGenState.gen (pf : BoogieIdent) (σ : BoogieGenState) - : BoogieIdent × BoogieGenState := +def CoreGenState.gen (pf : CoreIdent) (σ : CoreGenState) + : CoreIdent × CoreGenState := let (s, cs') := StringGenState.gen pf.name σ.cs - let newState : BoogieGenState := { cs := cs', generated := (.temp s) :: σ.generated } + let newState : CoreGenState := { cs := cs', generated := (.temp s) :: σ.generated } ((.temp s), newState) -theorem genBoogieIdentTemp : - BoogieGenState.gen pf s = (l, s') → BoogieIdent.isTemp l := by +theorem genCoreIdentTemp : + CoreGenState.gen pf s = (l, s') → CoreIdent.isTemp l := by intros Hgen - simp [BoogieGenState.gen] at Hgen + simp [CoreGenState.gen] at Hgen rw [← Hgen.1] constructor -theorem BoogieGenState.WFMono' : - BoogieGenState.WF s → - BoogieGenState.gen pf s = (l, s') → - BoogieGenState.WF s' := by +theorem CoreGenState.WFMono' : + CoreGenState.WF s → + CoreGenState.gen pf s = (l, s') → + CoreGenState.WF s' := by intros Hwf Hgen - unfold BoogieGenState.WF at Hwf + unfold CoreGenState.WF at Hwf simp [gen] at Hgen simp [← Hgen] generalize h1 : (StringGenState.gen pf.name s.cs).fst = st @@ -76,7 +76,7 @@ theorem BoogieGenState.WFMono' : constructor simp_all simp [← Hwf.right.left, ← Hgen.left, ← Hstrgen.right, ← Hstrgen.left] - constructor <;> try simp [BoogieIdent.isTemp] + constructor <;> try simp [CoreIdent.isTemp] simp [← Hwf.right.left] intro x str Hx false_or_by_contra @@ -86,8 +86,8 @@ theorem BoogieGenState.WFMono' : have Hnodup := Hnodup.left x simp_all -theorem BoogieGenState.WFMono : ∀ (γ γ' : BoogieGenState) (pf l : BoogieIdent), - BoogieGenState.gen pf γ = (l, γ') → WF γ → WF γ' ∧ l ∈ γ'.generated ∧ γ ⊆ γ' := by +theorem CoreGenState.WFMono : ∀ (γ γ' : CoreGenState) (pf l : CoreIdent), + CoreGenState.gen pf γ = (l, γ') → WF γ → WF γ' ∧ l ∈ γ'.generated ∧ γ ⊆ γ' := by intros γ γ' pf l Hgen Hwf have Hwf':= WFMono' Hwf Hgen simp [gen] at Hgen @@ -97,17 +97,17 @@ theorem BoogieGenState.WFMono : ∀ (γ γ' : BoogieGenState) (pf l : BoogieIden simp [Subset, ← Hgen.right] apply List.subset_cons_self -/-- BoogieLabelGen guarantees that all labels are .temp -/ -instance : LabelGen.WFLabelGen BoogieIdent BoogieGenState where +/-- CoreLabelGen guarantees that all labels are .temp -/ +instance : LabelGen.WFLabelGen CoreIdent CoreGenState where emp := .emp - gen := BoogieGenState.gen - generated := BoogieGenState.generated - wf := BoogieGenState.WF + gen := CoreGenState.gen + generated := CoreGenState.generated + wf := CoreGenState.WF wf_emp := by - simp [BoogieGenState.WF, StringGenState.WF, Counter.WF] + simp [CoreGenState.WF, StringGenState.WF, Counter.WF] constructor - wf_gen := BoogieGenState.WFMono + wf_gen := CoreGenState.WFMono -abbrev BoogieGenM := StateM BoogieGenState +abbrev BoogieGenM := StateM CoreGenState end Core diff --git a/Strata/Languages/Core/DDMTransform/Parse.lean b/Strata/Languages/Core/DDMTransform/Parse.lean index dd6238af3..24cb43c80 100644 --- a/Strata/Languages/Core/DDMTransform/Parse.lean +++ b/Strata/Languages/Core/DDMTransform/Parse.lean @@ -6,7 +6,7 @@ import Strata.DDM.Integration.Lean import Strata.DDM.Util.Format -import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Core --------------------------------------------------------------------- diff --git a/Strata/Languages/Core/DDMTransform/Translate.lean b/Strata/Languages/Core/DDMTransform/Translate.lean index d6cb86bb7..861516deb 100644 --- a/Strata/Languages/Core/DDMTransform/Translate.lean +++ b/Strata/Languages/Core/DDMTransform/Translate.lean @@ -6,7 +6,7 @@ import Strata.DDM.AST import Strata.Languages.Core.DDMTransform.Parse -import Strata.Languages.Core.BoogieGen +import Strata.Languages.Core.CoreGen import Strata.DDM.Util.DecimalRat @@ -154,7 +154,7 @@ structure GenNum where structure TransBindings where boundTypeVars : Array TyIdentifier := #[] - boundVars : Array (LExpr BoogieLParams.mono) := #[] + boundVars : Array (LExpr CoreLParams.mono) := #[] freeVars : Array Core.Decl := #[] gen : GenNum := (GenNum.mk 0 0 0 0 0) @@ -193,7 +193,7 @@ instance : Inhabited (Core.Decl × TransBindings) where instance : Inhabited (Core.Decls × TransBindings) where default := ([], {}) -instance : Inhabited (List BoogieIdent × TransBindings) where +instance : Inhabited (List CoreIdent × TransBindings) where default := ([], {}) instance : Inhabited (List TyIdentifier × TransBindings) where @@ -337,21 +337,21 @@ def translateTypeDecl (bindings : TransBindings) (op : Operation) : --------------------------------------------------------------------- -def translateLhs (arg : Arg) : TransM BoogieIdent := do +def translateLhs (arg : Arg) : TransM CoreIdent := do let .op op := arg | TransM.error s!"translateLhs expected op {repr arg}" match op.name, op.args with - | q`Core.lhsIdent, #[id] => translateIdent BoogieIdent id + | q`Core.lhsIdent, #[id] => translateIdent CoreIdent id -- (TODO) Implement lhsArray. | _, _ => TransM.error s!"translateLhs: unimplemented for {repr arg}" def translateBindMk (bindings : TransBindings) (arg : Arg) : - TransM (BoogieIdent × List TyIdentifier × LMonoTy) := do + TransM (CoreIdent × List TyIdentifier × LMonoTy) := do let .op op := arg | TransM.error s!"translateBindMk expected op {repr arg}" match op.name, op.args with | q`Core.bind_mk, #[ida, targsa, tpa] => - let id ← translateIdent BoogieIdent ida + let id ← translateIdent CoreIdent ida let args ← translateTypeArgs targsa let tp ← translateLMonoTy bindings tpa return (id, args.toList, tp) @@ -359,12 +359,12 @@ def translateBindMk (bindings : TransBindings) (arg : Arg) : TransM.error s!"translateBindMk unimplemented for {repr arg}" def translateMonoBindMk (bindings : TransBindings) (arg : Arg) : - TransM (BoogieIdent × LMonoTy) := do + TransM (CoreIdent × LMonoTy) := do let .op op := arg | TransM.error s!"translateMonoBindMk expected op {repr arg}" match op.name, op.args with | q`Core.mono_bind_mk, #[ida, tpa] => - let id ← translateIdent BoogieIdent ida + let id ← translateIdent CoreIdent ida let tp ← translateLMonoTy bindings tpa return (id, tp) | _, _ => @@ -721,7 +721,7 @@ partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : | .fn _ q`Core.bvnot, [tpa, xa] => let tp ← translateLMonoTy bindings (dealiasTypeArg p tpa) let x ← translateExpr p bindings xa - let fn : LExpr BoogieLParams.mono ← + let fn : LExpr CoreLParams.mono ← translateFn (.some tp) q`Core.bvnot return (.app () fn x) -- If-then-else expression @@ -786,7 +786,7 @@ partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : let kty ← translateLMonoTy bindings _ktp let vty ← translateLMonoTy bindings _vtp -- TODO: use Boogie.mapSelectOp, but specialized - let fn : LExpr BoogieLParams.mono := (LExpr.op () "select" (.some (LMonoTy.mkArrow (mapTy kty vty) [kty, vty]))) + let fn : LExpr CoreLParams.mono := (LExpr.op () "select" (.some (LMonoTy.mkArrow (mapTy kty vty) [kty, vty]))) let m ← translateExpr p bindings ma let i ← translateExpr p bindings ia return .mkApp () fn [m, i] @@ -794,7 +794,7 @@ partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : let kty ← translateLMonoTy bindings _ktp let vty ← translateLMonoTy bindings _vtp -- TODO: use Boogie.mapUpdateOp, but specialized - let fn : LExpr BoogieLParams.mono := (LExpr.op () "update" (.some (LMonoTy.mkArrow (mapTy kty vty) [kty, vty, mapTy kty vty]))) + let fn : LExpr CoreLParams.mono := (LExpr.op () "update" (.some (LMonoTy.mkArrow (mapTy kty vty) [kty, vty, mapTy kty vty]))) let m ← translateExpr p bindings ma let i ← translateExpr p bindings ia let x ← translateExpr p bindings xa @@ -927,7 +927,7 @@ def translateVarStatement (bindings : TransBindings) (decls : Array Arg) : let (stmts, bindings) ← initVarStmts tpids bindings let newVars ← tpids.mapM (fun (id, ty) => if h: ty.isMonoType then - return ((LExpr.fvar () id (ty.toMonoType h)): LExpr BoogieLParams.mono) + return ((LExpr.fvar () id (ty.toMonoType h)): LExpr CoreLParams.mono) else TransM.error s!"translateVarStatement requires {id} to have a monomorphic type, but it has type {ty}") let bbindings := bindings.boundVars ++ newVars @@ -939,10 +939,10 @@ def translateInitStatement (p : Program) (bindings : TransBindings) (args : Arra TransM.error "translateInitStatement unexpected arg length {repr decls}" else let mty ← translateLMonoTy bindings args[0]! - let lhs ← translateIdent BoogieIdent args[1]! + let lhs ← translateIdent CoreIdent args[1]! let val ← translateExpr p bindings args[2]! let ty := (.forAll [] mty) - let newBinding: LExpr BoogieLParams.mono := LExpr.fvar () lhs mty + let newBinding: LExpr CoreLParams.mono := LExpr.fvar () lhs mty let bbindings := bindings.boundVars ++ [newBinding] return ([.init lhs ty val], { bindings with boundVars := bbindings }) @@ -963,7 +963,7 @@ partial def translateStmt (p : Program) (bindings : TransBindings) (arg : Arg) : let md ← getOpMetaData op return ([.set lhs val md], bindings) | q`Core.havoc_statement, #[ida] => - let id ← translateIdent BoogieIdent ida + let id ← translateIdent CoreIdent ida let md ← getOpMetaData op return ([.havoc id md], bindings) | q`Core.assert, #[la, ca] => @@ -1000,7 +1000,7 @@ partial def translateStmt (p : Program) (bindings : TransBindings) (arg : Arg) : let md ← getOpMetaData op return ([.loop c .none i bodyss md], bindings) | q`Core.call_statement, #[lsa, fa, esa] => - let ls ← translateCommaSep (translateIdent BoogieIdent) lsa + let ls ← translateCommaSep (translateIdent CoreIdent) lsa let f ← translateIdent String fa let es ← translateCommaSep (fun a => translateExpr p bindings a) esa let md ← getOpMetaData op @@ -1049,19 +1049,19 @@ end --------------------------------------------------------------------- def translateInitMkBinding (bindings : TransBindings) (op : Arg) : - TransM (BoogieIdent × LMonoTy) := do + TransM (CoreIdent × LMonoTy) := do -- (FIXME) Account for metadata. let bargs ← checkOpArg op q`Core.mkBinding 2 - let id ← translateIdent BoogieIdent bargs[0]! + let id ← translateIdent CoreIdent bargs[0]! let tp ← translateLMonoTy bindings bargs[1]! return (id, tp) def translateInitMkBindings (bindings : TransBindings) (ops : Array Arg) : - TransM (Array (BoogieIdent × LMonoTy)) := do + TransM (Array (CoreIdent × LMonoTy)) := do ops.mapM (fun op => translateInitMkBinding bindings op) def translateBindings (bindings : TransBindings) (op : Arg) : - TransM (ListMap BoogieIdent LMonoTy) := do + TransM (ListMap CoreIdent LMonoTy) := do let bargs ← checkOpArg op q`Core.mkBindings 1 match bargs[0]! with | .seq _ .comma args => @@ -1070,9 +1070,9 @@ def translateBindings (bindings : TransBindings) (op : Arg) : | _ => TransM.error s!"translateBindings expects a comma separated list: {repr op}" -def translateModifies (arg : Arg) : TransM BoogieIdent := do +def translateModifies (arg : Arg) : TransM CoreIdent := do let args ← checkOpArg arg q`Core.modifies_spec 1 - translateIdent BoogieIdent args[0]! + translateIdent CoreIdent args[0]! def translateOptionFree (arg : Arg) : TransM Procedure.CheckAttr := do let .option _ free := arg @@ -1083,8 +1083,8 @@ def translateOptionFree (arg : Arg) : TransM Procedure.CheckAttr := do return .Free | none => return .Default -def translateRequires (p : Program) (name : BoogieIdent) (count : Nat) (bindings : TransBindings) (arg : Arg) : - TransM (ListMap BoogieLabel Procedure.Check) := do +def translateRequires (p : Program) (name : CoreIdent) (count : Nat) (bindings : TransBindings) (arg : Arg) : + TransM (ListMap CoreLabel Procedure.Check) := do let args ← checkOpArg arg q`Core.requires_spec 3 let l ← translateOptionLabel s!"{name.name}_requires_{count}" args[0]! let free? ← translateOptionFree args[1]! @@ -1092,8 +1092,8 @@ def translateRequires (p : Program) (name : BoogieIdent) (count : Nat) (bindings let md ← getArgMetaData arg return [(l, { expr := e, attr := free?, md := md })] -def translateEnsures (p : Program) (name : BoogieIdent) (count : Nat) (bindings : TransBindings) (arg : Arg) : - TransM (ListMap BoogieLabel Procedure.Check) := do +def translateEnsures (p : Program) (name : CoreIdent) (count : Nat) (bindings : TransBindings) (arg : Arg) : + TransM (ListMap CoreLabel Procedure.Check) := do let args ← checkOpArg arg q`Core.ensures_spec 3 let l ← translateOptionLabel s!"{name.name}_ensures_{count}" args[0]! let free? ← translateOptionFree args[1]! @@ -1101,8 +1101,8 @@ def translateEnsures (p : Program) (name : BoogieIdent) (count : Nat) (bindings let md ← getArgMetaData arg return [(l, { expr := e, attr := free?, md := md })] -def translateSpecElem (p : Program) (name : BoogieIdent) (count : Nat) (bindings : TransBindings) (arg : Arg) : - TransM (List BoogieIdent × ListMap BoogieLabel Procedure.Check × ListMap BoogieLabel Procedure.Check) := do +def translateSpecElem (p : Program) (name : CoreIdent) (count : Nat) (bindings : TransBindings) (arg : Arg) : + TransM (List CoreIdent × ListMap CoreLabel Procedure.Check × ListMap CoreLabel Procedure.Check) := do let .op op := arg | TransM.error s!"translateSpecElem expects an op {repr arg}" match op.name with @@ -1118,8 +1118,8 @@ def translateSpecElem (p : Program) (name : BoogieIdent) (count : Nat) (bindings | _ => TransM.error s!"translateSpecElem unimplemented for {repr arg}" -partial def translateSpec (p : Program) (name : BoogieIdent) (bindings : TransBindings) (arg : Arg) : - TransM (List BoogieIdent × ListMap BoogieLabel Procedure.Check × ListMap BoogieLabel Procedure.Check) := do +partial def translateSpec (p : Program) (name : CoreIdent) (bindings : TransBindings) (arg : Arg) : + TransM (List CoreIdent × ListMap CoreLabel Procedure.Check × ListMap CoreLabel Procedure.Check) := do let sargs ← checkOpArg arg q`Core.spec_mk 1 let .seq _ .none args := sargs[0]! | TransM.error s!"Invalid specs {repr sargs[0]!}" @@ -1136,7 +1136,7 @@ partial def translateSpec (p : Program) (name : BoogieIdent) (bindings : TransBi def translateProcedure (p : Program) (bindings : TransBindings) (op : Operation) : TransM (Core.Decl × TransBindings) := do let _ ← @checkOp (Core.Decl × TransBindings) op q`Core.command_procedure 6 - let pname ← translateIdent BoogieIdent op.args[0]! + let pname ← translateIdent CoreIdent op.args[0]! let typeArgs ← translateTypeArgs op.args[1]! let sig ← translateBindings bindings op.args[2]! let ret ← translateOptionMonoDeclList bindings op.args[3]! @@ -1173,7 +1173,7 @@ def translateProcedure (p : Program) (bindings : TransBindings) (op : Operation) def translateConstant (bindings : TransBindings) (op : Operation) : TransM (Core.Decl × TransBindings) := do let _ ← @checkOp (Core.Decl × TransBindings) op q`Core.command_constdecl 3 - let cname ← translateIdent BoogieIdent op.args[0]! + let cname ← translateIdent CoreIdent op.args[0]! let typeArgs ← translateTypeArgs op.args[1]! let ret ← translateLMonoTy bindings op.args[2]! let md ← getOpMetaData op @@ -1234,7 +1234,7 @@ def translateFunction (status : FnInterp) (p : Program) (bindings : TransBinding match status with | .Definition => @checkOp (Core.Decl × TransBindings) op q`Core.command_fndef 6 | .Declaration => @checkOp (Core.Decl × TransBindings) op q`Core.command_fndecl 4 - let fname ← translateIdent BoogieIdent op.args[0]! + let fname ← translateIdent CoreIdent op.args[0]! let typeArgs ← translateTypeArgs op.args[1]! let sig ← translateBindings bindings op.args[2]! let ret ← translateLMonoTy bindings op.args[3]! @@ -1273,9 +1273,9 @@ with types translated from `TypeExpr` to `LMonoTy`. -/ structure TransConstructorInfo where /-- Constructor name -/ - name : BoogieIdent + name : CoreIdent /-- Fields as (fieldName, fieldType) pairs with translated types -/ - fields : Array (BoogieIdent × LMonoTy) + fields : Array (CoreIdent × LMonoTy) deriving Repr /-- @@ -1376,7 +1376,7 @@ def translateDatatype (p : Program) (bindings : TransBindings) (op : Operation) -- Generate factory from LDatatype and convert to Core.Decl -- (used only for bindings.freeVars, not for allDecls) - let factory ← match ldatatype.genFactory (T := BoogieLParams) with + let factory ← match ldatatype.genFactory (T := CoreLParams) with | .ok f => pure f | .error e => TransM.error s!"Failed to generate datatype factory: {e}" let funcDecls : List Core.Decl := factory.toList.map fun func => diff --git a/Strata/Languages/Core/Env.lean b/Strata/Languages/Core/Env.lean index a91c629be..2ecb1694d 100644 --- a/Strata/Languages/Core/Env.lean +++ b/Strata/Languages/Core/Env.lean @@ -18,11 +18,11 @@ instance : ToFormat ExpressionMetadata := -- ToFormat instance for Expression.Expr instance : ToFormat Expression.Expr := by - show ToFormat (Lambda.LExpr BoogieLParams.mono) + show ToFormat (Lambda.LExpr CoreLParams.mono) infer_instance -- Custom ToFormat instance for our specific Scope type to get the desired formatting -private def formatScope (m : Map BoogieIdent (Option Lambda.LMonoTy × Expression.Expr)) : Std.Format := +private def formatScope (m : Map CoreIdent (Option Lambda.LMonoTy × Expression.Expr)) : Std.Format := match m with | [] => "" | [(k, (ty, v))] => go k ty v @@ -33,7 +33,7 @@ private def formatScope (m : Map BoogieIdent (Option Lambda.LMonoTy × Expressio | some ty => f!"({k} : {ty}) → {v}" | none => f!"{k} → {v}" -instance : ToFormat (Map BoogieIdent (Option Lambda.LMonoTy × Expression.Expr)) where +instance : ToFormat (Map CoreIdent (Option Lambda.LMonoTy × Expression.Expr)) where format := formatScope instance : Inhabited ExpressionMetadata := @@ -42,8 +42,8 @@ instance : Inhabited ExpressionMetadata := instance : Lambda.Traceable Lambda.LExpr.EvalProvenance ExpressionMetadata where combine _ := () -instance : Inhabited (Lambda.LExpr ⟨⟨ExpressionMetadata, BoogieIdent⟩, LMonoTy⟩) := - show Inhabited (Lambda.LExpr ⟨⟨Unit, BoogieIdent⟩, LMonoTy⟩) from inferInstance +instance : Inhabited (Lambda.LExpr ⟨⟨ExpressionMetadata, CoreIdent⟩, LMonoTy⟩) := + show Inhabited (Lambda.LExpr ⟨⟨Unit, CoreIdent⟩, LMonoTy⟩) from inferInstance --------------------------------------------------------------------- @@ -184,7 +184,7 @@ def oldVarSubst (subst : SubstMap) (E : Env) : SubstMap := def Env.exprEval (E : Env) (e : Expression.Expr) : Expression.Expr := e.eval E.exprEnv.config.fuel E.exprEnv -def Env.pushScope (E : Env) (scope : (Lambda.Scope BoogieLParams)) : Env := +def Env.pushScope (E : Env) (scope : (Lambda.Scope CoreLParams)) : Env := { E with exprEnv.state := E.exprEnv.state.push scope } def Env.pushEmptyScope (E : Env) : Env := @@ -193,14 +193,14 @@ def Env.pushEmptyScope (E : Env) : Env := def Env.popScope (E : Env) : Env := { E with exprEnv.state := E.exprEnv.state.pop } -def Env.factory (E : Env) : (@Lambda.Factory BoogieLParams) := +def Env.factory (E : Env) : (@Lambda.Factory CoreLParams) := E.exprEnv.config.factory -def Env.addFactory (E : Env) (f : (@Lambda.Factory BoogieLParams)) : Except Format Env := do +def Env.addFactory (E : Env) (f : (@Lambda.Factory CoreLParams)) : Except Format Env := do let exprEnv ← E.exprEnv.addFactory f .ok { E with exprEnv := exprEnv } -def Env.addFactoryFunc (E : Env) (func : (Lambda.LFunc BoogieLParams)) : Except Format Env := do +def Env.addFactoryFunc (E : Env) (func : (Lambda.LFunc CoreLParams)) : Except Format Env := do let exprEnv ← E.exprEnv.addFactoryFunc func .ok { E with exprEnv := exprEnv } @@ -216,16 +216,16 @@ def Env.addToContext List.foldl (fun E (x, v) => E.insertInContext x v) E xs -- TODO: prove uniqueness, add different prefix -def Env.genSym (x : String) (c : Lambda.EvalConfig BoogieLParams) : BoogieIdent × Lambda.EvalConfig BoogieLParams := +def Env.genSym (x : String) (c : Lambda.EvalConfig CoreLParams) : CoreIdent × Lambda.EvalConfig CoreLParams := let new_idx := c.gen let c := c.incGen let new_var := c.varPrefix ++ x ++ toString new_idx (.temp new_var, c) -def Env.genVar' (x : String) (σ : (Lambda.LState BoogieLParams)) : - (BoogieIdent × (Lambda.LState BoogieLParams)) := +def Env.genVar' (x : String) (σ : (Lambda.LState CoreLParams)) : + (CoreIdent × (Lambda.LState CoreLParams)) := let (new_var, config) := Env.genSym x σ.config - let σ : Lambda.LState BoogieLParams := { σ with config := config } + let σ : Lambda.LState CoreLParams := { σ with config := config } -- let known_vars := Lambda.LState.knownVars σ -- if new_var ∈ known_vars then -- panic s!"[LState.genVar] Generated variable {Std.format new_var} is not fresh!\n\ @@ -239,7 +239,7 @@ def Env.genVar (x : Expression.Ident) (E : Env) : Expression.Ident × Env := let (var, σ) := Env.genVar' name E.exprEnv (var, { E with exprEnv := σ }) -def Env.genVars (xs : List String) (σ : Lambda.LState BoogieLParams) : (List BoogieIdent × Lambda.LState BoogieLParams) := +def Env.genVars (xs : List String) (σ : Lambda.LState CoreLParams) : (List CoreIdent × Lambda.LState CoreLParams) := match xs with | [] => ([], σ) | x :: rest => @@ -319,7 +319,7 @@ def Env.merge (cond : Expression.Expr) (E1 E2 : Env) : Env := Env.performMerge cond E1 E2 (by simp_all) (by simp_all) def Env.addDatatypes (E: Env) (datatypes: List (Lambda.LDatatype Visibility)) : Except Format Env := do - let f ← Lambda.TypeFactory.genFactory (T:=BoogieLParams) (datatypes.toArray) + let f ← Lambda.TypeFactory.genFactory (T:=CoreLParams) (datatypes.toArray) let env ← E.addFactory f return { env with datatypes := datatypes.toArray } diff --git a/Strata/Languages/Core/Expressions.lean b/Strata/Languages/Core/Expressions.lean index 00844a955..60d37b6f7 100644 --- a/Strata/Languages/Core/Expressions.lean +++ b/Strata/Languages/Core/Expressions.lean @@ -18,7 +18,7 @@ open Std (ToFormat Format format) def ExpressionMetadata := Unit abbrev Expression : Imperative.PureExpr := - { Ident := BoogieIdent, + { Ident := CoreIdent, EqIdent := inferInstanceAs (DecidableEq (Lambda.Identifier _)) Expr := Lambda.LExpr ⟨⟨ExpressionMetadata, Visibility⟩, Lambda.LMonoTy⟩, Ty := Lambda.LTy, diff --git a/Strata/Languages/Core/Factory.lean b/Strata/Languages/Core/Factory.lean index b0e21aa5d..939b32287 100644 --- a/Strata/Languages/Core/Factory.lean +++ b/Strata/Languages/Core/Factory.lean @@ -41,24 +41,24 @@ def TImplicit {Metadata: Type} (IDMeta: Type): LExprParamsT := ({Metadata := Met Convert an LExpr LMonoTy Unit to an LExpr LMonoTy Visibility TODO: Remove when Lambda elaborator offers parametric identifier type -/ -def ToBoogieIdent {M: Type} (ine: LExpr (@TImplicit M Unit)): LExpr (@TImplicit M Visibility) := +def ToCoreIdent {M: Type} (ine: LExpr (@TImplicit M Unit)): LExpr (@TImplicit M Visibility) := match ine with | .const m c => .const m c - | .op m o oty => .op m (BoogieIdent.unres o.name) oty + | .op m o oty => .op m (CoreIdent.unres o.name) oty | .bvar m deBruijnIndex => .bvar m deBruijnIndex - | .fvar m name oty => .fvar m (BoogieIdent.unres name.name) oty - | .abs m oty e => .abs m oty (ToBoogieIdent e) - | .quant m k oty tr e => .quant m k oty (ToBoogieIdent tr) (ToBoogieIdent e) - | .app m fn e => .app m (ToBoogieIdent fn) (ToBoogieIdent e) - | .ite m c t e => .ite m (ToBoogieIdent c) (ToBoogieIdent t) (ToBoogieIdent e) - | .eq m e1 e2 => .eq m (ToBoogieIdent e1) (ToBoogieIdent e2) + | .fvar m name oty => .fvar m (CoreIdent.unres name.name) oty + | .abs m oty e => .abs m oty (ToCoreIdent e) + | .quant m k oty tr e => .quant m k oty (ToCoreIdent tr) (ToCoreIdent e) + | .app m fn e => .app m (ToCoreIdent fn) (ToCoreIdent e) + | .ite m c t e => .ite m (ToCoreIdent c) (ToCoreIdent t) (ToCoreIdent e) + | .eq m e1 e2 => .eq m (ToCoreIdent e1) (ToCoreIdent e2) private def bvBinaryOp (fn:∀ {n}, BitVec n → BitVec n → BitVec n) (check:∀ {n}, BitVec n → BitVec n → Bool) - (m:BoogieLParams.Metadata) - (ops:List (LExpr BoogieLParams.mono)) - : Option (LExpr BoogieLParams.mono) := + (m:CoreLParams.Metadata) + (ops:List (LExpr CoreLParams.mono)) + : Option (LExpr CoreLParams.mono) := match ops with | [.bitvecConst _ n1 b1, .bitvecConst _ n2 b2] => if h : n1 = n2 then @@ -69,9 +69,9 @@ private def bvBinaryOp (fn:∀ {n}, BitVec n → BitVec n → BitVec n) | _ => .none private def bvShiftOp (fn:∀ {n}, BitVec n → Nat → BitVec n) - (m:BoogieLParams.Metadata) - (ops:List (LExpr BoogieLParams.mono)) - : Option (LExpr BoogieLParams.mono) := + (m:CoreLParams.Metadata) + (ops:List (LExpr CoreLParams.mono)) + : Option (LExpr CoreLParams.mono) := match ops with | [.bitvecConst _ n1 b1, .bitvecConst _ n2 b2] => let i2 := BitVec.toNat b2 @@ -81,18 +81,18 @@ private def bvShiftOp (fn:∀ {n}, BitVec n → Nat → BitVec n) | _ => .none private def bvUnaryOp (fn:∀ {n}, BitVec n → BitVec n) - (m:BoogieLParams.Metadata) - (ops:List (LExpr BoogieLParams.mono)) - : Option (LExpr BoogieLParams.mono) := + (m:CoreLParams.Metadata) + (ops:List (LExpr CoreLParams.mono)) + : Option (LExpr CoreLParams.mono) := match ops with | [.bitvecConst _ n b] => .some (.bitvecConst m n (fn b)) | _ => .none private def bvBinaryPred (fn:∀ {n}, BitVec n → BitVec n → Bool) (swap:Bool) - (m:BoogieLParams.Metadata) - (ops:List (LExpr BoogieLParams.mono)) - : Option (LExpr BoogieLParams.mono) := + (m:CoreLParams.Metadata) + (ops:List (LExpr CoreLParams.mono)) + : Option (LExpr CoreLParams.mono) := match ops with | [.bitvecConst _ n1 b1, .bitvecConst _ n2 b2] => if h : n1 = n2 then @@ -149,7 +149,7 @@ info: [("Neg", "unaryOp"), ("Add", "binaryOp"), ("Sub", "binaryOp"), ("Mul", "bi #guard_msgs in #eval List.zip BVOpNames BVOpAritys -variable [Coe String BoogieLParams.Identifier] +variable [Coe String CoreLParams.Identifier] open Lean Elab Command in elab "ExpandBVOpFuncDefs" "[" sizes:num,* "]" : command => do @@ -161,7 +161,7 @@ elab "ExpandBVOpFuncDefs" "[" sizes:num,* "]" : command => do let opName := Syntax.mkStrLit s!"Bv{s}.{op}" let bvTypeName := Name.mkSimple s!"bv{s}" let opStr := Syntax.mkStrLit op - elabCommand (← `(def $funcName : LFunc BoogieLParams := + elabCommand (← `(def $funcName : LFunc CoreLParams := $funcArity $opName mty[$(mkIdent bvTypeName):ident] ((BVOpEvals.find? (fun (k,_) => k == $opStr)).bind (fun (_,w)=>w)))) @@ -169,136 +169,136 @@ ExpandBVOpFuncDefs[1, 2, 8, 16, 32, 64] /- Real Arithmetic Operations -/ -def realAddFunc : LFunc BoogieLParams := binaryOp "Real.Add" mty[real] none -def realSubFunc : LFunc BoogieLParams := binaryOp "Real.Sub" mty[real] none -def realMulFunc : LFunc BoogieLParams := binaryOp "Real.Mul" mty[real] none -def realDivFunc : LFunc BoogieLParams := binaryOp "Real.Div" mty[real] none -def realNegFunc : LFunc BoogieLParams := unaryOp "Real.Neg" mty[real] none +def realAddFunc : LFunc CoreLParams := binaryOp "Real.Add" mty[real] none +def realSubFunc : LFunc CoreLParams := binaryOp "Real.Sub" mty[real] none +def realMulFunc : LFunc CoreLParams := binaryOp "Real.Mul" mty[real] none +def realDivFunc : LFunc CoreLParams := binaryOp "Real.Div" mty[real] none +def realNegFunc : LFunc CoreLParams := unaryOp "Real.Neg" mty[real] none /- Real Comparison Operations -/ -def realLtFunc : LFunc BoogieLParams := binaryPredicate "Real.Lt" mty[real] none -def realLeFunc : LFunc BoogieLParams := binaryPredicate "Real.Le" mty[real] none -def realGtFunc : LFunc BoogieLParams := binaryPredicate "Real.Gt" mty[real] none -def realGeFunc : LFunc BoogieLParams := binaryPredicate "Real.Ge" mty[real] none +def realLtFunc : LFunc CoreLParams := binaryPredicate "Real.Lt" mty[real] none +def realLeFunc : LFunc CoreLParams := binaryPredicate "Real.Le" mty[real] none +def realGtFunc : LFunc CoreLParams := binaryPredicate "Real.Gt" mty[real] none +def realGeFunc : LFunc CoreLParams := binaryPredicate "Real.Ge" mty[real] none /- String Operations -/ -def strLengthFunc : LFunc BoogieLParams := +def strLengthFunc : LFunc CoreLParams := { name := "Str.Length", typeArgs := [], inputs := [("x", mty[string])] output := mty[int], - concreteEval := some (unOpCeval (T:=BoogieLParams) String Int (.intConst (T:=BoogieLParams.mono)) (@LExpr.denoteString BoogieLParams) + concreteEval := some (unOpCeval (T:=CoreLParams) String Int (.intConst (T:=CoreLParams.mono)) (@LExpr.denoteString CoreLParams) (fun s => (Int.ofNat (String.length s))))} -def strConcatFunc : LFunc BoogieLParams := +def strConcatFunc : LFunc CoreLParams := { name := "Str.Concat", typeArgs := [], inputs := [("x", mty[string]), ("y", mty[string])] output := mty[string], - concreteEval := some (binOpCeval String String (.strConst (T := BoogieLParams.mono)) + concreteEval := some (binOpCeval String String (.strConst (T := CoreLParams.mono)) LExpr.denoteString String.append)} -def strSubstrFunc : LFunc BoogieLParams := +def strSubstrFunc : LFunc CoreLParams := { name := "Str.Substr", typeArgs := [], -- longest substring of `x` of length at most `n` starting at position `i`. inputs := [("x", mty[string]), ("i", mty[int]), ("n", mty[int])] output := mty[string] } -def strToRegexFunc : LFunc BoogieLParams := +def strToRegexFunc : LFunc CoreLParams := { name := "Str.ToRegEx", typeArgs := [], inputs := [("x", mty[string])] output := mty[regex] } -def strInRegexFunc : LFunc BoogieLParams := +def strInRegexFunc : LFunc CoreLParams := { name := "Str.InRegEx", typeArgs := [], inputs := [("x", mty[string]), ("y", mty[regex])] output := mty[bool] } -def reAllCharFunc : LFunc BoogieLParams := +def reAllCharFunc : LFunc CoreLParams := { name := "Re.AllChar", typeArgs := [], inputs := [] output := mty[regex] } -def reAllFunc : LFunc BoogieLParams := +def reAllFunc : LFunc CoreLParams := { name := "Re.All", typeArgs := [], inputs := [] output := mty[regex] } -def reRangeFunc : LFunc BoogieLParams := +def reRangeFunc : LFunc CoreLParams := { name := "Re.Range", typeArgs := [], inputs := [("x", mty[string]), ("y", mty[string])] output := mty[regex] } -def reConcatFunc : LFunc BoogieLParams := +def reConcatFunc : LFunc CoreLParams := { name := "Re.Concat", typeArgs := [], inputs := [("x", mty[regex]), ("y", mty[regex])] output := mty[regex] } -def reStarFunc : LFunc BoogieLParams := +def reStarFunc : LFunc CoreLParams := { name := "Re.Star", typeArgs := [], inputs := [("x", mty[regex])] output := mty[regex] } -def rePlusFunc : LFunc BoogieLParams := +def rePlusFunc : LFunc CoreLParams := { name := "Re.Plus", typeArgs := [], inputs := [("x", mty[regex])] output := mty[regex] } -def reLoopFunc : LFunc BoogieLParams := +def reLoopFunc : LFunc CoreLParams := { name := "Re.Loop", typeArgs := [], inputs := [("x", mty[regex]), ("n1", mty[int]), ("n2", mty[int])] output := mty[regex] } -def reUnionFunc : LFunc BoogieLParams := +def reUnionFunc : LFunc CoreLParams := { name := "Re.Union", typeArgs := [], inputs := [("x", mty[regex]), ("y", mty[regex])] output := mty[regex] } -def reInterFunc : LFunc BoogieLParams := +def reInterFunc : LFunc CoreLParams := { name := "Re.Inter", typeArgs := [], inputs := [("x", mty[regex]), ("y", mty[regex])] output := mty[regex] } -def reCompFunc : LFunc BoogieLParams := +def reCompFunc : LFunc CoreLParams := { name := "Re.Comp", typeArgs := [], inputs := [("x", mty[regex])] output := mty[regex] } -def reNoneFunc : LFunc BoogieLParams := +def reNoneFunc : LFunc CoreLParams := { name := "Re.None", typeArgs := [], inputs := [] output := mty[regex] } /- A polymorphic `old` function with type `∀a. a → a`. -/ -def polyOldFunc : LFunc BoogieLParams := +def polyOldFunc : LFunc CoreLParams := { name := "old", typeArgs := ["a"], - inputs := [((BoogieIdent.locl "x"), mty[%a])] + inputs := [((CoreIdent.locl "x"), mty[%a])] output := mty[%a]} /- A `Map` selection function with type `∀k, v. Map k v → k → v`. -/ -def mapSelectFunc : LFunc BoogieLParams := +def mapSelectFunc : LFunc CoreLParams := { name := "select", typeArgs := ["k", "v"], inputs := [("m", mapTy mty[%k] mty[%v]), ("i", mty[%k])], output := mty[%v] } /- A `Map` update function with type `∀k, v. Map k v → k → v → Map k v`. -/ -def mapUpdateFunc : LFunc BoogieLParams := +def mapUpdateFunc : LFunc CoreLParams := { name := "update", typeArgs := ["k", "v"], inputs := [("m", mapTy mty[%k] mty[%v]), ("i", mty[%k]), ("x", mty[%v])], @@ -306,7 +306,7 @@ def mapUpdateFunc : LFunc BoogieLParams := axioms := [ -- updateSelect: forall m: Map k v, kk: k, vv: v :: m[kk := vv][kk] == vv - ToBoogieIdent esM[∀(Map %k %v): + ToCoreIdent esM[∀(Map %k %v): (∀ (%k): (∀ (%v):{ (((~select : (Map %k %v) → %k → %v) @@ -314,7 +314,7 @@ def mapUpdateFunc : LFunc BoogieLParams := (((~select : (Map %k %v) → %k → %v) ((((~update : (Map %k %v) → %k → %v → (Map %k %v)) %2) %1) %0)) %1) == %0))], -- updatePreserve: forall m: Map k v, okk: k, kk: k, vv: v :: okk != kk ==> m[kk := vv][okk] == m[okk] - ToBoogieIdent esM[∀ (Map %k %v): -- %3 m + ToCoreIdent esM[∀ (Map %k %v): -- %3 m (∀ (%k): -- %2 okk (∀ (%k): -- %1 kk (∀ (%v): -- %0 vv @@ -332,31 +332,31 @@ def mapUpdateFunc : LFunc BoogieLParams := ))))] ] } -instance : Coe String BoogieLParams.Identifier where +instance : Coe String CoreLParams.Identifier where coe | s => ⟨s, .unres⟩ -def emptyTriggersFunc : LFunc BoogieLParams := +def emptyTriggersFunc : LFunc CoreLParams := { name := "Triggers.empty", typeArgs := [], inputs := [], output := mty[Triggers], concreteEval := none } -def addTriggerGroupFunc : LFunc BoogieLParams := +def addTriggerGroupFunc : LFunc CoreLParams := { name := "Triggers.addGroup", typeArgs := [], inputs := [("g", mty[TriggerGroup]), ("t", mty[Triggers])], output := mty[Triggers], concreteEval := none } -def emptyTriggerGroupFunc : LFunc BoogieLParams := +def emptyTriggerGroupFunc : LFunc CoreLParams := { name := "TriggerGroup.empty", typeArgs := [], inputs := [], output := mty[TriggerGroup], concreteEval := none } -def addTriggerFunc : LFunc BoogieLParams := +def addTriggerFunc : LFunc CoreLParams := { name := "TriggerGroup.addTrigger", typeArgs := ["a"], inputs := [("x", mty[%a]), ("t", mty[TriggerGroup])], @@ -372,14 +372,14 @@ macro "ExpandBVOpFuncNames" "[" sizes:num,* "]" : term => do allOps := allOps ++ ops.toArray `([$(allOps),*]) -def bvConcatFunc (size : Nat) : LFunc BoogieLParams := +def bvConcatFunc (size : Nat) : LFunc CoreLParams := { name := s!"Bv{size}.Concat", typeArgs := [], inputs := [("x", .bitvec size), ("y", .bitvec size)] output := .bitvec (size*2), concreteEval := none } -def bvExtractFunc (size hi lo: Nat) : LFunc BoogieLParams := +def bvExtractFunc (size hi lo: Nat) : LFunc CoreLParams := { name := s!"Bv{size}.Extract_{hi}_{lo}", typeArgs := [], inputs := [("x", .bitvec size)] @@ -400,7 +400,7 @@ def bv64Extract_31_0_Func := bvExtractFunc 64 31 0 def bv64Extract_15_0_Func := bvExtractFunc 64 15 0 def bv64Extract_7_0_Func := bvExtractFunc 64 7 0 -def Factory : @Factory BoogieLParams := #[ +def Factory : @Factory CoreLParams := #[ intAddFunc, intSubFunc, intMulFunc, @@ -408,10 +408,10 @@ def Factory : @Factory BoogieLParams := #[ intModFunc, intNegFunc, - @intLtFunc BoogieLParams _, - @intLeFunc BoogieLParams _, - @intGtFunc BoogieLParams _, - @intGeFunc BoogieLParams _, + @intLtFunc CoreLParams _, + @intLeFunc CoreLParams _, + @intGtFunc CoreLParams _, + @intGeFunc CoreLParams _, realAddFunc, realSubFunc, @@ -423,11 +423,11 @@ def Factory : @Factory BoogieLParams := #[ realGtFunc, realGeFunc, - @boolAndFunc BoogieLParams _, - @boolOrFunc BoogieLParams _, - @boolImpliesFunc BoogieLParams _, - @boolEquivFunc BoogieLParams _, - @boolNotFunc BoogieLParams _, + @boolAndFunc CoreLParams _, + @boolOrFunc CoreLParams _, + @boolImpliesFunc CoreLParams _, + @boolEquivFunc CoreLParams _, + @boolNotFunc CoreLParams _, strLengthFunc, strConcatFunc, @@ -479,7 +479,7 @@ elab "DefBVOpFuncExprs" "[" sizes:num,* "]" : command => do let funcName := mkIdent (.str (.str .anonymous "Core") s!"bv{s}{op}Func") elabCommand (← `(def $opName : Expression.Expr := ($funcName).opExpr)) -instance : Inhabited BoogieLParams.Metadata where +instance : Inhabited CoreLParams.Metadata where default := () DefBVOpFuncExprs [1, 8, 16, 32, 64] @@ -503,7 +503,7 @@ def addTriggerGroupOp : Expression.Expr := addTriggerGroupFunc.opExpr def emptyTriggerGroupOp : Expression.Expr := emptyTriggerGroupFunc.opExpr def addTriggerOp : Expression.Expr := addTriggerFunc.opExpr -instance : Inhabited (⟨ExpressionMetadata, BoogieIdent⟩: LExprParams).Metadata where +instance : Inhabited (⟨ExpressionMetadata, CoreIdent⟩: LExprParams).Metadata where default := () def intAddOp : Expression.Expr := intAddFunc.opExpr @@ -525,11 +525,11 @@ def realLtOp : Expression.Expr := realLtFunc.opExpr def realLeOp : Expression.Expr := realLeFunc.opExpr def realGtOp : Expression.Expr := realGtFunc.opExpr def realGeOp : Expression.Expr := realGeFunc.opExpr -def boolAndOp : Expression.Expr := @boolAndFunc.opExpr BoogieLParams _ -def boolOrOp : Expression.Expr := @boolOrFunc.opExpr BoogieLParams _ -def boolImpliesOp : Expression.Expr := @boolImpliesFunc.opExpr BoogieLParams _ -def boolEquivOp : Expression.Expr := @boolEquivFunc.opExpr BoogieLParams _ -def boolNotOp : Expression.Expr := @boolNotFunc.opExpr BoogieLParams _ +def boolAndOp : Expression.Expr := @boolAndFunc.opExpr CoreLParams _ +def boolOrOp : Expression.Expr := @boolOrFunc.opExpr CoreLParams _ +def boolImpliesOp : Expression.Expr := @boolImpliesFunc.opExpr CoreLParams _ +def boolEquivOp : Expression.Expr := @boolEquivFunc.opExpr CoreLParams _ +def boolNotOp : Expression.Expr := @boolNotFunc.opExpr CoreLParams _ def strLengthOp : Expression.Expr := strLengthFunc.opExpr def strConcatOp : Expression.Expr := strConcatFunc.opExpr def strSubstrOp : Expression.Expr := strSubstrFunc.opExpr @@ -561,6 +561,6 @@ def mkTriggerExpr (ts : List (List Expression.Expr)) : Expression.Expr := Get all the built-in functions supported by Boogie. -/ def builtinFunctions : Array String := - Factory.map (fun f => BoogieIdent.toPretty f.name) + Factory.map (fun f => CoreIdent.toPretty f.name) end Core diff --git a/Strata/Languages/Core/Function.lean b/Strata/Languages/Core/Function.lean index ce149121b..4823c029f 100644 --- a/Strata/Languages/Core/Function.lean +++ b/Strata/Languages/Core/Function.lean @@ -17,24 +17,24 @@ open Lambda /-! # Boogie Functions -/ -abbrev Function := Lambda.LFunc BoogieLParams +abbrev Function := Lambda.LFunc CoreLParams --- Type class instances to enable type class resolution for BoogieLParams.Identifier -instance : DecidableEq BoogieLParams.IDMeta := +-- Type class instances to enable type class resolution for CoreLParams.Identifier +instance : DecidableEq CoreLParams.IDMeta := show DecidableEq Visibility from inferInstance -instance : ToFormat BoogieLParams.IDMeta := +instance : ToFormat CoreLParams.IDMeta := show ToFormat Visibility from inferInstance open LTy.Syntax LExpr.SyntaxMono in /-- info: ok: ∀[a, b]. (arrow int (arrow a (arrow b (arrow a a)))) -/ #guard_msgs in -#eval do let type ← LFunc.type (T:=BoogieLParams) - ({ name := BoogieIdent.unres "Foo", +#eval do let type ← LFunc.type (T:=CoreLParams) + ({ name := CoreIdent.unres "Foo", typeArgs := ["a", "b"], - inputs := [(BoogieIdent.locl "w", mty[int]), (BoogieIdent.locl "x", mty[%a]), (BoogieIdent.locl "y", mty[%b]), (BoogieIdent.locl "z", mty[%a])], + inputs := [(CoreIdent.locl "w", mty[int]), (CoreIdent.locl "x", mty[%a]), (CoreIdent.locl "y", mty[%b]), (CoreIdent.locl "z", mty[%a])], output := mty[%a], - body := some (LExpr.fvar () (BoogieIdent.locl "x") none) } : Function) + body := some (LExpr.fvar () (CoreIdent.locl "x") none) } : Function) return format type --------------------------------------------------------------------- diff --git a/Strata/Languages/Core/Identifiers.lean b/Strata/Languages/Core/Identifiers.lean index aaefbbcf3..88d1d82b6 100644 --- a/Strata/Languages/Core/Identifiers.lean +++ b/Strata/Languages/Core/Identifiers.lean @@ -13,7 +13,8 @@ namespace Core open Std /-- - The purpose of `Visiblity` is to denote the visibility/scope of a Boogie identifier. + The purpose of `Visiblity` is to denote the visibility/scope of a Strata Core + identifier. For example, global variables should have a `.glob` (i.e., global) visibility, and variables declared within a procedure should have a `.locl` (i.e., local) @@ -34,7 +35,7 @@ open Std is the responsibility of the variable generator to ensure that the generated names themselves are unique (i.e., do not have duplicates). - See `BoogieGenState` for a unique generator for Boogie Identifiers. + See `CoreGenState` for a unique generator for Strata Core Identifiers. -/ inductive Visibility where | unres @@ -50,59 +51,59 @@ instance : ToFormat Visibility where | .locl => "l:" | .temp => "t:" -abbrev BoogieIdent := Lambda.Identifier Visibility +abbrev CoreIdent := Lambda.Identifier Visibility instance : ToString Visibility where toString v := toString $ ToFormat.format v -abbrev BoogieExprMetadata := Unit -abbrev BoogieLParams: Lambda.LExprParams := {Metadata := BoogieExprMetadata, IDMeta := Visibility} -abbrev BoogieLabel := String +abbrev CoreExprMetadata := Unit +abbrev CoreLParams: Lambda.LExprParams := {Metadata := CoreExprMetadata, IDMeta := Visibility} +abbrev CoreLabel := String -def BoogieIdentDec : DecidableEq BoogieIdent := inferInstanceAs (DecidableEq (Lambda.Identifier Visibility)) +def CoreIdentDec : DecidableEq CoreIdent := inferInstanceAs (DecidableEq (Lambda.Identifier Visibility)) @[match_pattern] -def BoogieIdent.unres (s : String) : BoogieIdent := ⟨s, Visibility.unres⟩ +def CoreIdent.unres (s : String) : CoreIdent := ⟨s, Visibility.unres⟩ @[match_pattern] -def BoogieIdent.glob (s : String) : BoogieIdent := ⟨s, Visibility.glob⟩ +def CoreIdent.glob (s : String) : CoreIdent := ⟨s, Visibility.glob⟩ @[match_pattern] -def BoogieIdent.locl (s : String) : BoogieIdent := ⟨s, Visibility.locl⟩ +def CoreIdent.locl (s : String) : CoreIdent := ⟨s, Visibility.locl⟩ @[match_pattern] -def BoogieIdent.temp (s : String) : BoogieIdent := ⟨s, Visibility.temp⟩ +def CoreIdent.temp (s : String) : CoreIdent := ⟨s, Visibility.temp⟩ -def BoogieIdent.isUnres (id : BoogieIdent) : Bool := match id with +def CoreIdent.isUnres (id : CoreIdent) : Bool := match id with | .unres _ => true | _ => false -def BoogieIdent.isGlob (id : BoogieIdent) : Bool := match id with +def CoreIdent.isGlob (id : CoreIdent) : Bool := match id with | .glob _ => true | _ => false -def BoogieIdent.isLocl (id : BoogieIdent) : Bool := match id with +def CoreIdent.isLocl (id : CoreIdent) : Bool := match id with | .locl _ => true | _ => false -def BoogieIdent.isTemp (id : BoogieIdent) : Bool := match id with +def CoreIdent.isTemp (id : CoreIdent) : Bool := match id with | .temp _ => true | _ => false -def BoogieIdent.isGlobOrLocl (id : BoogieIdent) : Bool := - BoogieIdent.isGlob id ∨ BoogieIdent.isLocl id +def CoreIdent.isGlobOrLocl (id : CoreIdent) : Bool := + CoreIdent.isGlob id ∨ CoreIdent.isLocl id -instance : Coe String BoogieIdent where +instance : Coe String CoreIdent where coe | s => .unres s --- instance : DecidableEq BoogieIdent := instDecidableEqProd +-- instance : DecidableEq CoreIdent := instDecidableEqProd -/-- The pretty-printer for Boogie Identifiers. +/-- The pretty-printer for Strata Core Identifiers. We ignore the visibility part so that the output can be parsed again -/ -def BoogieIdent.toPretty (x : BoogieIdent) : String := +def CoreIdent.toPretty (x : CoreIdent) : String := match x with | ⟨s, _⟩ => s -/-- The pretty-printer for Boogie Identifiers. +/-- The pretty-printer for Strata Core Identifiers. We ignore the visibility part so that the output can be parsed again -/ -instance : ToFormat BoogieIdent where - format i := BoogieIdent.toPretty i +instance : ToFormat CoreIdent where + format i := CoreIdent.toPretty i --- Explicit instances for BoogieLParams field access -instance : ToFormat BoogieLParams.Identifier := - show ToFormat BoogieIdent from inferInstance +-- Explicit instances for CoreLParams field access +instance : ToFormat CoreLParams.Identifier := + show ToFormat CoreIdent from inferInstance -instance : DecidableEq BoogieLParams.Identifier := - show DecidableEq BoogieIdent from inferInstance +instance : DecidableEq CoreLParams.Identifier := + show DecidableEq CoreIdent from inferInstance @@ -110,23 +111,23 @@ instance : DecidableEq BoogieLParams.Identifier := This can be useful for both debugging and generating "unique" strings, for example, as labels of proof obligations in the VC generator. - As a general guideline, whenever conversion from a `BoogieIdent` to `String` + As a general guideline, whenever conversion from a `CoreIdent` to `String` is needed, _always use the `toString` method_." Since `toString` includes the scoping information, consistency is ensured. Moreover, we could change the string representation fairly easily by overriding the method, if needed. -/ -instance : ToString BoogieIdent where +instance : ToString CoreIdent where toString | ⟨s, v⟩ => (toString $ ToFormat.format v) ++ (toString $ ToFormat.format s) -instance : Repr BoogieIdent where +instance : Repr CoreIdent where reprPrec | ⟨s, v⟩, _ => (ToFormat.format v) ++ (ToFormat.format s) -instance : Inhabited BoogieIdent where +instance : Inhabited CoreIdent where default := ⟨"_", .unres⟩ instance : Lambda.HasGen Visibility where genVar T := let (sym, state') := (Lambda.TState.genExprSym T.genState) - (BoogieIdent.temp sym, { T with genState := state' }) + (CoreIdent.temp sym, { T with genState := state' }) namespace Syntax @@ -134,30 +135,30 @@ open Lean Elab Meta Lambda.LExpr.SyntaxMono scoped syntax ident : lidentmono /-- Elaborator for String identifiers, construct a String instance -/ -def elabBoogieIdent : Syntax → MetaM Expr +def elabCoreIdent : Syntax → MetaM Expr | `(lidentmono| $s:ident) => do let s := toString s.getId - return ← mkAppM ``BoogieIdent.unres #[mkStrLit s] + return ← mkAppM ``CoreIdent.unres #[mkStrLit s] | _ => throwUnsupportedSyntax -- -instance : MkLExprParams ⟨BoogieExprMetadata, Visibility⟩ where - elabIdent := elabBoogieIdent - toExpr := mkApp2 (mkConst ``Lambda.LExprParams.mk) (mkConst ``BoogieExprMetadata) (.const ``Visibility []) +instance : MkLExprParams ⟨CoreExprMetadata, Visibility⟩ where + elabIdent := elabCoreIdent + toExpr := mkApp2 (mkConst ``Lambda.LExprParams.mk) (mkConst ``CoreExprMetadata) (.const ``Visibility []) -elab "eb[" e:lexprmono "]" : term => elabLExprMono (T:=⟨BoogieExprMetadata, Visibility⟩) e +elab "eb[" e:lexprmono "]" : term => elabLExprMono (T:=⟨CoreExprMetadata, Visibility⟩) e /-- -info: Lambda.LExpr.op () (BoogieIdent.unres "old") - none : Lambda.LExpr { Metadata := BoogieExprMetadata, IDMeta := Visibility }.mono +info: Lambda.LExpr.op () (CoreIdent.unres "old") + none : Lambda.LExpr { Metadata := CoreExprMetadata, IDMeta := Visibility }.mono -/ #guard_msgs in #check eb[~old] /-- -info: Lambda.LExpr.app () (Lambda.LExpr.op () (BoogieIdent.unres "old") none) - (Lambda.LExpr.fvar () (BoogieIdent.unres "a") - none) : Lambda.LExpr { Metadata := BoogieExprMetadata, IDMeta := Visibility }.mono +info: Lambda.LExpr.app () (Lambda.LExpr.op () (CoreIdent.unres "old") none) + (Lambda.LExpr.fvar () (CoreIdent.unres "a") + none) : Lambda.LExpr { Metadata := CoreExprMetadata, IDMeta := Visibility }.mono -/ #guard_msgs in #check eb[(~old a)] @@ -165,8 +166,8 @@ info: Lambda.LExpr.app () (Lambda.LExpr.op () (BoogieIdent.unres "old") none) open Lambda.LTy.Syntax in /-- -info: Lambda.LExpr.fvar () (BoogieIdent.unres "x") - (some (Lambda.LMonoTy.tcons "bool" [])) : Lambda.LExpr { Metadata := BoogieExprMetadata, IDMeta := Visibility }.mono +info: Lambda.LExpr.fvar () (CoreIdent.unres "x") + (some (Lambda.LMonoTy.tcons "bool" [])) : Lambda.LExpr { Metadata := CoreExprMetadata, IDMeta := Visibility }.mono -/ #guard_msgs in #check eb[(x : bool)] diff --git a/Strata/Languages/Core/OldExpressions.lean b/Strata/Languages/Core/OldExpressions.lean index ee34c80ea..233d48f07 100644 --- a/Strata/Languages/Core/OldExpressions.lean +++ b/Strata/Languages/Core/OldExpressions.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Core.BoogieGen +import Strata.Languages.Core.CoreGen import Strata.Languages.Core.Procedure namespace Core @@ -58,7 +58,7 @@ def oldExpr (e : Expression.Expr) : Expression.Expr := - .app mApp (.op mOp (BoogieIdent.unres "old") tyold) e + .app mApp (.op mOp (CoreIdent.unres "old") tyold) e @[match_pattern] def oldVar @@ -72,7 +72,7 @@ def oldVar := @oldExpr mApp mOp tyold (.fvar mVar v tyv) inductive IsOldPred : Expression.Expr → Prop where - | oldPred : IsOldPred (.op m (BoogieIdent.unres "old") ty) + | oldPred : IsOldPred (.op m (CoreIdent.unres "old") ty) def IsOldPred.decidablePred (e : Expression.Expr): Decidable (IsOldPred e) := match He : e with @@ -163,7 +163,7 @@ This function is agnostic of old expression normalization (see -/ def containsOldExpr (e : Expression.Expr) : Bool := match e with - | .op _ (BoogieIdent.unres "old") _ => true + | .op _ (CoreIdent.unres "old") _ => true | .op _ _ _ => false | .const _ _ | .bvar _ _ | .fvar _ _ _ => false | .abs _ _ e' => containsOldExpr e' @@ -191,8 +191,8 @@ def extractOldExprVars (expr : Expression.Expr) | .abs _ _ e => extractOldExprVars e | .quant _ _ _ tr e => extractOldExprVars tr ++ extractOldExprVars e | .app _ e1 e2 => match e1, e2 with - | .op _ (BoogieIdent.unres "old") _, .fvar _ v _ => [v] - | .op _ (BoogieIdent.unres "old") _, _ => panic! s!"Old expression {expr} not normalized" + | .op _ (CoreIdent.unres "old") _, .fvar _ v _ => [v] + | .op _ (CoreIdent.unres "old") _, _ => panic! s!"Old expression {expr} not normalized" | e1', e2' => extractOldExprVars e1' ++ extractOldExprVars e2' | .ite _ c t e => extractOldExprVars c ++ extractOldExprVars t ++ extractOldExprVars e | .eq _ e1 e2 => extractOldExprVars e1 ++ extractOldExprVars e2 @@ -212,7 +212,7 @@ def substOld (var : Expression.Ident) (s e : Expression.Expr) : | .quant m qk ty tr' e' => .quant m qk ty (substOld var s tr') (substOld var s e') | .app m e1 e2 => match e1, e2 with - | .op _ (BoogieIdent.unres "old") _, .fvar _ x _ => + | .op _ (CoreIdent.unres "old") _, .fvar _ x _ => -- NOTE: We rely on the typeChecker to normalize `e` ensure that `old` is -- only used with an `fvar`. if x == var @@ -237,7 +237,7 @@ def substsOldExpr (sm : Map Expression.Ident Expression.Expr) (e : Expression.Ex | .quant m qk ty tr' e' => .quant m qk ty (substsOldExpr sm tr') (substsOldExpr sm e') | .app m e1 e2 => match e1, e2 with - | .op _ (BoogieIdent.unres "old") _, .fvar _ x _ => + | .op _ (CoreIdent.unres "old") _, .fvar _ x _ => match sm.find? x with | some s => s | none => e @@ -391,7 +391,7 @@ theorem IsOldPredNormalize : simp [normalizeOldExpr] at Hold cases Hold case neg Hneg' => - unfold BoogieIdent.unres at * + unfold CoreIdent.unres at * unfold normalizeOldExpr at Hold split at Hold <;> simp_all split at Hold <;> simp_all @@ -523,7 +523,7 @@ case app fn e fn_ih e_ih => cases Hval with | app Hval1 Hval2 Hnold => have Hold'' := IsOldPredNormalize Hval1 Hold' - cases Hold'' <;> simp [BoogieIdent.unres] at * + cases Hold'' <;> simp [CoreIdent.unres] at * case ite c t e c_ih t_ih e_ih => apply c_ih cases Hval <;> assumption diff --git a/Strata/Languages/Core/Procedure.lean b/Strata/Languages/Core/Procedure.lean index 66beb9d24..1c2d9a2d9 100644 --- a/Strata/Languages/Core/Procedure.lean +++ b/Strata/Languages/Core/Procedure.lean @@ -23,22 +23,22 @@ instance : DecidableEq ExpressionMetadata := instance : Repr ExpressionMetadata := show Repr Unit from inferInstance -instance : DecidableEq (⟨⟨ExpressionMetadata, BoogieIdent⟩, LMonoTy⟩ : LExprParamsT).base.Metadata := +instance : DecidableEq (⟨⟨ExpressionMetadata, CoreIdent⟩, LMonoTy⟩ : LExprParamsT).base.Metadata := show DecidableEq ExpressionMetadata from inferInstance -instance : DecidableEq (⟨⟨ExpressionMetadata, BoogieIdent⟩, LMonoTy⟩ : LExprParamsT).base.IDMeta := - show DecidableEq BoogieIdent from inferInstance +instance : DecidableEq (⟨⟨ExpressionMetadata, CoreIdent⟩, LMonoTy⟩ : LExprParamsT).base.IDMeta := + show DecidableEq CoreIdent from inferInstance -instance : DecidableEq (⟨⟨ExpressionMetadata, BoogieIdent⟩, LMonoTy⟩ : LExprParamsT).TypeType := +instance : DecidableEq (⟨⟨ExpressionMetadata, CoreIdent⟩, LMonoTy⟩ : LExprParamsT).TypeType := show DecidableEq LMonoTy from inferInstance -instance : Repr (⟨⟨ExpressionMetadata, BoogieIdent⟩, LMonoTy⟩ : LExprParamsT).base.Metadata := +instance : Repr (⟨⟨ExpressionMetadata, CoreIdent⟩, LMonoTy⟩ : LExprParamsT).base.Metadata := show Repr ExpressionMetadata from inferInstance -instance : Repr (⟨⟨ExpressionMetadata, BoogieIdent⟩, LMonoTy⟩ : LExprParamsT).base.IDMeta := - show Repr BoogieIdent from inferInstance +instance : Repr (⟨⟨ExpressionMetadata, CoreIdent⟩, LMonoTy⟩ : LExprParamsT).base.IDMeta := + show Repr CoreIdent from inferInstance -instance : Repr (⟨⟨ExpressionMetadata, BoogieIdent⟩, LMonoTy⟩ : LExprParamsT).TypeType := +instance : Repr (⟨⟨ExpressionMetadata, CoreIdent⟩, LMonoTy⟩ : LExprParamsT).TypeType := show Repr LMonoTy from inferInstance instance : Repr Expression.Expr := @@ -47,7 +47,7 @@ instance : Repr Expression.Expr := /-! # Boogie Procedures -/ structure Procedure.Header where - name : BoogieIdent + name : CoreIdent typeArgs : List TyIdentifier inputs : @LMonoTySignature Visibility outputs : @LMonoTySignature Visibility @@ -93,8 +93,8 @@ def Procedure.Check.eraseTypes (c : Procedure.Check) : Procedure.Check := structure Procedure.Spec where modifies : List Expression.Ident - preconditions : ListMap BoogieLabel Procedure.Check - postconditions : ListMap BoogieLabel Procedure.Check + preconditions : ListMap CoreLabel Procedure.Check + postconditions : ListMap CoreLabel Procedure.Check deriving Inhabited, Repr instance : ToFormat Procedure.Spec where @@ -109,14 +109,14 @@ def Procedure.Spec.eraseTypes (s : Procedure.Spec) : Procedure.Spec := postconditions := s.postconditions.map (fun (l, c) => (l, c.eraseTypes)) } -def Procedure.Spec.getCheckExprs (conds : ListMap BoogieLabel Procedure.Check) : +def Procedure.Spec.getCheckExprs (conds : ListMap CoreLabel Procedure.Check) : List Expression.Expr := let checks := conds.values checks.map (fun c => c.expr) def Procedure.Spec.updateCheckExprs - (es : List Expression.Expr) (conds : ListMap BoogieLabel Procedure.Check) : - ListMap BoogieLabel Procedure.Check := + (es : List Expression.Expr) (conds : ListMap CoreLabel Procedure.Check) : + ListMap CoreLabel Procedure.Check := let checks := go es conds.values conds.keys.zip checks where go (es : List Expression.Expr) (checks : List Procedure.Check) := diff --git a/Strata/Languages/Core/ProcedureWF.lean b/Strata/Languages/Core/ProcedureWF.lean index 8fc806ccc..68ce457bb 100644 --- a/Strata/Languages/Core/ProcedureWF.lean +++ b/Strata/Languages/Core/ProcedureWF.lean @@ -17,7 +17,7 @@ namespace WF open Lambda -theorem snd_values_mem {ps : ListMap BoogieLabel Procedure.Check} : +theorem snd_values_mem {ps : ListMap CoreLabel Procedure.Check} : x ∈ ps.toList → x.snd ∈ ListMap.values ps := by intros Hin @@ -81,9 +81,9 @@ theorem Procedure.typeCheckWF : Procedure.typeCheck T p pp = Except.ok (pp', T') exact Hc2 . -- 11. All `modifies` variables have no duplicates. sorry - . -- 14. The `inputs` list of a procedure are all `BoogieIdent.locl` + . -- 14. The `inputs` list of a procedure are all `CoreIdent.locl` sorry - . -- 15. The `outputs` list of a procedure are all `BoogieIdent.locl` + . -- 15. The `outputs` list of a procedure are all `CoreIdent.locl` sorry . constructor <;> simp . -- precondition @@ -91,7 +91,7 @@ theorem Procedure.typeCheckWF : Procedure.typeCheck T p pp = Except.ok (pp', T') intros x Hin constructor . constructor - -- 5. All variables in post-conditions and pre-conditions are either `BoogieIdent.locl` or `BoogieIdent.glob`. + -- 5. All variables in post-conditions and pre-conditions are either `CoreIdent.locl` or `CoreIdent.glob`. . sorry -- 16. All variables in pre/post conditions that are `.locl` must be in `outputs` or `inputs` of the procedure . sorry @@ -107,7 +107,7 @@ theorem Procedure.typeCheckWF : Procedure.typeCheck T p pp = Except.ok (pp', T') apply List.Forall_mem_iff.mpr intros x Hin constructor - . -- 5. All variables in post-conditions and pre-conditions are either `BoogieIdent.locl` or `BoogieIdent.glob`. + . -- 5. All variables in post-conditions and pre-conditions are either `CoreIdent.locl` or `CoreIdent.glob`. sorry . -- 6. Postconditions in a procedure are all `ValidExpression`s sorry diff --git a/Strata/Languages/Core/Program.lean b/Strata/Languages/Core/Program.lean index a8cd2dee3..7fa81ad09 100644 --- a/Strata/Languages/Core/Program.lean +++ b/Strata/Languages/Core/Program.lean @@ -22,8 +22,8 @@ open Imperative instance : Inhabited TypeDecl where default := .con { name := "DefaultType", numargs := 0 } --- ToFormat instance for Function (which is LFunc BoogieLParams) --- Note: ToFormat BoogieLParams.Identifier is now defined in Identifiers.lean +-- ToFormat instance for Function (which is LFunc CoreLParams) +-- Note: ToFormat CoreLParams.Identifier is now defined in Identifiers.lean inductive DeclKind : Type where | var | type | ax | distinct | proc | func diff --git a/Strata/Languages/Core/ProgramWF.lean b/Strata/Languages/Core/ProgramWF.lean index cffd48aed..10379b42f 100644 --- a/Strata/Languages/Core/ProgramWF.lean +++ b/Strata/Languages/Core/ProgramWF.lean @@ -24,24 +24,24 @@ import Strata.Languages.Core.ProcedureWF well-formedness condition is not needed, it is denoted by '-'. 1. All `modifies` variables in a procedure are declared in the program. - 2. All declared global variables are `BoogieIdent.glob`. - - All local variable declarations in a procedure are `BoogieIdent.locl`. + 2. All declared global variables are `CoreIdent.glob`. + - All local variable declarations in a procedure are `CoreIdent.locl`. 4. All local variable declarations in a procedure have no duplicates. - 5. All variables in post-conditions and pre-conditions are either `BoogieIdent.locl` or `BoogieIdent.glob`. + 5. All variables in post-conditions and pre-conditions are either `CoreIdent.locl` or `CoreIdent.glob`. 6. Postconditions in a procedure are all `ValidExpression`s (c.f., `OldExpressions.lean`), that is, the old predicates do not occur on the right hand side of an `.app`. - 7. The `lhs` of a call statement contain no duplicates and are `BoogieIdent.locl`. + 7. The `lhs` of a call statement contain no duplicates and are `CoreIdent.locl`. This is to avoid overlapping with global variables that occurs in pre/post conditions, because call elimination directly substitutes `lhs` into the pre/post conditions, they must not already exist in the pre/post conditions. If a `lhs` needs to be global, a separate transformation can be implemented to create/substitute temporary variables before the call statement, and insert an assignment statement to + The `outputs` list of a procedure contains no duplicates - 9. All variables mentioned in `args` of a call statement are either `BoogieIdent.locl` or `BoogieIdent.glob`. + 9. All variables mentioned in `args` of a call statement are either `CoreIdent.locl` or `CoreIdent.glob`. + The `inputs` list of a procedure contains no duplicates 11. All `modifies` variables have no duplicates. 12. The `inputs` list of a procedure is disjoint from the `outputs` list of the procedure 13. The `lhs` of a call statement is disjoint from `modifies`, `outputs`, and `inputs` of the procedure - 14. The `inputs` list of a procedure are all `BoogieIdent.locl` - 15. The `outputs` list of a procedure are all `BoogieIdent.locl` + 14. The `inputs` list of a procedure are all `CoreIdent.locl` + 15. The `outputs` list of a procedure are all `CoreIdent.locl` 16. All variables in pre/post conditions that are `.locl` must be in `outputs` or `inputs` of the procedure In order to fully prove the type checker's properties, it might be necessary to @@ -133,7 +133,7 @@ theorem Program.typeCheck.goWF' : | intro l r => apply And.intro . constructor - -- 2. All declared global variables are `BoogieIdent.glob`. + -- 2. All declared global variables are `CoreIdent.glob`. sorry . exists v.1, { context := res.snd.context.subst res.snd.state.substInfo.subst, @@ -173,7 +173,7 @@ theorem Program.typeCheck.goWF' : state := (LMonoTys.instantiate td.typeArgs [td.toLHSLMonoTy, td.type] T).snd.state, functions := (LMonoTys.instantiate td.typeArgs [td.toLHSLMonoTy, td.type] T).snd.functions, knownTypes := (LMonoTys.instantiate td.typeArgs [td.toLHSLMonoTy, td.type] T).snd.knownTypes - : TEnv BoogieIdent } -- NOTE: this type annotation is important + : TEnv CoreIdent } -- NOTE: this type annotation is important = TT at Htc exists v'.fst, TT, v'.snd | ax a => diff --git a/Strata/Languages/Core/SMTEncoder.lean b/Strata/Languages/Core/SMTEncoder.lean index 965f3d961..74881de2b 100644 --- a/Strata/Languages/Core/SMTEncoder.lean +++ b/Strata/Languages/Core/SMTEncoder.lean @@ -6,7 +6,7 @@ -import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Core import Strata.DL.SMT.SMT import Init.Data.String.Extra import Strata.DDM.Util.DecimalRat @@ -35,8 +35,8 @@ structure SMT.Context where ifs : Array SMT.IF := #[] axms : Array Term := #[] tySubst: Map String TermType := [] - datatypes : Array (LDatatype BoogieLParams.IDMeta) := #[] - datatypeFuns : Map String (Op.DatatypeFuncs × LConstr BoogieLParams.IDMeta) := Map.empty + datatypes : Array (LDatatype CoreLParams.IDMeta) := #[] + datatypeFuns : Map String (Op.DatatypeFuncs × LConstr CoreLParams.IDMeta) := Map.empty deriving Repr, DecidableEq, Inhabited def SMT.Context.default : SMT.Context := {} @@ -67,7 +67,7 @@ def SMT.Context.removeSubst (ctx : SMT.Context) (newSubst: Map String TermType) def SMT.Context.hasDatatype (ctx : SMT.Context) (name : String) : Bool := (ctx.datatypes.map LDatatype.name).contains name -def SMT.Context.addDatatype (ctx : SMT.Context) (d : LDatatype BoogieLParams.IDMeta) : SMT.Context := +def SMT.Context.addDatatype (ctx : SMT.Context) (d : LDatatype CoreLParams.IDMeta) : SMT.Context := if ctx.hasDatatype d.name then ctx else let (c, i, s) := d.genFunctionMaps @@ -97,7 +97,7 @@ private def lMonoTyToSMTString (ty : LMonoTy) : String := Build a dependency graph for datatypes. Returns a mapping from datatype names to their dependencies. -/ -private def buildDatatypeDependencyGraph (datatypes : Array (LDatatype BoogieLParams.IDMeta)) : +private def buildDatatypeDependencyGraph (datatypes : Array (LDatatype CoreLParams.IDMeta)) : Map String (Array String) := let depMap := datatypes.foldl (fun acc d => let deps := d.constrs.foldl (fun deps c => @@ -259,7 +259,7 @@ def convertQuantifierKind : Lambda.QuantifierKind -> Strata.SMT.QuantifierKind mutual -partial def toSMTTerm (E : Env) (bvs : BoundVars) (e : LExpr BoogieLParams.mono) (ctx : SMT.Context) +partial def toSMTTerm (E : Env) (bvs : BoundVars) (e : LExpr CoreLParams.mono) (ctx : SMT.Context) : Except Format (Term × SMT.Context) := do match e with | .boolConst _ b => .ok (Term.bool b, ctx) @@ -316,7 +316,7 @@ partial def toSMTTerm (E : Env) (bvs : BoundVars) (e : LExpr BoogieLParams.mono) | .app _ _ _ => appToSMTTerm E bvs e [] ctx -partial def appToSMTTerm (E : Env) (bvs : BoundVars) (e : LExpr BoogieLParams.mono) (acc : List Term) (ctx : SMT.Context) : +partial def appToSMTTerm (E : Env) (bvs : BoundVars) (e : LExpr CoreLParams.mono) (acc : List Term) (ctx : SMT.Context) : Except Format (Term × SMT.Context) := do match e with -- Special case for indexed SMT operations. @@ -358,7 +358,7 @@ partial def appToSMTTerm (E : Env) (bvs : BoundVars) (e : LExpr BoogieLParams.mo | _ => toSMTTerm E bvs e ctx -partial def toSMTOp (E : Env) (fn : BoogieIdent) (fnty : LMonoTy) (ctx : SMT.Context) : +partial def toSMTOp (E : Env) (fn : CoreIdent) (fnty : LMonoTy) (ctx : SMT.Context) : Except Format ((List Term → TermType → Term) × TermType × SMT.Context) := open LTy.Syntax in do -- Encode the type to ensure any datatypes are registered in the context @@ -595,7 +595,7 @@ partial def toSMTOp (E : Env) (fn : BoogieIdent) (fnty : LMonoTy) (ctx : SMT.Con .ok (acc_map.insert tyVar smtTy) ) Map.empty -- Add all axioms for this function to the context, with types binding for the type variables in the expr - let ctx ← func.axioms.foldlM (fun acc_ctx (ax: LExpr BoogieLParams.mono) => do + let ctx ← func.axioms.foldlM (fun acc_ctx (ax: LExpr CoreLParams.mono) => do let current_axiom_ctx := acc_ctx.addSubst smt_ty_inst let (axiom_term, new_ctx) ← toSMTTerm E [] ax current_axiom_ctx .ok (new_ctx.addAxiom axiom_term) @@ -606,7 +606,7 @@ partial def toSMTOp (E : Env) (fn : BoogieIdent) (fnty : LMonoTy) (ctx : SMT.Con .ok (.app (Op.uf uf), smt_outty, ctx) end -def toSMTTerms (E : Env) (es : List (LExpr BoogieLParams.mono)) (ctx : SMT.Context) : +def toSMTTerms (E : Env) (es : List (LExpr CoreLParams.mono)) (ctx : SMT.Context) : Except Format ((List Term) × SMT.Context) := do match es with | [] => .ok ([], ctx) @@ -657,7 +657,7 @@ def ProofObligation.toSMTTerms (E : Env) --------------------------------------------------------------------- /-- Convert an expression of type LExpr to a String representation in SMT-Lib syntax, for testing. -/ -def toSMTTermString (e : LExpr BoogieLParams.mono) (E : Env := Env.init) (ctx : SMT.Context := SMT.Context.default) +def toSMTTermString (e : LExpr CoreLParams.mono) (E : Env := Env.init) (ctx : SMT.Context := SMT.Context.default) : IO String := do let smtctx := toSMTTerm E [] e ctx match smtctx with diff --git a/Strata/Languages/Core/StatementSemantics.lean b/Strata/Languages/Core/StatementSemantics.lean index 1a71386e0..25d68fe43 100644 --- a/Strata/Languages/Core/StatementSemantics.lean +++ b/Strata/Languages/Core/StatementSemantics.lean @@ -42,7 +42,7 @@ instance : HasNot Core.Expression where not | Boogie.true => Boogie.false | Boogie.false => Boogie.true - | e => Lambda.LExpr.app () (Lambda.LFunc.opExpr (T:=BoogieLParams) Lambda.boolNotFunc) e + | e => Lambda.LExpr.app () (Lambda.LFunc.opExpr (T:=CoreLParams) Lambda.boolNotFunc) e abbrev BoogieEval := SemanticEval Expression abbrev BoogieStore := SemanticStore Expression diff --git a/Strata/Languages/Core/StatementType.lean b/Strata/Languages/Core/StatementType.lean index e904cc428..1dd9967db 100644 --- a/Strata/Languages/Core/StatementType.lean +++ b/Strata/Languages/Core/StatementType.lean @@ -25,7 +25,7 @@ Type checker for Boogie commands. Note that this function needs the entire program to type-check `call` commands by looking up the corresponding procedure's information. -/ -def typeCheckCmd (C: LContext BoogieLParams) (Env : TEnv Visibility) (P : Program) (c : Command) : +def typeCheckCmd (C: LContext CoreLParams) (Env : TEnv Visibility) (P : Program) (c : Command) : Except Format (Command × (TEnv Visibility)) := do match c with | .cmd c => @@ -38,7 +38,7 @@ def typeCheckCmd (C: LContext BoogieLParams) (Env : TEnv Visibility) (P : Progra match Program.Procedure.find? P pname with | none => .error f!"[{c}]: Procedure {pname} not found!" | some proc => - if lhs.any (fun (l: BoogieIdent) => (Env.context.types.find? l).isNone) then + if lhs.any (fun (l: CoreIdent) => (Env.context.types.find? l).isNone) then .error f!"[{c}]: All the return variables {lhs} must exist in the context!" else if lhs.length != proc.header.outputs.length then .error f!"[{c}]: Arity mismatch in this call's return values!\ @@ -75,7 +75,7 @@ def typeCheckCmd (C: LContext BoogieLParams) (Env : TEnv Visibility) (P : Progra .error f!"{@MetaData.formatFileRangeD Expression _ md false} {e}" -def typeCheckAux (C: LContext BoogieLParams) (Env : TEnv Visibility) (P : Program) (op : Option Procedure) (ss : List Statement) : +def typeCheckAux (C: LContext CoreLParams) (Env : TEnv Visibility) (P : Program) (op : Option Procedure) (ss : List Statement) : Except Format (List Statement × TEnv Visibility) := go Env ss [] where diff --git a/Strata/Languages/Core/StatementWF.lean b/Strata/Languages/Core/StatementWF.lean index faaee29ce..d5b372b21 100644 --- a/Strata/Languages/Core/StatementWF.lean +++ b/Strata/Languages/Core/StatementWF.lean @@ -175,14 +175,14 @@ theorem Statement.typeCheckWF : constructor <;> simp_all . -- 13. The `lhs` of a call statement is disjoint from `modifies`, `outputs`, and `inputs` of the procedure sorry - . -- 7. The `lhs` of a call statement contain no duplicates and are `BoogieIdent.locl`. + . -- 7. The `lhs` of a call statement contain no duplicates and are `CoreIdent.locl`. sorry . refine List.Forall_mem_iff.mpr ?_ intros arg Hin constructor refine List.Forall_mem_iff.mpr ?_ intros var Hin' - -- 9. All variables mentioned in `args` of a call statement are either `BoogieIdent.locl` or `BoogieIdent.glob`. + -- 9. All variables mentioned in `args` of a call statement are either `CoreIdent.locl` or `CoreIdent.glob`. sorry | cmd => constructor diff --git a/Strata/Languages/Core/Verifier.lean b/Strata/Languages/Core/Verifier.lean index 3a46dc574..a60dbd56a 100644 --- a/Strata/Languages/Core/Verifier.lean +++ b/Strata/Languages/Core/Verifier.lean @@ -319,7 +319,7 @@ def preprocessObligation (obligation : ProofObligation Expression) (p : Program) -- axioms w.r.t. the consequent to reduce the size of the proof -- obligation. let cg := Program.toFunctionCG p - let fns := obligation.obligation.getOps.map BoogieIdent.toPretty + let fns := obligation.obligation.getOps.map CoreIdent.toPretty let relevant_fns := (fns ++ (CallGraph.getAllCalleesClosure cg fns)).dedup let irrelevant_axs := Program.getIrrelevantAxioms p relevant_fns let new_assumptions := Imperative.PathConditions.removeByNames obligation.assumptions irrelevant_axs @@ -404,7 +404,7 @@ def verifySingleEnv (smtsolver : String) (pE : Program × Env) (options : Option def verify (smtsolver : String) (program : Program) (options : Options := Options.default) - (moreFns : @Lambda.Factory BoogieLParams := Lambda.Factory.default) : + (moreFns : @Lambda.Factory CoreLParams := Lambda.Factory.default) : EIO Format VCResults := do match Core.typeCheckAndPartialEval options program moreFns with | .error err => @@ -424,7 +424,7 @@ namespace Strata open Lean.Parser def typeCheck (ictx : InputContext) (env : Program) (options : Options := Options.default) - (moreFns : @Lambda.Factory Core.BoogieLParams := Lambda.Factory.default) : + (moreFns : @Lambda.Factory Core.CoreLParams := Lambda.Factory.default) : Except Std.Format Core.Program := do let (program, errors) := TransM.run ictx (translateProgram env) if errors.isEmpty then @@ -442,7 +442,7 @@ def verify (smtsolver : String) (env : Program) (ictx : InputContext := Inhabited.default) (options : Options := Options.default) - (moreFns : @Lambda.Factory Core.BoogieLParams := Lambda.Factory.default) + (moreFns : @Lambda.Factory Core.CoreLParams := Lambda.Factory.default) : IO Core.VCResults := do let (program, errors) := Boogie.getProgram env ictx if errors.isEmpty then diff --git a/Strata/Languages/Core/WF.lean b/Strata/Languages/Core/WF.lean index 6f07c95db..51634c9e4 100644 --- a/Strata/Languages/Core/WF.lean +++ b/Strata/Languages/Core/WF.lean @@ -45,7 +45,7 @@ open Imperative structure WFcmdProp (p : Program) (c : Imperative.Cmd Expression) : Prop where structure WFargProp (p : Program) (arg : Expression.Expr) : Prop where - glarg : Forall (BoogieIdent.isGlobOrLocl ·) (HasVarsPure.getVars (P:=Expression) arg) + glarg : Forall (CoreIdent.isGlobOrLocl ·) (HasVarsPure.getVars (P:=Expression) arg) structure WFcallProp (p : Program) (lhs : List Expression.Ident) (procName : String) (args : List Expression.Expr) : Prop where defined : (Program.Procedure.find? p (.unres procName)).isSome @@ -55,7 +55,7 @@ structure WFcallProp (p : Program) (lhs : List Expression.Ident) (procName : Str proc.header.outputs.length = lhs.length lhsDisj : (Program.Procedure.find? p (.unres procName) = some proc) → lhs.Disjoint (proc.spec.modifies ++ ListMap.keys proc.header.inputs ++ ListMap.keys proc.header.outputs) - lhsWF : lhs.Nodup ∧ Forall (BoogieIdent.isLocl ·) lhs + lhsWF : lhs.Nodup ∧ Forall (CoreIdent.isLocl ·) lhs wfargs : Forall (WFargProp p) args def WFCmdExtProp (p : Program) (c : CmdExt Expression) : Prop := match c with @@ -89,20 +89,20 @@ instance (p : Program) : ListP (WFStatementProp p) (WFStatementsProp p) where /- Spec Wellformedness -/ -structure WFPrePostProp (p : Program) (d : Procedure) (pp : BoogieLabel × Procedure.Check) +structure WFPrePostProp (p : Program) (d : Procedure) (pp : CoreLabel × Procedure.Check) : Prop where - glvars : Forall (BoogieIdent.isGlobOrLocl ·) (HasVarsPure.getVars (P:=Expression) pp.2.expr) + glvars : Forall (CoreIdent.isGlobOrLocl ·) (HasVarsPure.getVars (P:=Expression) pp.2.expr) lvars : Forall (fun x => - (BoogieIdent.isLocl x) → + (CoreIdent.isLocl x) → (x ∈ (ListMap.keys d.header.inputs) ++ (ListMap.keys d.header.outputs))) (HasVarsPure.getVars (P:=Expression) pp.2.expr) -structure WFPreProp (p : Program) (d : Procedure) (pp : BoogieLabel × Procedure.Check) +structure WFPreProp (p : Program) (d : Procedure) (pp : CoreLabel × Procedure.Check) : Prop extends WFPrePostProp p d pp where nold : ¬ OldExpressions.containsOldExpr pp.2.expr -structure WFPostProp (p : Program) (d : Procedure) (pp : BoogieLabel × Procedure.Check) +structure WFPostProp (p : Program) (d : Procedure) (pp : CoreLabel × Procedure.Check) : Prop extends WFPrePostProp p d pp where oldexprs : OldExpressions.ValidExpression pp.2.expr @@ -127,7 +127,7 @@ structure WFSpecProp (p : Program) (spec : Procedure.Spec) (d : Procedure): Prop /- Procedure Wellformedness -/ structure WFVarProp (p : Program) (name : Expression.Ident) (ty : Expression.Ty) (e : Expression.Expr) : Prop where - glob : BoogieIdent.isGlob name + glob : CoreIdent.isGlob name structure WFTypeDeclarationProp (p : Program) (f : TypeDecl) : Prop where @@ -142,8 +142,8 @@ structure WFProcedureProp (p : Program) (d : Procedure) : Prop where inputsNodup : (ListMap.keys d.header.inputs).Nodup outputsNodup : (ListMap.keys d.header.outputs).Nodup modNodup : d.spec.modifies.Nodup - inputsLocl : Forall (BoogieIdent.isLocl ·) (ListMap.keys d.header.inputs) - outputsLocl : Forall (BoogieIdent.isLocl ·) (ListMap.keys d.header.outputs) + inputsLocl : Forall (CoreIdent.isLocl ·) (ListMap.keys d.header.inputs) + outputsLocl : Forall (CoreIdent.isLocl ·) (ListMap.keys d.header.outputs) wfspec : WFSpecProp p d.spec d structure WFFunctionProp (p : Program) (f : Function) : Prop where diff --git a/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean b/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean index bf4af7d06..56e2c8891 100644 --- a/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean +++ b/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean @@ -42,7 +42,7 @@ def translateExpr (expr : StmtExpr) : Core.Expression.Expr := | .LiteralBool b => .const () (.boolConst b) | .LiteralInt i => .const () (.intConst i) | .Identifier name => - let ident := Core.BoogieIdent.locl name + let ident := Core.CoreIdent.locl name .fvar () ident (some LMonoTy.int) -- Default to int type | .PrimitiveOp op [e] => match op with @@ -79,7 +79,7 @@ def translateExpr (expr : StmtExpr) : Core.Expression.Expr := | .Assign _ value => translateExpr value -- For expressions, just translate the value | .StaticCall name args => -- Create function call as an op application - let ident := Core.BoogieIdent.glob name + let ident := Core.CoreIdent.glob name let fnOp := .op () ident (some LMonoTy.int) -- Assume int return type args.foldl (fun acc arg => .app () acc (translateExpr arg)) fnOp | _ => panic! Std.Format.pretty (Std.ToFormat.format expr) @@ -108,7 +108,7 @@ def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Core. | .LocalVariable name ty initializer => let boogieMonoType := translateType ty let boogieType := LTy.forAll [] boogieMonoType - let ident := Core.BoogieIdent.locl name + let ident := Core.CoreIdent.locl name match initializer with | some initExpr => let boogieExpr := translateExpr initExpr @@ -123,7 +123,7 @@ def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Core. | .Assign target value => match target with | .Identifier name => - let ident := Core.BoogieIdent.locl name + let ident := Core.CoreIdent.locl name let boogieExpr := translateExpr value [Core.Statement.set ident boogieExpr] | _ => [] -- Can only assign to simple identifiers @@ -143,7 +143,7 @@ def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Core. match valueOpt, outputParams.head? with | some value, some outParam => -- Assign to the first output parameter, then assume false for no fallthrough - let ident := Core.BoogieIdent.locl outParam.name + let ident := Core.CoreIdent.locl outParam.name let boogieExpr := translateExpr value let assignStmt := Core.Statement.set ident boogieExpr let noFallThrough := Core.Statement.assume "return" (.const () (.boolConst false)) .empty @@ -160,8 +160,8 @@ def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Core. /-- Translate Laurel Parameter to Boogie Signature entry -/ -def translateParameterToBoogie (param : Parameter) : (Core.BoogieIdent × LMonoTy) := - let ident := Core.BoogieIdent.locl param.name +def translateParameterToBoogie (param : Parameter) : (Core.CoreIdent × LMonoTy) := + let ident := Core.CoreIdent.locl param.name let ty := translateType param.type (ident, ty) diff --git a/Strata/Languages/Python/FunctionSignatures.lean b/Strata/Languages/Python/FunctionSignatures.lean index b003d0d3f..35a239400 100644 --- a/Strata/Languages/Python/FunctionSignatures.lean +++ b/Strata/Languages/Python/FunctionSignatures.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Core namespace Strata namespace Python diff --git a/Strata/Languages/Python/PyFactory.lean b/Strata/Languages/Python/PyFactory.lean index 2baf98fd9..018cfc535 100644 --- a/Strata/Languages/Python/PyFactory.lean +++ b/Strata/Languages/Python/PyFactory.lean @@ -64,7 +64,7 @@ if not PyReMatch(REGEX, name, 0) then open Core open Lambda LTy.Syntax LExpr.SyntaxMono -def reCompileFunc : LFunc Core.BoogieLParams := +def reCompileFunc : LFunc Core.CoreLParams := { name := "PyReCompile", typeArgs := [], inputs := [("string", mty[string]), @@ -94,7 +94,7 @@ def reCompileFunc : LFunc Core.BoogieLParams := | _ => .none) } -def ReFactory : @Factory Core.BoogieLParams := +def ReFactory : @Factory Core.CoreLParams := #[ reCompileFunc ] diff --git a/Strata/Languages/Python/PythonToBoogie.lean b/Strata/Languages/Python/PythonToBoogie.lean index 1af566c15..de01e2a11 100644 --- a/Strata/Languages/Python/PythonToBoogie.lean +++ b/Strata/Languages/Python/PythonToBoogie.lean @@ -9,7 +9,7 @@ import Strata.DDM.AST import Strata.Languages.Core.DDMTransform.Parse -import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Core import Strata.Languages.Python.PythonDialect import Strata.Languages.Python.FunctionSignatures import Strata.Languages.Python.Regex.ReToBoogie @@ -503,8 +503,8 @@ partial def exceptHandlersToBoogie (jmp_targets: List String) (translation_ctx: | .ExceptHandler _ ex_ty _ body => let set_ex_ty_matches := match ex_ty.val with | .some ex_ty => - let inherits_from : Core.BoogieIdent := "inheritsFrom" - let get_ex_tag : Core.BoogieIdent := "ExceptOrNone_code_val" + let inherits_from : Core.CoreIdent := "inheritsFrom" + let get_ex_tag : Core.CoreIdent := "ExceptOrNone_code_val" let exception_ty : Core.Expression.Expr := .app () (.op () get_ex_tag none) (.fvar () "maybe_except" none) let rhs_curried : Core.Expression.Expr := .app () (.op () inherits_from none) exception_ty let res := PyExprToBoogie translation_ctx ex_ty diff --git a/Strata/Transform/CallElimCorrect.lean b/Strata/Transform/CallElimCorrect.lean index 5c1875e53..448495187 100644 --- a/Strata/Transform/CallElimCorrect.lean +++ b/Strata/Transform/CallElimCorrect.lean @@ -30,31 +30,31 @@ import Strata.DL.Util.ListUtils namespace CallElimCorrect open Core Core.Transform CallElim -theorem BoogieIdent.isGlob_isGlobOrLocl : - PredImplies (BoogieIdent.isGlob ·) (BoogieIdent.isGlobOrLocl ·) := by +theorem CoreIdent.isGlob_isGlobOrLocl : + PredImplies (CoreIdent.isGlob ·) (CoreIdent.isGlobOrLocl ·) := by intros x H - simp [BoogieIdent.isGlobOrLocl] + simp [CoreIdent.isGlobOrLocl] exact Or.symm (Or.inr H) -theorem BoogieIdent.isLocl_isGlobOrLocl : - PredImplies (BoogieIdent.isLocl ·) (BoogieIdent.isGlobOrLocl ·) := by +theorem CoreIdent.isLocl_isGlobOrLocl : + PredImplies (CoreIdent.isLocl ·) (CoreIdent.isGlobOrLocl ·) := by intros x H - simp [BoogieIdent.isGlobOrLocl] + simp [CoreIdent.isGlobOrLocl] exact Or.symm (Or.inl H) -theorem BoogieIdent.Disjoint_isTemp_isGlobOrLocl : - PredDisjoint (BoogieIdent.isTemp ·) (BoogieIdent.isGlobOrLocl ·) := by +theorem CoreIdent.Disjoint_isTemp_isGlobOrLocl : + PredDisjoint (CoreIdent.isTemp ·) (CoreIdent.isGlobOrLocl ·) := by intros x H1 H2 - simp [BoogieIdent.isTemp] at H1 - simp [BoogieIdent.isGlobOrLocl] at H2 + simp [CoreIdent.isTemp] at H1 + simp [CoreIdent.isGlobOrLocl] at H2 split at H1 <;> simp_all - cases H2 <;> simp [BoogieIdent.isGlob, BoogieIdent.isLocl] at * + cases H2 <;> simp [CoreIdent.isGlob, CoreIdent.isLocl] at * -theorem BoogieIdent.Disjoint_isLocl_isGlob : - PredDisjoint (BoogieIdent.isLocl ·) (BoogieIdent.isGlob ·) := by +theorem CoreIdent.Disjoint_isLocl_isGlob : + PredDisjoint (CoreIdent.isLocl ·) (CoreIdent.isGlob ·) := by intros x H1 H2 - simp [BoogieIdent.isLocl] at H1 - simp [BoogieIdent.isGlob] at H2 + simp [CoreIdent.isLocl] at H1 + simp [CoreIdent.isGlob] at H2 split at H1 <;> simp_all -- inidividual lemmas @@ -137,7 +137,7 @@ theorem getIdentTy!_no_throw : theorem getIdentTys!_no_throw : ∀ {p : Program} {idents : List Expression.Ident} - {cs : BoogieGenState}, + {cs : CoreGenState}, (∀ ident ∈ idents, (p.find? .var ident).isSome = true) → ∃ r, (runWith idents (getIdentTys! p) cs).fst = (Except.ok r) := by intros p idents cs Hglob @@ -240,7 +240,7 @@ theorem callElimBlockNoExcept : exfalso apply Hne simp [Option.isSome] at df - unfold BoogieIdent.unres at * + unfold CoreIdent.unres at * split at df <;> simp_all apply Hne simp [← ol, Lambda.LMonoTySignature.toTrivialLTy] @@ -256,7 +256,7 @@ theorem callElimBlockNoExcept : exfalso apply Hne simp [Option.isSome] at df - unfold BoogieIdent.unres at * + unfold CoreIdent.unres at * split at df <;> simp_all apply Hne simp [← al, Lambda.LMonoTySignature.toTrivialLTy] @@ -270,7 +270,7 @@ theorem callElimBlockNoExcept : cases wf with | mk wf => simp [Program.Procedure.find?] at wf - unfold BoogieIdent.unres at * + unfold CoreIdent.unres at * split at wf <;> simp_all . -- other case grind @@ -299,7 +299,7 @@ theorem postconditions_subst_unwrap : symm exact Hin.2 -theorem prepostconditions_unwrap {ps : List (BoogieLabel × Procedure.Check)} : +theorem prepostconditions_unwrap {ps : List (CoreLabel × Procedure.Check)} : post ∈ List.map Procedure.Check.expr (ListMap.values ps) → ∃ label attr md, (label, { expr := post, attr := attr, md := md : Procedure.Check }) ∈ ps := by intros H @@ -1765,7 +1765,7 @@ theorem substOldCorrect : have HH:= Hwf2.2.1 vs vs' σ₀ σ₁ σ Hwf2'.1 Hwf2'.2 fro simp [OldExpressions.oldVar, OldExpressions.oldExpr, - BoogieIdent.unres, Hin] at HH + CoreIdent.unres, Hin] at HH rw [HH] simp [createFvar] simp [Imperative.WellFormedSemanticEvalVar] at Hwfvr @@ -1786,7 +1786,7 @@ theorem substOldCorrect : . have HH:= Hwf2.2.1 vs vs' σ₀ σ₁ σ Hwf2'.1 Hwf2'.2 fro simp [OldExpressions.oldVar, OldExpressions.oldExpr, - BoogieIdent.unres, Hin] at HH + CoreIdent.unres, Hin] at HH simp [createFvar] simp [HH] simp [Imperative.WellFormedSemanticEvalVar] at Hwfvr @@ -2027,7 +2027,7 @@ NormalizedOldExpr e → cases Hold cases Hwf simp_all - simp [BoogieIdent.unres] at HH + simp [CoreIdent.unres] at HH rename_i md tyy id v have HH2 := HH md tyy () id v simp_all @@ -2408,7 +2408,7 @@ theorem Program.find.var_in_decls : theorem WFProgGlob : WF.WFDeclsProp p p.decls → - PredImplies (isGlobalVar p ·) (BoogieIdent.isGlob ·) := by + PredImplies (isGlobalVar p ·) (CoreIdent.isGlob ·) := by intros Hwf x HH simp [isGlobalVar, Option.isSome] at HH split at HH <;> simp at HH @@ -2476,27 +2476,27 @@ case cons h t ih => /--! Theorems about well-formedness of BoogieGen -/ theorem genArgExprIdentTemp : - genArgExprIdent s = (l, s') → BoogieIdent.isTemp l := - fun Hgen => by exact genBoogieIdentTemp Hgen + genArgExprIdent s = (l, s') → CoreIdent.isTemp l := + fun Hgen => by exact genCoreIdentTemp Hgen theorem genOutExprIdentTemp : - genOutExprIdent e s = (l, s') → BoogieIdent.isTemp l := - fun Hgen => genBoogieIdentTemp Hgen + genOutExprIdent e s = (l, s') → CoreIdent.isTemp l := + fun Hgen => genCoreIdentTemp Hgen -theorem genBoogieIdentGeneratedWF : - BoogieGenState.gen pf s = (l, s') → s'.generated = l :: s.generated := by +theorem genCoreIdentGeneratedWF : + CoreGenState.gen pf s = (l, s') → s'.generated = l :: s.generated := by intros Hgen - simp [BoogieGenState.gen] at Hgen + simp [CoreGenState.gen] at Hgen rw [← Hgen.2] simp_all theorem genIdentGeneratedWF : genIdent ident pf s = (l, s') → s'.generated = l :: s.generated := - fun Hgen => genBoogieIdentGeneratedWF Hgen + fun Hgen => genCoreIdentGeneratedWF Hgen theorem genArgExprIdentGeneratedWF : genArgExprIdent s = (l, s') → s'.generated = l :: s.generated := - fun Hgen => genBoogieIdentGeneratedWF Hgen + fun Hgen => genCoreIdentGeneratedWF Hgen theorem genArgExprIdentsGeneratedWF : genArgExprIdents n s = (ls, s') → @@ -2520,7 +2520,7 @@ theorem genArgExprIdentsGeneratedWF : have HH := genArgExprIdentGeneratedWF heq grind -theorem genArgExprIdentsTripGeneratedWF { s s' : BoogieGenState } : +theorem genArgExprIdentsTripGeneratedWF { s s' : CoreGenState } : genArgExprIdentsTrip outs xs s = (Except.ok trips, s') → trips.unzip.1.unzip.1.reverse ++ s.generated = s'.generated := by intros Hgen @@ -2552,15 +2552,15 @@ theorem genArgExprIdentsTripGeneratedWF { s s' : BoogieGenState } : cases Hgen theorem genArgExprIdentWFMono : - BoogieGenState.WF s → + CoreGenState.WF s → genArgExprIdent s = (l, s') → - BoogieGenState.WF s' := - fun Hgen => BoogieGenState.WFMono' Hgen + CoreGenState.WF s' := + fun Hgen => CoreGenState.WFMono' Hgen theorem genArgExprIdentsWFMono : - BoogieGenState.WF s → + CoreGenState.WF s → genArgExprIdents n s = (ls, s') → - BoogieGenState.WF s' := by + CoreGenState.WF s' := by intros Hwf Hgen simp [genArgExprIdents] at Hgen induction n generalizing s ls s' @@ -2579,9 +2579,9 @@ theorem genArgExprIdentsWFMono : grind theorem genArgExprIdentsTripWFMono : - BoogieGenState.WF s → + CoreGenState.WF s → genArgExprIdentsTrip outs xs s = (Except.ok trips, s') → - BoogieGenState.WF s' := by + CoreGenState.WF s' := by intros Hwf Hgen simp [genArgExprIdentsTrip] at * split at Hgen @@ -2608,7 +2608,7 @@ theorem genArgExprIdentsTripWFMono : theorem genOutExprIdentGeneratedWF : genOutExprIdent e s = (l, s') → s'.generated = l :: s.generated := - fun Hgen => genBoogieIdentGeneratedWF Hgen + fun Hgen => genCoreIdentGeneratedWF Hgen theorem genOutExprIdentsGeneratedWF : genOutExprIdents es s = (ls, s') → @@ -2632,7 +2632,7 @@ theorem genOutExprIdentsGeneratedWF : simp [HH] at ih simp_all -theorem genOutExprIdentsTripGeneratedWF { s s' : BoogieGenState } : +theorem genOutExprIdentsTripGeneratedWF { s s' : CoreGenState } : genOutExprIdentsTrip outs xs s = (Except.ok trips, s') → trips.unzip.1.unzip.1.reverse ++ s.generated = s'.generated := by intros Hgen @@ -2664,15 +2664,15 @@ theorem genOutExprIdentsTripGeneratedWF { s s' : BoogieGenState } : cases Hgen theorem genOutExprIdentWFMono : - BoogieGenState.WF s → + CoreGenState.WF s → genOutExprIdent e s = (l, s') → - BoogieGenState.WF s' := - fun Hgen => BoogieGenState.WFMono' Hgen + CoreGenState.WF s' := + fun Hgen => CoreGenState.WFMono' Hgen theorem genOutExprIdentsWFMono : - BoogieGenState.WF s → + CoreGenState.WF s → genOutExprIdents es s = (ls, s') → - BoogieGenState.WF s' := by + CoreGenState.WF s' := by intros Hwf Hgen simp [genOutExprIdents] at Hgen induction es generalizing s ls s' <;> simp at Hgen @@ -2690,9 +2690,9 @@ theorem genOutExprIdentsWFMono : exact ih HH heq' theorem genOutExprIdentsTripWFMono : - BoogieGenState.WF s → + CoreGenState.WF s → genOutExprIdentsTrip outs xs s = (Except.ok trips, s') → - BoogieGenState.WF s' := by + CoreGenState.WF s' := by intros Hwf Hgen simp [genOutExprIdentsTrip] at * split at Hgen @@ -2719,7 +2719,7 @@ theorem genOutExprIdentsTripWFMono : theorem genOldExprIdentGeneratedWF : genOldExprIdent e s = (l, s') → s'.generated = l :: s.generated := - fun Hgen => genBoogieIdentGeneratedWF Hgen + fun Hgen => genCoreIdentGeneratedWF Hgen theorem genOldExprIdentsGeneratedWF : genOldExprIdents es s = (ls, s') → @@ -2743,7 +2743,7 @@ theorem genOldExprIdentsGeneratedWF : simp [HH] at ih simp_all -theorem genOldExprIdentsTripGeneratedWF { s s' : BoogieGenState } : +theorem genOldExprIdentsTripGeneratedWF { s s' : CoreGenState } : genOldExprIdentsTrip p xs s = (Except.ok trips, s') → trips.unzip.1.unzip.1.reverse ++ s.generated = s'.generated := by intros Hgen @@ -2778,15 +2778,15 @@ theorem genOldExprIdentsTripGeneratedWF { s s' : BoogieGenState } : . cases Hgen theorem genOldExprIdentWFMono : - BoogieGenState.WF s → + CoreGenState.WF s → genOldExprIdent e s = (l, s') → - BoogieGenState.WF s' := - fun Hgen => BoogieGenState.WFMono' Hgen + CoreGenState.WF s' := + fun Hgen => CoreGenState.WFMono' Hgen theorem genOldExprIdentsWFMono : - BoogieGenState.WF s → + CoreGenState.WF s → genOldExprIdents es s = (ls, s') → - BoogieGenState.WF s' := by + CoreGenState.WF s' := by intros Hwf Hgen simp [genOldExprIdents] at Hgen induction es generalizing s ls s' <;> simp at Hgen @@ -2804,9 +2804,9 @@ theorem genOldExprIdentsWFMono : exact ih HH heq' theorem genOldExprIdentsTripWFMono : - BoogieGenState.WF s → + CoreGenState.WF s → genOldExprIdentsTrip outs xs s = (Except.ok trips, s') → - BoogieGenState.WF s' := by + CoreGenState.WF s' := by intros Hwf Hgen simp [genOldExprIdentsTrip, bind, liftM,] at * simp [Functor.map, ExceptT.bind, ExceptT.bindCont, bind, @@ -3279,8 +3279,8 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : WellFormedBoogieEvalCong δ → WF.WFStatementsProp p [st] → WF.WFProgramProp p → - BoogieGenState.WF γ → - (∀ v, v ∈ γ.generated ↔ ((σ v).isSome ∧ BoogieIdent.isTemp v)) → + CoreGenState.WF γ → + (∀ v, v ∈ γ.generated ↔ ((σ v).isSome ∧ CoreIdent.isTemp v)) → (Except.ok sts, γ') = (runWith [st] (CallElim.callElimStmts · p) γ) → -- NOTE: The theorem does not expect the same store due to inserting new temp variables exists σ'', @@ -3328,10 +3328,10 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : cases Heval with | call_sem lkup Hevalargs Hevalouts Hwfval Hwfvars Hwfb Hwf2 Hwf Hinitin Hinitout Hpre Hhav1 Hhav2 Hpost Hrd Hupdate => next outVals argVals σA σAO σO σR p' modvals => - unfold BoogieIdent.unres at Hfind + unfold CoreIdent.unres at Hfind have Hsome : (Program.Procedure.find? p procName).isSome := by simp [Hfind] simp [Option.isSome] at Hsome - unfold BoogieIdent.unres at * + unfold CoreIdent.unres at * have lkup' := lkup split at Hsome <;> try contradiction next x val Hfind => @@ -3386,30 +3386,30 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : have HH := List.mem_filter.mp Hin exact HH.2 have HrdOld := isDefinedReadValues HoldDef - have Hwfgenargs : BoogieGenState.WF s_arg := genArgExprIdentsTripWFMono Hwfgen Heqarg - have Hwfgenouts : BoogieGenState.WF s_out := genOutExprIdentsTripWFMono Hwfgenargs Heqout - have Hwfgenolds : BoogieGenState.WF cs' := genOldExprIdentsTripWFMono Hwfgenouts Heqold + have Hwfgenargs : CoreGenState.WF s_arg := genArgExprIdentsTripWFMono Hwfgen Heqarg + have Hwfgenouts : CoreGenState.WF s_out := genOutExprIdentsTripWFMono Hwfgenargs Heqout + have Hwfgenolds : CoreGenState.WF cs' := genOldExprIdentsTripWFMono Hwfgenouts Heqold have Hgenargs := genArgExprIdentsTripGeneratedWF Heqarg have Hgenouts := genOutExprIdentsTripGeneratedWF Heqout have Hgenolds := genOldExprIdentsTripGeneratedWF Heqold - have HargTemp : Forall (BoogieIdent.isTemp ·) argTrips.unzip.1.unzip.1 := by - simp [BoogieGenState.WF] at Hwfgenargs + have HargTemp : Forall (CoreIdent.isTemp ·) argTrips.unzip.1.unzip.1 := by + simp [CoreGenState.WF] at Hwfgenargs have HH := List.Forall_mem_iff.mp Hwfgenargs.2.2.2 simp only [← Hgenargs] at HH refine List.Forall_mem_iff.mpr ?_ intros x Hin apply HH exact List.mem_append_left γ.generated (List.mem_reverse.mpr Hin) - have HoutTemp : Forall (BoogieIdent.isTemp ·) outTrips.unzip.1.unzip.1 := by - simp [BoogieGenState.WF] at Hwfgenouts + have HoutTemp : Forall (CoreIdent.isTemp ·) outTrips.unzip.1.unzip.1 := by + simp [CoreGenState.WF] at Hwfgenouts have HH := List.Forall_mem_iff.mp Hwfgenouts.2.2.2 simp only [← Hgenouts] at HH refine List.Forall_mem_iff.mpr ?_ intros x Hin apply HH exact List.mem_append_left s_arg.generated (List.mem_reverse.mpr Hin) - have HoldTemp : Forall (BoogieIdent.isTemp ·) oldTrips.unzip.1.unzip.1 := by - simp [BoogieGenState.WF] at Hwfgenolds + have HoldTemp : Forall (CoreIdent.isTemp ·) oldTrips.unzip.1.unzip.1 := by + simp [CoreGenState.WF] at Hwfgenolds have HH := List.Forall_mem_iff.mp Hwfgenolds.2.2.2 simp only [← Hgenolds] at HH refine List.Forall_mem_iff.mpr ?_ @@ -3426,7 +3426,7 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : argTrips.unzip.fst.unzip.fst ++ outTrips.unzip.fst.unzip.fst ++ oldTrips.unzip.fst.unzip.fst).Nodup := by - simp [BoogieGenState.WF] at Hwfgenolds + simp [CoreGenState.WF] at Hwfgenolds have Hnd := nodup_reverse Hwfgenolds.2.2.1 simp only [List.reverse_append, List.reverse_reverse, ← List.append_assoc, ← Hgenargs,← Hgenouts,← Hgenolds] at Hnd @@ -3462,14 +3462,14 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : have Hcontra := List.mem_reverse.mpr ((Hwfgenst v).mpr ⟨Hsome, Htemp⟩) simp only [List.append_assoc] at Hin Hgennd' exact (List.nodup_append.mp Hgennd').2.2 v Hcontra v Hin rfl - have Hmodglob : Forall (BoogieIdent.isGlob ·) proc.spec.modifies := by + have Hmodglob : Forall (CoreIdent.isGlob ·) proc.spec.modifies := by simp [WF.WFModsProp] at wfmod apply List.Forall_PredImplies exact wfmod intros x HH apply WFProgGlob Hwfp exact WF.WFModProp.defined HH - have Holdsndglob : Forall (BoogieIdent.isGlob ·) oldTrips.unzip.snd := by + have Holdsndglob : Forall (CoreIdent.isGlob ·) oldTrips.unzip.snd := by simp [genOldExprIdentsTrip_snd Heqold] apply List.Forall_PredImplies apply List.Forall_filter @@ -3529,15 +3529,15 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . assumption . simp [genArgExprIdentsTrip_snd Heqarg] apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . simp at HargTemp apply HargTemp . apply List.Forall_flatMap.mp apply List.Forall_PredImplies Hwfargs intros x Hp exact WF.WFargProp.glarg Hp - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . apply List.Sublist.nodup (List.sublist_append_left _ _) ?_ . exact outTrips.unzip.fst.unzip.fst apply List.Sublist.nodup (List.sublist_append_left _ _) ?_ @@ -3584,27 +3584,27 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . -- Disjoint between localGlob and Temp simp [genOutExprIdentsTrip_snd Heqout] apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isLocl ·)) . simp at HoutTemp exact HoutTemp . exact Hlhs.2 . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isLocl_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isLocl_isGlobOrLocl . simp refine ReadValuesUpdatedStates ?_ ?_ ?_ . simp [Hargtriplen] . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isLocl ·)) . simp at HargTemp exact HargTemp . simp [← Heqouts] exact Hlhs.2 . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isLocl_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isLocl_isGlobOrLocl . simp [← Heqouts] exact Hevalouts . -- out vars generated are not defined @@ -3630,22 +3630,22 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : apply filter_nodup apply eraseDups_Nodup . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlob ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlob ·)) . exact HoldTemp . simp [genOldExprIdentsTrip_snd Heqold] apply List.Forall_PredImplies . apply List.Forall_filter . exact WFProgGlob Hwfp . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isGlob_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isGlob_isGlobOrLocl . simp apply ReadValuesUpdatedStates . simp [Houttriplen] . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlob ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlob ·)) . simp at HoutTemp exact HoutTemp . simp [genOldExprIdentsTrip_snd Heqold] @@ -3653,13 +3653,13 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . apply List.Forall_filter . exact WFProgGlob Hwfp . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isGlob_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isGlob_isGlobOrLocl apply ReadValuesUpdatedStates . simp [Hargtriplen] . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlob ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlob ·)) . simp at HargTemp exact HargTemp . simp [genOldExprIdentsTrip_snd Heqold] @@ -3667,8 +3667,8 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . apply List.Forall_filter . exact WFProgGlob Hwfp . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isGlob_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isGlob_isGlobOrLocl . simp at HoldVals exact HoldVals . -- old vars generated are not defined @@ -3738,23 +3738,23 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . exact (List.Disjoint_Nodup_iff.mpr Hgennd).1 . exact Hlhs.1 . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isLocl ·)) . exact HargTemp . exact Hlhs.2 . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isLocl_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isLocl_isGlobOrLocl . apply List.Disjoint.symm apply List.Disjoint_app.mp ⟨?_, ?_⟩ . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . exact HargTemp . apply List.Forall_append.mpr ⟨?_, ?_⟩ - . exact List.Forall_PredImplies Hinlc BoogieIdent.isLocl_isGlobOrLocl - . exact List.Forall_PredImplies Houtlc BoogieIdent.isLocl_isGlobOrLocl - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact List.Forall_PredImplies Hinlc CoreIdent.isLocl_isGlobOrLocl + . exact List.Forall_PredImplies Houtlc CoreIdent.isLocl_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . intros x Hin1 Hin2 apply Hlhsdisj Hin1 simp_all @@ -3815,8 +3815,8 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : apply List.Disjoint.mono_right . exact List.removeAll_Sublist . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . apply List.Forall_append.mpr exact ⟨HoutTemp, HoldTemp⟩ . have HH := prepostconditions_unwrap Hin @@ -3829,7 +3829,7 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : have Hwf := (List.Forall_mem_iff.mp wfpre _ HH).glvars simp at Hwf exact Hwf - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . have HH := prepostconditions_unwrap Hin cases HH with | intro label HH => @@ -3839,26 +3839,26 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : | intro md HH => apply List.Disjoint_app.mp ⟨?_, ?_⟩ . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . exact HargTemp . have Hwf := (List.Forall_mem_iff.mp wfpre _ HH).glvars simp at Hwf exact Hwf - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . have Hpre := (List.Forall_mem_iff.mp wfpre _ HH) have Hlcl := List.Forall_mem_iff.mp Hpre.lvars have Hgl := List.Forall_mem_iff.mp Hpre.glvars simp at Hlcl Hgl intros x Hin1 Hin2 specialize Hgl x Hin2 - simp [BoogieIdent.isGlobOrLocl] at Hgl + simp [CoreIdent.isGlobOrLocl] at Hgl cases Hgl with | inl Hg => -- disjoint of local and global have Hlhs := List.Forall_mem_iff.mp Hlhs.2 specialize Hlhs x Hin1 - exact BoogieIdent.Disjoint_isLocl_isGlob _ Hlhs Hg + exact CoreIdent.Disjoint_isLocl_isGlob _ Hlhs Hg | inr Hl => -- disjoint because of WF specialize Hlcl x Hin2 Hl @@ -3918,13 +3918,13 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . -- length, provable simp [Hargtriplen, Houttriplen] . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isLocl ·)) . apply List.Forall_append.mpr ⟨HargTemp, HoutTemp⟩ . exact Hlhs.2 . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isLocl_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isLocl_isGlobOrLocl . exact Hevalouts . exact Hrdinout . -- Read Values @@ -3957,36 +3957,36 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . apply ReadValuesUpdatedStates . simp [Holdtriplen] . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isLocl ·)) . simp at HoldTemp exact HoldTemp . exact Hlhs.2 . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isLocl_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isLocl_isGlobOrLocl . apply ReadValuesUpdatedStates . simp [Houttriplen] . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isLocl ·)) . simp at HoutTemp exact HoutTemp . exact Hlhs.2 . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isLocl_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isLocl_isGlobOrLocl . apply ReadValuesUpdatedStates . simp [Hargtriplen] . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isLocl ·)) . simp at HargTemp exact HargTemp . exact Hlhs.2 . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isLocl_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isLocl_isGlobOrLocl . exact Hevalouts . -- Prove havocs correct simp [← createHavocsApp] @@ -4046,23 +4046,23 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . exact (List.nodup_append.mp HH.1).1 . exact Hlhs.1 . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isLocl ·)) . exact HargTemp . exact Hlhs.2 . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isLocl_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isLocl_isGlobOrLocl . apply List.Disjoint.symm apply List.Disjoint_app.mp ⟨?_, ?_⟩ . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . exact HargTemp . apply List.Forall_append.mpr ⟨?_, ?_⟩ - . exact List.Forall_PredImplies Hinlc BoogieIdent.isLocl_isGlobOrLocl - . exact List.Forall_PredImplies Houtlc BoogieIdent.isLocl_isGlobOrLocl - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact List.Forall_PredImplies Hinlc CoreIdent.isLocl_isGlobOrLocl + . exact List.Forall_PredImplies Houtlc CoreIdent.isLocl_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . intros x Hin1 Hin2 apply Hlhsdisj Hin1 simp_all @@ -4115,11 +4115,11 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : refine List.Disjoint_Nodup_iff.mp ⟨Houtnd, Hmodsnd, ?_⟩ -- disjoint between local and global apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isLocl ·)) - (Q:=(BoogieIdent.isGlob ·)) + (P:=(CoreIdent.isLocl ·)) + (Q:=(CoreIdent.isGlob ·)) . exact Houtlc . exact Hmodglob - . exact BoogieIdent.Disjoint_isLocl_isGlob + . exact CoreIdent.Disjoint_isLocl_isGlob have Hrd1 := UpdateStatesReadValues Houtnd Hup1 have Hrd2 := UpdateStatesReadValues Hmodsnd Hup2 have Heq2 := ReadValuesInjective Hrd2 Hrd'.2.2 @@ -4209,13 +4209,13 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : intros x Hin1 Hin2 have Hdisj : oldTrips.unzip.fst.unzip.fst.Disjoint oldTrips.unzip.snd := by apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlob ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlob ·)) . simp; exact HoldTemp . simp; exact Holdsndglob . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isGlob_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isGlob_isGlobOrLocl have Hsubset := substsOldPostSubset (post:=(OldExpressions.normalizeOldExpr post)) (oldTrips:=oldTrips) Hdisj have Hin : x ∈ (Imperative.HasVarsPure.getVars (P:=Expression) (OldExpressions.normalizeOldExpr post) ++ oldTrips.unzip.fst.unzip.fst) := by @@ -4230,13 +4230,13 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : -- disjoint of global/local with temp have Hin := normalizeOldExprInVars Hin specialize Hgl x Hin - apply BoogieIdent.Disjoint_isTemp_isGlobOrLocl + apply CoreIdent.Disjoint_isTemp_isGlobOrLocl . exact List.Forall_mem_iff.mp HargTemp x Hin1 . exact Hgl | inr Hin => -- disjoint among temp simp only [List.unzip_fst, List.map_map] at Hin - simp [BoogieIdent.isGlobOrLocl] at Hgl + simp [CoreIdent.isGlobOrLocl] at Hgl have HH := (List.nodup_append.mp Hgennd).2.2 apply HH x Hin1 x apply List.mem_append.mpr @@ -4248,13 +4248,13 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : have Hin := normalizeOldExprInVars Hin specialize Hgl x Hin -- x is either global or local - simp [BoogieIdent.isGlobOrLocl] at Hgl + simp [CoreIdent.isGlobOrLocl] at Hgl cases Hgl with | inl Hg => -- x is global have Hlhs := List.Forall_mem_iff.mp Hlhs.2 specialize Hlhs x Hin1 - exact BoogieIdent.Disjoint_isLocl_isGlob _ Hlhs Hg + exact CoreIdent.Disjoint_isLocl_isGlob _ Hlhs Hg | inr Hl => -- x is local, use wf specialize Hlcl x Hin Hl @@ -4263,9 +4263,9 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : | inr Hin => -- oldTrips disjoint from lhs simp only [List.unzip_fst, List.map_map] at Hin - apply BoogieIdent.Disjoint_isTemp_isGlobOrLocl + apply CoreIdent.Disjoint_isTemp_isGlobOrLocl . exact List.Forall_mem_iff.mp HoldTemp x Hin - . apply BoogieIdent.isLocl_isGlobOrLocl + . apply CoreIdent.isLocl_isGlobOrLocl exact List.Forall_mem_iff.mp Hlhs.2 _ Hin1 . -- post condition correct have Hmem := SubstPostsMem HinSubst @@ -4311,22 +4311,22 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . -- Disjoint between local and temp apply List.Disjoint.symm apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . exact List.Forall_append.mpr ⟨HoutTemp, HoldTemp⟩ - . exact List.Forall_PredImplies Houtlc BoogieIdent.isLocl_isGlobOrLocl - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact List.Forall_PredImplies Houtlc CoreIdent.isLocl_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . simp [Houtlen] . simp [InitStatesUpdated Hinitin] apply UpdatedStatesDisjNotDefMonotone . -- Disjoint between local and temp apply List.Disjoint.symm apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . exact List.Forall_append.mpr ⟨HoutTemp, HoldTemp⟩ - . exact List.Forall_PredImplies Hinlc BoogieIdent.isLocl_isGlobOrLocl - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact List.Forall_PredImplies Hinlc CoreIdent.isLocl_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . simp [← Hargtriplen, Harglen, ← Heqargs] . have Hndef := (Imperative.isNotDefinedApp' Hndefgen).2 exact UpdateStatesNotDefMonotone' Hndef Hupdate @@ -4363,14 +4363,14 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . -- Disjoint between local and temp apply List.Disjoint.symm apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isLocl ·)) - (Q:=(BoogieIdent.isGlob ·)) + (P:=(CoreIdent.isLocl ·)) + (Q:=(CoreIdent.isGlob ·)) . exact Houtlc . simp [genOldExprIdentsTrip_snd Heqold] apply List.Forall_PredImplies . apply List.Forall_filter . exact WFProgGlob Hwfp - . exact BoogieIdent.Disjoint_isLocl_isGlob + . exact CoreIdent.Disjoint_isLocl_isGlob . apply InitStatesReadValuesMonotone (σ:=σA) ?_ Hinitout . apply InitStatesReadValuesMonotone (σ:=σ) ?_ Hinitin simp only [List.unzip_snd] @@ -4410,21 +4410,21 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . exact (List.nodup_append.mp (List.nodup_append.mp Hgennd).2.1).2.1 . apply List.Disjoint.symm apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlob ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlob ·)) . exact HoldTemp . simp [genOldExprIdentsTrip_snd Heqold] apply List.Forall_PredImplies . apply List.Forall_filter . exact WFProgGlob Hwfp . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isGlob_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isGlob_isGlobOrLocl . simp [Holdtriplen] . apply List.Disjoint_Subset_right (ks:=(Imperative.HasVarsPure.getVars post)) . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . simp exact HoldTemp . have HH := prepostconditions_unwrap Hin.1 @@ -4437,7 +4437,7 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : have Hwf := (List.Forall_mem_iff.mp wfpost _ HH).glvars simp at Hwf exact Hwf - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . refine extractedOldVarsInVars ?_ have HH := prepostconditions_unwrap Hin.1 cases HH with @@ -4455,8 +4455,8 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . simp [Holdtriplen] . exact (List.nodup_append.mp (List.nodup_append.mp Hgennd).2.1).2.1 . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . exact HoldTemp . have HH := prepostconditions_unwrap Hin.1 cases HH with @@ -4468,13 +4468,13 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : have Hwf := (List.Forall_mem_iff.mp wfpost _ HH).glvars simp at Hwf exact Hwf - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl apply EvalExpressionUpdatedStates <;> try assumption . simp [Houttriplen] . exact (List.nodup_append.mp (List.nodup_append.mp Hgennd).2.1).1 . apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . exact HoutTemp . have HH := prepostconditions_unwrap Hin.1 cases HH with @@ -4486,7 +4486,7 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : have Hwf := (List.Forall_mem_iff.mp wfpost _ HH).glvars simp at Hwf exact Hwf - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl exact Hpost.2 . -- substStores, provable apply ReadValuesSubstStores (vs:=argVals ++ v1) @@ -4502,11 +4502,11 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . exact Hmodsnd . -- Disjoint between local and temp apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isLocl ·)) - (Q:=(BoogieIdent.isGlob ·)) + (P:=(CoreIdent.isLocl ·)) + (Q:=(CoreIdent.isGlob ·)) . exact Hinlc . exact Hmodglob - . exact BoogieIdent.Disjoint_isLocl_isGlob + . exact CoreIdent.Disjoint_isLocl_isGlob . apply UpdateStatesReadValuesMonotone (σ:=σAO) _ ?_ Hup1 . exact Hinoutnd . apply InitStatesReadValuesMonotone (σ:=σA) _ Hinitout @@ -4525,22 +4525,22 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . -- Disjoint between local and temp apply List.Disjoint.symm apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . exact List.Forall_append.mpr ⟨HoutTemp, HoldTemp⟩ - . refine List.Forall_PredImplies Houtlc BoogieIdent.isLocl_isGlobOrLocl - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . refine List.Forall_PredImplies Houtlc CoreIdent.isLocl_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . simp [Houtlen] . simp [InitStatesUpdated Hinitin] apply UpdatedStatesDisjNotDefMonotone . -- Disjoint between local and temp apply List.Disjoint.symm apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . exact List.Forall_append.mpr ⟨HoutTemp, HoldTemp⟩ - . refine List.Forall_PredImplies Hinlc BoogieIdent.isLocl_isGlobOrLocl - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . refine List.Forall_PredImplies Hinlc CoreIdent.isLocl_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . simp [← Hargtriplen, Harglen, ← Heqargs] . have Hndef := (Imperative.isNotDefinedApp' Hndefgen).2 exact UpdateStatesNotDefMonotone' Hndef Hupdate @@ -4551,20 +4551,20 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . simp [Holdtriplen] . -- Disjoint between local and temp apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . exact HoldTemp - . refine List.Forall_PredImplies Houtlc BoogieIdent.isLocl_isGlobOrLocl - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . refine List.Forall_PredImplies Houtlc CoreIdent.isLocl_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . apply ReadValuesUpdatedStates . simp [Houttriplen] . -- Disjoint between local and temp apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . exact HoutTemp - . refine List.Forall_PredImplies Houtlc BoogieIdent.isLocl_isGlobOrLocl - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . refine List.Forall_PredImplies Houtlc CoreIdent.isLocl_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . exact Hrd'.2.1 . apply ReadValuesApp . apply ReadValuesUpdatedStates @@ -4585,35 +4585,35 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . simp [Holdtriplen] . -- Disjoint between local and temp apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isLocl ·)) . exact HoldTemp . exact Hlhs.2 . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isLocl_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isLocl_isGlobOrLocl . apply ReadValuesUpdatedStates . simp [Houttriplen] . -- Disjoint between local and temp apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isLocl ·)) . exact HoutTemp . exact Hlhs.2 . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isLocl_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isLocl_isGlobOrLocl . apply ReadValuesUpdatedStates . simp [Hargtriplen] . -- Disjoint between local and temp apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isLocl ·)) . exact HargTemp . exact Hlhs.2 . apply List.PredDisjoint_PredImplies_right - exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl - exact BoogieIdent.isLocl_isGlobOrLocl + exact CoreIdent.Disjoint_isTemp_isGlobOrLocl + exact CoreIdent.isLocl_isGlobOrLocl . apply ReadValuesUpdatedStates . exact ReadValuesLength Hrd'.2.2 . intros x Hin1 Hin2 @@ -4641,14 +4641,14 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : rw [List.map_fst_zip] . -- Disjoint between old labels and lhs, modified, and modvals apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . simp at HargTemp exact HargTemp . apply List.Forall_append.mpr ⟨?_, ?_⟩ - . exact List.Forall_PredImplies Hlhs.2 BoogieIdent.isLocl_isGlobOrLocl - . exact List.Forall_PredImplies Hmodglob BoogieIdent.isGlob_isGlobOrLocl - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact List.Forall_PredImplies Hlhs.2 CoreIdent.isLocl_isGlobOrLocl + . exact List.Forall_PredImplies Hmodglob CoreIdent.isGlob_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . simp_all . simp_all . -- Disjoint between old labels and lhs, modified, and modvals @@ -4656,14 +4656,14 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : rw [List.map_fst_zip] rw [List.map_fst_zip (l₂:=modvals)] apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . simp at HoutTemp exact HoutTemp . apply List.Forall_append.mpr ⟨?_, ?_⟩ - . exact List.Forall_PredImplies Hlhs.2 BoogieIdent.isLocl_isGlobOrLocl - . exact List.Forall_PredImplies Hmodglob BoogieIdent.isGlob_isGlobOrLocl - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact List.Forall_PredImplies Hlhs.2 CoreIdent.isLocl_isGlobOrLocl + . exact List.Forall_PredImplies Hmodglob CoreIdent.isGlob_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . have Hlen := UpdateStatesLength Hupdate omega . simp_all @@ -4672,14 +4672,14 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : rw [List.map_fst_zip] rw [List.map_fst_zip (l₂:=modvals)] apply List.PredDisjoint_Disjoint - (P:=(BoogieIdent.isTemp ·)) - (Q:=(BoogieIdent.isGlobOrLocl ·)) + (P:=(CoreIdent.isTemp ·)) + (Q:=(CoreIdent.isGlobOrLocl ·)) . simp at HoldTemp exact HoldTemp . apply List.Forall_append.mpr ⟨?_, ?_⟩ - . exact List.Forall_PredImplies Hlhs.2 BoogieIdent.isLocl_isGlobOrLocl - . exact List.Forall_PredImplies Hmodglob BoogieIdent.isGlob_isGlobOrLocl - . exact BoogieIdent.Disjoint_isTemp_isGlobOrLocl + . exact List.Forall_PredImplies Hlhs.2 CoreIdent.isLocl_isGlobOrLocl + . exact List.Forall_PredImplies Hmodglob CoreIdent.isGlob_isGlobOrLocl + . exact CoreIdent.Disjoint_isTemp_isGlobOrLocl . have Hlen := UpdateStatesLength Hupdate omega . simp_all diff --git a/Strata/Transform/CoreTransform.lean b/Strata/Transform/CoreTransform.lean index 6a9cdd986..e4c1cdf96 100644 --- a/Strata/Transform/CoreTransform.lean +++ b/Strata/Transform/CoreTransform.lean @@ -5,8 +5,8 @@ -/ import Strata.Languages.Core.Statement -import Strata.Languages.Core.Boogie -import Strata.Languages.Core.BoogieGen +import Strata.Languages.Core.Core +import Strata.Languages.Core.CoreGen import Strata.DL.Util.LabelGen /-! # Utility functions for program transformation in Strata Core -/ @@ -35,7 +35,7 @@ def createFvars (ident : List Expression.Ident) def genIdent (ident : Expression.Ident) (pf : String → String) : BoogieGenM Expression.Ident := - BoogieGenState.gen (pf ident.name) + CoreGenState.gen (pf ident.name) /-- Generate identifiers in the form of arg_... that can be used to reduce argument expressions to temporary variables. @@ -252,13 +252,13 @@ def runProgram (f : Command → Program → CoreTransformM (List Statement)) @[simp] def runWith {α : Type} (p : α) (f : α → CoreTransformM β) - (s : BoogieGenState): - Except Err β × BoogieGenState := + (s : CoreGenState): + Except Err β × CoreGenState := (StateT.run (f p) s) @[simp] def run {α : Type} (p : α) (f : α → CoreTransformM β) - (s : BoogieGenState := .emp): + (s : CoreGenState := .emp): Except Err β := (runWith p f s).fst diff --git a/Strata/Transform/ProcedureInlining.lean b/Strata/Transform/ProcedureInlining.lean index c5c2ff9b2..8f40ca343 100644 --- a/Strata/Transform/ProcedureInlining.lean +++ b/Strata/Transform/ProcedureInlining.lean @@ -6,8 +6,8 @@ import Strata.DL.Util.LabelGen import Strata.DL.Util.ListUtils -import Strata.Languages.Core.Boogie -import Strata.Languages.Core.BoogieGen +import Strata.Languages.Core.Core +import Strata.Languages.Core.CoreGen import Strata.Languages.Core.ProgramWF import Strata.Languages.Core.Statement import Strata.Transform.CoreTransform diff --git a/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean b/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean index 715708d00..c15973edf 100644 --- a/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean +++ b/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean @@ -97,17 +97,17 @@ def Boogie.Cmd.renameVars (frto : Map String String) (c : Imperative.Cmd Core.Ex match c with | .init name ty e _ => let e' := substVarNames e frto - let name_alt := frto.find? (Core.BoogieIdent.toPretty name) - let new := name_alt.getD (Core.BoogieIdent.toPretty name) + let name_alt := frto.find? (Core.CoreIdent.toPretty name) + let new := name_alt.getD (Core.CoreIdent.toPretty name) .init new ty e' .empty | .set name e _ => let e' := substVarNames e frto - let name_alt := frto.find? (Core.BoogieIdent.toPretty name) - let new := name_alt.getD (Core.BoogieIdent.toPretty name) + let name_alt := frto.find? (Core.CoreIdent.toPretty name) + let new := name_alt.getD (Core.CoreIdent.toPretty name) .set new e' .empty | .havoc name _ => - let name_alt := frto.find? (Core.BoogieIdent.toPretty name) - let new := name_alt.getD (Core.BoogieIdent.toPretty name) + let name_alt := frto.find? (Core.CoreIdent.toPretty name) + let new := name_alt.getD (Core.CoreIdent.toPretty name) .havoc new .empty | .assume label e _ => let e' := substVarNames e frto @@ -166,7 +166,7 @@ def transformToGoto (boogie : Core.Program) : Except Format CProverGOTO.Context | none => .error f!"[transformToGoto] We can process only Strata Core procedures at this time. \ Declaration encountered: {decl}" | some p => - let pname := Core.BoogieIdent.toPretty p.header.name + let pname := Core.CoreIdent.toPretty p.header.name if !p.header.typeArgs.isEmpty then .error f!"[transformToGoto] Translation for polymorphic Boogie procedures is unimplemented." @@ -182,13 +182,13 @@ def transformToGoto (boogie : Core.Program) : Except Format CProverGOTO.Context let ret_tys ← p.header.outputs.values.mapM (fun ty => Lambda.LMonoTy.toGotoType ty) let ret_ty := if ret_tys.isEmpty then CProverGOTO.Ty.Empty else ret_tys[0]! - let formals := p.header.inputs.keys.map Core.BoogieIdent.toPretty + let formals := p.header.inputs.keys.map Core.CoreIdent.toPretty let formals_tys ← p.header.inputs.values.mapM (fun ty => Lambda.LMonoTy.toGotoType ty) let new_formals := formals.map (fun f => CProverGOTO.mkFormalSymbol pname f) let formals_renamed := formals.zip new_formals let formals_tys : Map String CProverGOTO.Ty := formals.zip formals_tys - let locals := (Imperative.Block.definedVars p.body).map Core.BoogieIdent.toPretty + let locals := (Imperative.Block.definedVars p.body).map Core.CoreIdent.toPretty let new_locals := locals.map (fun l => CProverGOTO.mkLocalSymbol pname l) let locals_renamed := locals.zip new_locals @@ -204,7 +204,7 @@ def transformToGoto (boogie : Core.Program) : Except Format CProverGOTO.Context { type := .END_FUNCTION, locationNum := ans.nextLoc + 1}] let insts := ans.instructions ++ ending_insts - let pgm := { name := Core.BoogieIdent.toPretty p.header.name, + let pgm := { name := Core.CoreIdent.toPretty p.header.name, parameterIdentifiers := new_formals.toArray, instructions := insts } diff --git a/StrataTest/Internal/InternalFunctionSignatures.lean b/StrataTest/Internal/InternalFunctionSignatures.lean index 30183d033..ba6b1409c 100644 --- a/StrataTest/Internal/InternalFunctionSignatures.lean +++ b/StrataTest/Internal/InternalFunctionSignatures.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Core import Strata.Languages.Python.FunctionSignatures namespace Strata diff --git a/StrataTest/Languages/Core/DatatypeVerificationTests.lean b/StrataTest/Languages/Core/DatatypeVerificationTests.lean index 13ddcd229..320750f3c 100644 --- a/StrataTest/Languages/Core/DatatypeVerificationTests.lean +++ b/StrataTest/Languages/Core/DatatypeVerificationTests.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Core import Strata.Languages.Core.Verifier import Strata.DL.Lambda.TypeFactory @@ -85,7 +85,7 @@ def mkProgramWithDatatypes : Except Format Program := do let proc : Procedure := { header := { - name := BoogieIdent.unres procName + name := CoreIdent.unres procName typeArgs := [] inputs := [] outputs := [] @@ -137,13 +137,13 @@ procedure testConstructors () { def test1_constructorApplication : IO String := do let statements : List Statement := [ -- Create None value - Statement.init (BoogieIdent.unres "x") (.forAll [] (LMonoTy.tcons "Option" [.int])) - (LExpr.op () (BoogieIdent.unres "None") (.some (LMonoTy.tcons "Option" [.int]))), + Statement.init (CoreIdent.unres "x") (.forAll [] (LMonoTy.tcons "Option" [.int])) + (LExpr.op () (CoreIdent.unres "None") (.some (LMonoTy.tcons "Option" [.int]))), -- Create Some value - Statement.init (BoogieIdent.unres "y") (.forAll [] (LMonoTy.tcons "Option" [.int])) + Statement.init (CoreIdent.unres "y") (.forAll [] (LMonoTy.tcons "Option" [.int])) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "Some") + (LExpr.op () (CoreIdent.unres "Some") (.some (LMonoTy.arrow .int (LMonoTy.tcons "Option" [.int])))) (LExpr.intConst () 42)), @@ -175,29 +175,29 @@ procedure testTesters () { def test2_testerFunctions : IO String := do let statements : List Statement := [ -- Create None value - Statement.init (BoogieIdent.unres "x") (.forAll [] (LMonoTy.tcons "Option" [.int])) - (LExpr.op () (BoogieIdent.unres "None") (.some (LMonoTy.tcons "Option" [.int]))), + Statement.init (CoreIdent.unres "x") (.forAll [] (LMonoTy.tcons "Option" [.int])) + (LExpr.op () (CoreIdent.unres "None") (.some (LMonoTy.tcons "Option" [.int]))), -- Assert that x is None Statement.assert "x_is_none" (LExpr.app () - (LExpr.op () (BoogieIdent.unres "isNone") + (LExpr.op () (CoreIdent.unres "isNone") (.some (LMonoTy.arrow (LMonoTy.tcons "Option" [.int]) .bool))) - (LExpr.fvar () (BoogieIdent.unres "x") (.some (LMonoTy.tcons "Option" [.int])))), + (LExpr.fvar () (CoreIdent.unres "x") (.some (LMonoTy.tcons "Option" [.int])))), -- Create Some value - Statement.init (BoogieIdent.unres "y") (.forAll [] (LMonoTy.tcons "Option" [.int])) + Statement.init (CoreIdent.unres "y") (.forAll [] (LMonoTy.tcons "Option" [.int])) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "Some") + (LExpr.op () (CoreIdent.unres "Some") (.some (LMonoTy.arrow .int (LMonoTy.tcons "Option" [.int])))) (LExpr.intConst () 42)), -- Assert that y is Some Statement.assert "y_is_some" (LExpr.app () - (LExpr.op () (BoogieIdent.unres "isSome") + (LExpr.op () (CoreIdent.unres "isSome") (.some (LMonoTy.arrow (LMonoTy.tcons "Option" [.int]) .bool))) - (LExpr.fvar () (BoogieIdent.unres "y") (.some (LMonoTy.tcons "Option" [.int])))) + (LExpr.fvar () (CoreIdent.unres "y") (.some (LMonoTy.tcons "Option" [.int])))) ] match mkProgramWithDatatypes [optionDatatype] "testTesters" statements with @@ -228,45 +228,45 @@ procedure testDestructors () { def test3_destructorFunctions : IO String := do let statements : List Statement := [ -- Create Some(42) - Statement.init (BoogieIdent.unres "opt") (.forAll [] (LMonoTy.tcons "Option" [.int])) + Statement.init (CoreIdent.unres "opt") (.forAll [] (LMonoTy.tcons "Option" [.int])) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "Some") + (LExpr.op () (CoreIdent.unres "Some") (.some (LMonoTy.arrow .int (LMonoTy.tcons "Option" [.int])))) (LExpr.intConst () 42)), -- Extract value from Some - Statement.init (BoogieIdent.unres "value") (.forAll [] LMonoTy.int) + Statement.init (CoreIdent.unres "value") (.forAll [] LMonoTy.int) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "OptionVal") + (LExpr.op () (CoreIdent.unres "OptionVal") (.some (LMonoTy.arrow (LMonoTy.tcons "Option" [.int]) .int))) - (LExpr.fvar () (BoogieIdent.unres "opt") (.some (LMonoTy.tcons "Option" [.int])))), + (LExpr.fvar () (CoreIdent.unres "opt") (.some (LMonoTy.tcons "Option" [.int])))), -- Assert that val == 42 Statement.assert "val_is_42" (LExpr.eq () - (LExpr.fvar () (BoogieIdent.unres "value") (.some .int)) + (LExpr.fvar () (CoreIdent.unres "value") (.some .int)) (LExpr.intConst () 42)), -- Create Cons(1, Nil) - Statement.init (BoogieIdent.unres "list") (.forAll [] (LMonoTy.tcons "List" [.int])) + Statement.init (CoreIdent.unres "list") (.forAll [] (LMonoTy.tcons "List" [.int])) (LExpr.app () (LExpr.app () - (LExpr.op () (BoogieIdent.unres "Cons") + (LExpr.op () (CoreIdent.unres "Cons") (.some (LMonoTy.arrow .int (LMonoTy.arrow (LMonoTy.tcons "List" [.int]) (LMonoTy.tcons "List" [.int]))))) (LExpr.intConst () 1)) - (LExpr.op () (BoogieIdent.unres "Nil") (.some (LMonoTy.tcons "List" [.int])))), + (LExpr.op () (CoreIdent.unres "Nil") (.some (LMonoTy.tcons "List" [.int])))), -- Extract head - Statement.init (BoogieIdent.unres "head") (.forAll [] LMonoTy.int) + Statement.init (CoreIdent.unres "head") (.forAll [] LMonoTy.int) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "hd") + (LExpr.op () (CoreIdent.unres "hd") (.some (LMonoTy.arrow (LMonoTy.tcons "List" [.int]) .int))) - (LExpr.fvar () (BoogieIdent.unres "list") (.some (LMonoTy.tcons "List" [.int])))), + (LExpr.fvar () (CoreIdent.unres "list") (.some (LMonoTy.tcons "List" [.int])))), -- Assert head == 1 Statement.assert "head_is_1" (LExpr.eq () - (LExpr.fvar () (BoogieIdent.unres "head") (.some .int)) + (LExpr.fvar () (CoreIdent.unres "head") (.some .int)) (LExpr.intConst () 1)) ] @@ -296,49 +296,49 @@ procedure testNested () { def test4_nestedDatatypes : IO String := do let statements : List Statement := [ -- Create a List of Option: Cons(Some(42), Nil) - Statement.init (BoogieIdent.unres "listOfOpt") + Statement.init (CoreIdent.unres "listOfOpt") (.forAll [] (LMonoTy.tcons "List" [LMonoTy.tcons "Option" [.int]])) (LExpr.app () (LExpr.app () - (LExpr.op () (BoogieIdent.unres "Cons") + (LExpr.op () (CoreIdent.unres "Cons") (.some (LMonoTy.arrow (LMonoTy.tcons "Option" [.int]) (LMonoTy.arrow (LMonoTy.tcons "List" [LMonoTy.tcons "Option" [.int]]) (LMonoTy.tcons "List" [LMonoTy.tcons "Option" [.int]]))))) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "Some") + (LExpr.op () (CoreIdent.unres "Some") (.some (LMonoTy.arrow .int (LMonoTy.tcons "Option" [.int])))) (LExpr.intConst () 42))) - (LExpr.op () (BoogieIdent.unres "Nil") + (LExpr.op () (CoreIdent.unres "Nil") (.some (LMonoTy.tcons "List" [LMonoTy.tcons "Option" [.int]])))), -- Assert that the list is Cons Statement.assert "list_is_cons" (LExpr.app () - (LExpr.op () (BoogieIdent.unres "isCons") + (LExpr.op () (CoreIdent.unres "isCons") (.some (LMonoTy.arrow (LMonoTy.tcons "List" [LMonoTy.tcons "Option" [.int]]) .bool))) - (LExpr.fvar () (BoogieIdent.unres "listOfOpt") + (LExpr.fvar () (CoreIdent.unres "listOfOpt") (.some (LMonoTy.tcons "List" [LMonoTy.tcons "Option" [.int]])))), -- Extract the head of the list (which is an Option) - Statement.init (BoogieIdent.unres "headOpt") (.forAll [] (LMonoTy.tcons "Option" [.int])) + Statement.init (CoreIdent.unres "headOpt") (.forAll [] (LMonoTy.tcons "Option" [.int])) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "hd") + (LExpr.op () (CoreIdent.unres "hd") (.some (LMonoTy.arrow (LMonoTy.tcons "List" [LMonoTy.tcons "Option" [.int]]) (LMonoTy.tcons "Option" [.int])))) - (LExpr.fvar () (BoogieIdent.unres "listOfOpt") + (LExpr.fvar () (CoreIdent.unres "listOfOpt") (.some (LMonoTy.tcons "List" [LMonoTy.tcons "Option" [.int]])))), -- Extract the value from the Option - Statement.init (BoogieIdent.unres "value") (.forAll [] LMonoTy.int) + Statement.init (CoreIdent.unres "value") (.forAll [] LMonoTy.int) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "OptionVal") + (LExpr.op () (CoreIdent.unres "OptionVal") (.some (LMonoTy.arrow (LMonoTy.tcons "Option" [.int]) .int))) - (LExpr.fvar () (BoogieIdent.unres "headOpt") + (LExpr.fvar () (CoreIdent.unres "headOpt") (.some (LMonoTy.tcons "Option" [.int])))), -- Assert that the extracted value is 42 Statement.assert "value_is_42" (LExpr.eq () - (LExpr.fvar () (BoogieIdent.unres "value") (.some .int)) + (LExpr.fvar () (CoreIdent.unres "value") (.some .int)) (LExpr.intConst () 42)) ] @@ -367,26 +367,26 @@ procedure testTesterHavoc () { def test5_testerWithHavoc : IO String := do let statements : List Statement := [ -- Havoc an Option value (non-deterministic) - Statement.init (BoogieIdent.unres "x") (.forAll [] (LMonoTy.tcons "Option" [.int])) - (LExpr.op () (BoogieIdent.unres "None") (.some (LMonoTy.tcons "Option" [.int]))), - Statement.havoc (BoogieIdent.unres "x"), + Statement.init (CoreIdent.unres "x") (.forAll [] (LMonoTy.tcons "Option" [.int])) + (LExpr.op () (CoreIdent.unres "None") (.some (LMonoTy.tcons "Option" [.int]))), + Statement.havoc (CoreIdent.unres "x"), -- Assume x is Some Statement.assume "x_is_some" (LExpr.app () - (LExpr.op () (BoogieIdent.unres "isSome") + (LExpr.op () (CoreIdent.unres "isSome") (.some (LMonoTy.arrow (LMonoTy.tcons "Option" [.int]) .bool))) - (LExpr.fvar () (BoogieIdent.unres "x") (.some (LMonoTy.tcons "Option" [.int])))), + (LExpr.fvar () (CoreIdent.unres "x") (.some (LMonoTy.tcons "Option" [.int])))), -- Assert x is not None (should follow from assumption) Statement.assert "x_not_none" (LExpr.app () - (LExpr.op () (BoogieIdent.unres "Bool.Not") + (LExpr.op () (CoreIdent.unres "Bool.Not") (.some (LMonoTy.arrow .bool .bool))) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "isNone") + (LExpr.op () (CoreIdent.unres "isNone") (.some (LMonoTy.arrow (LMonoTy.tcons "Option" [.int]) .bool))) - (LExpr.fvar () (BoogieIdent.unres "x") (.some (LMonoTy.tcons "Option" [.int]))))) + (LExpr.fvar () (CoreIdent.unres "x") (.some (LMonoTy.tcons "Option" [.int]))))) ] match mkProgramWithDatatypes [optionDatatype] "testTesterHavoc" statements with @@ -414,33 +414,33 @@ procedure testDestructorHavoc () { def test6_destructorWithHavoc : IO String := do let statements : List Statement := [ -- Havoc an Option value - Statement.init (BoogieIdent.unres "opt") (.forAll [] (LMonoTy.tcons "Option" [.int])) + Statement.init (CoreIdent.unres "opt") (.forAll [] (LMonoTy.tcons "Option" [.int])) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "Some") + (LExpr.op () (CoreIdent.unres "Some") (.some (LMonoTy.arrow .int (LMonoTy.tcons "Option" [.int])))) (LExpr.intConst () 0)), - Statement.havoc (BoogieIdent.unres "opt"), + Statement.havoc (CoreIdent.unres "opt"), -- Assume opt is Some(42) Statement.assume "opt_is_some_42" (LExpr.eq () - (LExpr.fvar () (BoogieIdent.unres "opt") (.some (LMonoTy.tcons "Option" [.int]))) + (LExpr.fvar () (CoreIdent.unres "opt") (.some (LMonoTy.tcons "Option" [.int]))) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "Some") + (LExpr.op () (CoreIdent.unres "Some") (.some (LMonoTy.arrow .int (LMonoTy.tcons "Option" [.int])))) (LExpr.intConst () 42))), -- Extract value - Statement.init (BoogieIdent.unres "value") (.forAll [] LMonoTy.int) + Statement.init (CoreIdent.unres "value") (.forAll [] LMonoTy.int) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "OptionVal") + (LExpr.op () (CoreIdent.unres "OptionVal") (.some (LMonoTy.arrow (LMonoTy.tcons "Option" [.int]) .int))) - (LExpr.fvar () (BoogieIdent.unres "opt") (.some (LMonoTy.tcons "Option" [.int])))), + (LExpr.fvar () (CoreIdent.unres "opt") (.some (LMonoTy.tcons "Option" [.int])))), -- Assert val == 42 Statement.assert "val_is_42" (LExpr.eq () - (LExpr.fvar () (BoogieIdent.unres "value") (.some .int)) + (LExpr.fvar () (CoreIdent.unres "value") (.some .int)) (LExpr.intConst () 42)) ] @@ -468,26 +468,26 @@ procedure testListHavoc () { def test7_listWithHavoc : IO String := do let statements : List Statement := [ -- Havoc a list - Statement.init (BoogieIdent.unres "xs") (.forAll [] (LMonoTy.tcons "List" [.int])) - (LExpr.op () (BoogieIdent.unres "Nil") (.some (LMonoTy.tcons "List" [.int]))), - Statement.havoc (BoogieIdent.unres "xs"), + Statement.init (CoreIdent.unres "xs") (.forAll [] (LMonoTy.tcons "List" [.int])) + (LExpr.op () (CoreIdent.unres "Nil") (.some (LMonoTy.tcons "List" [.int]))), + Statement.havoc (CoreIdent.unres "xs"), -- Assume xs is Cons Statement.assume "xs_is_cons" (LExpr.app () - (LExpr.op () (BoogieIdent.unres "isCons") + (LExpr.op () (CoreIdent.unres "isCons") (.some (LMonoTy.arrow (LMonoTy.tcons "List" [.int]) .bool))) - (LExpr.fvar () (BoogieIdent.unres "xs") (.some (LMonoTy.tcons "List" [.int])))), + (LExpr.fvar () (CoreIdent.unres "xs") (.some (LMonoTy.tcons "List" [.int])))), -- Assert xs is not Nil Statement.assert "xs_not_nil" (LExpr.app () - (LExpr.op () (BoogieIdent.unres "Bool.Not") + (LExpr.op () (CoreIdent.unres "Bool.Not") (.some (LMonoTy.arrow .bool .bool))) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "isNil") + (LExpr.op () (CoreIdent.unres "isNil") (.some (LMonoTy.arrow (LMonoTy.tcons "List" [.int]) .bool))) - (LExpr.fvar () (BoogieIdent.unres "xs") (.some (LMonoTy.tcons "List" [.int]))))) + (LExpr.fvar () (CoreIdent.unres "xs") (.some (LMonoTy.tcons "List" [.int]))))) ] match mkProgramWithDatatypes [listDatatype] "testListHavoc" statements with @@ -519,42 +519,42 @@ procedure testHiddenTypeRecursion () { def test8_hiddenTypeRecursion : IO String := do let statements : List Statement := [ -- Initialize with Empty Container - note we NEVER use Hidden directly - Statement.init (BoogieIdent.unres "container") + Statement.init (CoreIdent.unres "container") (.forAll [] (LMonoTy.tcons "Container" [.int])) - (LExpr.op () (BoogieIdent.unres "Empty") (.some (LMonoTy.tcons "Container" [.int]))), + (LExpr.op () (CoreIdent.unres "Empty") (.some (LMonoTy.tcons "Container" [.int]))), -- Havoc the container to make it non-deterministic - Statement.havoc (BoogieIdent.unres "container"), + Statement.havoc (CoreIdent.unres "container"), -- Assume container is not Empty (so it must be WithHidden) Statement.assume "container_not_empty" (LExpr.app () - (LExpr.op () (BoogieIdent.unres "Bool.Not") + (LExpr.op () (CoreIdent.unres "Bool.Not") (.some (LMonoTy.arrow .bool .bool))) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "isEmpty") + (LExpr.op () (CoreIdent.unres "isEmpty") (.some (LMonoTy.arrow (LMonoTy.tcons "Container" [.int]) .bool))) - (LExpr.fvar () (BoogieIdent.unres "container") (.some (LMonoTy.tcons "Container" [.int]))))), + (LExpr.fvar () (CoreIdent.unres "container") (.some (LMonoTy.tcons "Container" [.int]))))), -- Extract the visible part - Statement.init (BoogieIdent.unres "visiblePart") (.forAll [] LMonoTy.int) + Statement.init (CoreIdent.unres "visiblePart") (.forAll [] LMonoTy.int) (LExpr.app () - (LExpr.op () (BoogieIdent.unres "visiblePart") + (LExpr.op () (CoreIdent.unres "visiblePart") (.some (LMonoTy.arrow (LMonoTy.tcons "Container" [.int]) .int))) - (LExpr.fvar () (BoogieIdent.unres "container") (.some (LMonoTy.tcons "Container" [.int])))), + (LExpr.fvar () (CoreIdent.unres "container") (.some (LMonoTy.tcons "Container" [.int])))), -- Assume the visible part has a specific value Statement.assume "visible_part_is_42" (LExpr.eq () - (LExpr.fvar () (BoogieIdent.unres "visiblePart") (.some .int)) + (LExpr.fvar () (CoreIdent.unres "visiblePart") (.some .int)) (LExpr.intConst () 42)), -- Assert that container is WithHidden Statement.assert "container_is_with_hidden" (LExpr.app () - (LExpr.op () (BoogieIdent.unres "isWithHidden") + (LExpr.op () (CoreIdent.unres "isWithHidden") (.some (LMonoTy.arrow (LMonoTy.tcons "Container" [.int]) .bool))) - (LExpr.fvar () (BoogieIdent.unres "container") (.some (LMonoTy.tcons "Container" [.int])))) + (LExpr.fvar () (CoreIdent.unres "container") (.some (LMonoTy.tcons "Container" [.int])))) ] match mkProgramWithDatatypes [hiddenDatatype, containerDatatype] "testHiddenTypeRecursion" statements with diff --git a/StrataTest/Languages/Core/Examples/Goto.lean b/StrataTest/Languages/Core/Examples/Goto.lean index 7b245bd2e..7e612896b 100644 --- a/StrataTest/Languages/Core/Examples/Goto.lean +++ b/StrataTest/Languages/Core/Examples/Goto.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Core import Strata.Languages.Core.Verifier --------------------------------------------------------------------- diff --git a/StrataTest/Languages/Core/ExprEvalTest.lean b/StrataTest/Languages/Core/ExprEvalTest.lean index 1d2eeadaf..b25857418 100644 --- a/StrataTest/Languages/Core/ExprEvalTest.lean +++ b/StrataTest/Languages/Core/ExprEvalTest.lean @@ -35,9 +35,9 @@ section Tests open Lambda open Std -def encode (e:LExpr BoogieLParams.mono) +def encode (e:LExpr CoreLParams.mono) (tenv:TEnv Visibility) - (init_state:LState BoogieLParams): + (init_state:LState CoreLParams): Except Format (Option (Strata.SMT.Term × SMT.Context)) := do let init_state ← init_state.addFactory Core.Factory @@ -58,7 +58,7 @@ def encode (e:LExpr BoogieLParams.mono) Check whether concrete evaluation of e matches the SMT encoding of e. Returns false if e did not reduce to a constant. -/ -def checkValid (e:LExpr BoogieLParams.mono): IO Bool := do +def checkValid (e:LExpr CoreLParams.mono): IO Bool := do let tenv := TEnv.default let init_state := LState.init match encode e tenv init_state with @@ -99,7 +99,7 @@ private def pickRandInt (abs_bound:Nat): IO Int := do let rand_size <- IO.rand 0 abs_bound return (if rand_sign = 0 then rand_size else - (Int.ofNat rand_size)) -private def mkRandConst (ty:LMonoTy): IO (Option (LExpr BoogieLParams.mono)) +private def mkRandConst (ty:LMonoTy): IO (Option (LExpr CoreLParams.mono)) := do match ty with | .tcons "int" [] => @@ -119,7 +119,7 @@ private def mkRandConst (ty:LMonoTy): IO (Option (LExpr BoogieLParams.mono)) | .tcons "regex" [] => -- TODO: random regex generator return (.some (.app () - (.op () (BoogieIdent.unres "Str.ToRegEx") .none) (.strConst () ".*"))) + (.op () (CoreIdent.unres "Str.ToRegEx") .none) (.strConst () ".*"))) | .bitvec n => let specialvals := [0, 1, -1, Int.ofNat n, (Int.pow 2 (n-1)) - 1, -(Int.pow 2 (n-1))] @@ -129,7 +129,7 @@ private def mkRandConst (ty:LMonoTy): IO (Option (LExpr BoogieLParams.mono)) return .none def checkFactoryOps (verbose:Bool): IO Unit := do - let arr:Array (LFunc BoogieLParams) := Core.Factory + let arr:Array (LFunc CoreLParams) := Core.Factory let print (f:Format): IO Unit := if verbose then IO.println f else return () @@ -143,7 +143,7 @@ def checkFactoryOps (verbose:Bool): IO Unit := do let mut unsupported := false let mut cnt_skipped := 0 for _ in [0:cnt] do - let args:List (Option (LExpr BoogieLParams.mono)) + let args:List (Option (LExpr CoreLParams.mono)) <- e.inputs.mapM (fun t => do let res <- mkRandConst t.snd match res with @@ -157,7 +157,7 @@ def checkFactoryOps (verbose:Bool): IO Unit := do else let args := List.map (Option.get!) args let expr := List.foldl (fun e arg => (.app () e arg)) - (LExpr.op () (BoogieIdent.unres e.name.name) .none) args + (LExpr.op () (CoreIdent.unres e.name.name) .none) args let res <- checkValid expr if ¬ res then if cnt_skipped = 0 then @@ -183,7 +183,7 @@ open Lambda.LTy.Syntax #guard_msgs in #eval (checkValid eb[if #1 == #2 then #false else #true]) /-- info: true -/ #guard_msgs in #eval (checkValid - (.app () (.app () (.op () (BoogieIdent.unres "Int.Add") .none) eb[#100]) eb[#50])) + (.app () (.app () (.op () (CoreIdent.unres "Int.Add") .none) eb[#100]) eb[#50])) -- This may take a while (~ 5min) @@ -193,7 +193,7 @@ open Plausible TestGen deriving instance Arbitrary for Visibility -def test_lctx : LContext BoogieLParams := +def test_lctx : LContext CoreLParams := { LContext.empty with functions := Boogie.Factory @@ -206,7 +206,7 @@ abbrev test_ty : LTy := .forAll [] <| .tcons "bool" [] #guard_msgs(drop all) in #eval do - let P : LExpr BoogieLParams.mono → Prop := fun t => HasType test_lctx test_ctx t test_ty + let P : LExpr CoreLParams.mono → Prop := fun t => HasType test_lctx test_ctx t test_ty let t ← Gen.runUntil .none (ArbitrarySizedSuchThat.arbitrarySizedST P 5) 5 IO.println s!"Generated {t}" let b ← checkValid t diff --git a/StrataTest/Languages/Core/ProgramTypeTests.lean b/StrataTest/Languages/Core/ProgramTypeTests.lean index 618e8d1b4..a3d558b19 100644 --- a/StrataTest/Languages/Core/ProgramTypeTests.lean +++ b/StrataTest/Languages/Core/ProgramTypeTests.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Core namespace Core diff --git a/StrataTest/Languages/Core/SMTEncoderDatatypeTest.lean b/StrataTest/Languages/Core/SMTEncoderDatatypeTest.lean index 7e2f5ce5a..95fdb1c8f 100644 --- a/StrataTest/Languages/Core/SMTEncoderDatatypeTest.lean +++ b/StrataTest/Languages/Core/SMTEncoderDatatypeTest.lean @@ -70,7 +70,7 @@ def treeDatatype : LDatatype Visibility := /-- Convert an expression to full SMT string including datatype declarations. -/ -def toSMTStringWithDatatypes (e : LExpr BoogieLParams.mono) (datatypes : List (LDatatype Visibility)) : IO String := do +def toSMTStringWithDatatypes (e : LExpr CoreLParams.mono) (datatypes : List (LDatatype Visibility)) : IO String := do match Env.init.addDatatypes datatypes with | .error msg => return s!"Error creating environment: {msg}" | .ok env => @@ -108,7 +108,7 @@ info: (declare-datatype TestOption (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.fvar () (BoogieIdent.unres "x") (.some (.tcons "TestOption" [.int]))) + (.fvar () (CoreIdent.unres "x") (.some (.tcons "TestOption" [.int]))) [optionDatatype] -- Test 2: Recursive datatype (List) - using List type @@ -122,7 +122,7 @@ info: (declare-datatype TestList (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.fvar () (BoogieIdent.unres "xs") (.some (.tcons "TestList" [.int]))) + (.fvar () (CoreIdent.unres "xs") (.some (.tcons "TestList" [.int]))) [listDatatype] -- Test 3: Multiple constructors - Tree with Leaf and Node @@ -136,7 +136,7 @@ info: (declare-datatype TestTree (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.fvar () (BoogieIdent.unres "tree") (.some (.tcons "TestTree" [.bool]))) + (.fvar () (CoreIdent.unres "tree") (.some (.tcons "TestTree" [.bool]))) [treeDatatype] -- Test 4: Parametric datatype instantiation - List Int @@ -150,7 +150,7 @@ info: (declare-datatype TestList (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.fvar () (BoogieIdent.unres "intList") (.some (.tcons "TestList" [.int]))) + (.fvar () (CoreIdent.unres "intList") (.some (.tcons "TestList" [.int]))) [listDatatype] -- Test 5: Parametric datatype instantiation - List Bool (should reuse same datatype) @@ -164,7 +164,7 @@ info: (declare-datatype TestList (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.fvar () (BoogieIdent.unres "boolList") (.some (.tcons "TestList" [.bool]))) + (.fvar () (CoreIdent.unres "boolList") (.some (.tcons "TestList" [.bool]))) [listDatatype] -- Test 6: Multi-field constructor - Tree with 3 fields @@ -178,7 +178,7 @@ info: (declare-datatype TestTree (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.fvar () (BoogieIdent.unres "intTree") (.some (.tcons "TestTree" [.int]))) + (.fvar () (CoreIdent.unres "intTree") (.some (.tcons "TestTree" [.int]))) [treeDatatype] -- Test 7: Nested parametric types - List of Option (should declare both datatypes) @@ -195,7 +195,7 @@ info: (declare-datatype TestOption (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.fvar () (BoogieIdent.unres "listOfOption") (.some (.tcons "TestList" [.tcons "TestOption" [.int]]))) + (.fvar () (CoreIdent.unres "listOfOption") (.some (.tcons "TestList" [.tcons "TestOption" [.int]]))) [listDatatype, optionDatatype] /-! ## Constructor Application Tests -/ @@ -209,7 +209,7 @@ info: (declare-datatype TestOption (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.op () (BoogieIdent.unres "None") (.some (.tcons "TestOption" [.int]))) + (.op () (CoreIdent.unres "None") (.some (.tcons "TestOption" [.int]))) [optionDatatype] -- Test 9: Some constructor (single-argument) @@ -221,7 +221,7 @@ info: (declare-datatype TestOption (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.app () (.op () (BoogieIdent.unres "Some") (.some (.arrow .int (.tcons "TestOption" [.int])))) (.intConst () 42)) + (.app () (.op () (CoreIdent.unres "Some") (.some (.arrow .int (.tcons "TestOption" [.int])))) (.intConst () 42)) [optionDatatype] -- Test 10: Cons constructor (multi-argument) @@ -235,9 +235,9 @@ info: (declare-datatype TestList (par (α) ( #guard_msgs in #eval format <$> toSMTStringWithDatatypes (.app () - (.app () (.op () (BoogieIdent.unres "Cons") (.some (.arrow .int (.arrow (.tcons "TestList" [.int]) (.tcons "TestList" [.int]))))) + (.app () (.op () (CoreIdent.unres "Cons") (.some (.arrow .int (.arrow (.tcons "TestList" [.int]) (.tcons "TestList" [.int]))))) (.intConst () 1)) - (.op () (BoogieIdent.unres "Nil") (.some (.tcons "TestList" [.int])))) + (.op () (CoreIdent.unres "Nil") (.some (.tcons "TestList" [.int])))) [listDatatype] /-! ## Tester Function Tests -/ @@ -254,8 +254,8 @@ info: (declare-datatype TestOption (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.app () (.op () (BoogieIdent.unres "TestOption$isNone") (.some (.arrow (.tcons "TestOption" [.int]) .bool))) - (.fvar () (BoogieIdent.unres "x") (.some (.tcons "TestOption" [.int])))) + (.app () (.op () (CoreIdent.unres "TestOption$isNone") (.some (.arrow (.tcons "TestOption" [.int]) .bool))) + (.fvar () (CoreIdent.unres "x") (.some (.tcons "TestOption" [.int])))) [optionDatatype] -- Test 12: isCons tester @@ -270,8 +270,8 @@ info: (declare-datatype TestList (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.app () (.op () (BoogieIdent.unres "TestList$isCons") (.some (.arrow (.tcons "TestList" [.int]) .bool))) - (.fvar () (BoogieIdent.unres "xs") (.some (.tcons "TestList" [.int])))) + (.app () (.op () (CoreIdent.unres "TestList$isCons") (.some (.arrow (.tcons "TestList" [.int]) .bool))) + (.fvar () (CoreIdent.unres "xs") (.some (.tcons "TestList" [.int])))) [listDatatype] /-! ## Destructor Function Tests -/ @@ -288,8 +288,8 @@ info: (declare-datatype TestOption (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.app () (.op () (BoogieIdent.unres "TestOption$SomeProj0") (.some (.arrow (.tcons "TestOption" [.int]) .int))) - (.fvar () (BoogieIdent.unres "x") (.some (.tcons "TestOption" [.int])))) + (.app () (.op () (CoreIdent.unres "TestOption$SomeProj0") (.some (.arrow (.tcons "TestOption" [.int]) .int))) + (.fvar () (CoreIdent.unres "x") (.some (.tcons "TestOption" [.int])))) [optionDatatype] -- Test 14: Cons head destructor @@ -304,8 +304,8 @@ info: (declare-datatype TestList (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.app () (.op () (BoogieIdent.unres "TestList$ConsProj0") (.some (.arrow (.tcons "TestList" [.int]) .int))) - (.fvar () (BoogieIdent.unres "xs") (.some (.tcons "TestList" [.int])))) + (.app () (.op () (CoreIdent.unres "TestList$ConsProj0") (.some (.arrow (.tcons "TestList" [.int]) .int))) + (.fvar () (CoreIdent.unres "xs") (.some (.tcons "TestList" [.int])))) [listDatatype] -- Test 15: Cons tail destructor @@ -320,8 +320,8 @@ info: (declare-datatype TestList (par (α) ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.app () (.op () (BoogieIdent.unres "TestList$ConsProj1") (.some (.arrow (.tcons "TestList" [.int]) (.tcons "TestList" [.int])))) - (.fvar () (BoogieIdent.unres "xs") (.some (.tcons "TestList" [.int])))) + (.app () (.op () (CoreIdent.unres "TestList$ConsProj1") (.some (.arrow (.tcons "TestList" [.int]) (.tcons "TestList" [.int])))) + (.fvar () (CoreIdent.unres "xs") (.some (.tcons "TestList" [.int])))) [listDatatype] /-! ## Complex Dependency Topological Sorting Tests -/ @@ -416,7 +416,7 @@ info: (declare-datatype Zeta ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.fvar () (BoogieIdent.unres "alphaVar") (.some (.tcons "Alpha" []))) + (.fvar () (CoreIdent.unres "alphaVar") (.some (.tcons "Alpha" []))) [alphaDatatype, betaDatatype, gammaDatatype, deltaDatatype, epsilonDatatype, zetaDatatype] -- Test 17: Diamond dependency pattern @@ -479,7 +479,7 @@ info: (declare-datatype Root ( -/ #guard_msgs in #eval format <$> toSMTStringWithDatatypes - (.fvar () (BoogieIdent.unres "diamondVar") (.some (.tcons "Diamond" []))) + (.fvar () (CoreIdent.unres "diamondVar") (.some (.tcons "Diamond" []))) [diamondDatatype, leftDatatype, rightDatatype, rootDatatype] end DatatypeTests diff --git a/StrataTest/Transform/CallElim.lean b/StrataTest/Transform/CallElim.lean index 160e6774d..06b88a3eb 100644 --- a/StrataTest/Transform/CallElim.lean +++ b/StrataTest/Transform/CallElim.lean @@ -6,7 +6,7 @@ import Strata.DDM.Integration.Lean import Strata.DDM.Util.Format -import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Core import Strata.Languages.Core.DDMTransform.Translate import Strata.Languages.Core.ProgramType import Strata.Languages.Core.ProgramWF diff --git a/StrataTest/Transform/ProcedureInlining.lean b/StrataTest/Transform/ProcedureInlining.lean index 8b1cec2dc..4d1158efc 100644 --- a/StrataTest/Transform/ProcedureInlining.lean +++ b/StrataTest/Transform/ProcedureInlining.lean @@ -6,7 +6,7 @@ import Strata.DDM.Integration.Lean import Strata.DDM.Util.Format -import Strata.Languages.Core.Boogie +import Strata.Languages.Core.Core import Strata.Languages.Core.DDMTransform.Translate import Strata.Languages.Core.StatementSemantics import Strata.Languages.Core.ProgramType From 61bf3a4b7abdb02e9da22de3e195d676ebbf3fcc Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 15:29:17 -0600 Subject: [PATCH 08/19] Missing .boogie.st -> .core.st, do more updates in doc and comments --- .github/workflows/ci.yml | 4 +- .kiro/steering/structure.md | 4 +- CONTRIBUTING.md | 6 +- Examples/HeapReasoning.core.st | 2 +- Examples/expected/HeapReasoning.core.expected | 100 +++++++++--------- Examples/expected/LoopSimple.core.expected | 8 +- Examples/expected/SimpleProc.core.expected | 6 +- Examples/expected/TypeError.core.expected | 2 +- README.md | 4 +- Strata.lean | 2 +- Strata/Languages/Python/BoogiePrelude.lean | 2 +- StrataMain.lean | 4 +- StrataTest/Backends/CBMC/run_tests.sh | 2 +- .../Internal/InternalBoogiePrelude.lean | 2 +- StrataVerify.lean | 4 +- Tools/BoogieToStrata/.gitignore | 2 +- Tools/BoogieToStrata/Tests/Arrays2.expect | 24 ++--- Tools/BoogieToStrata/Tests/Axioms.expect | 10 +- Tools/BoogieToStrata/Tests/B.expect | 8 +- .../Tests/BooleanQuantification.expect | 14 +-- .../Tests/BooleanQuantification2.expect | 6 +- Tools/BoogieToStrata/Tests/Bubble.expect | 28 ++--- Tools/BoogieToStrata/Tests/DivMod.expect | 12 +-- Tools/BoogieToStrata/Tests/Gauss.expect | 6 +- Tools/BoogieToStrata/Tests/IfThenElse1.expect | 12 +-- Tools/BoogieToStrata/Tests/Implies.expect | 24 ++--- Tools/BoogieToStrata/Tests/Lambda.expect | 24 ++--- Tools/BoogieToStrata/Tests/McCarthy-91.expect | 4 +- Tools/BoogieToStrata/Tests/Quantifiers.expect | 28 ++--- .../BoogieToStrata/Tests/TypeSynonyms2.expect | 2 +- Tools/BoogieToStrata/Tests/Unique.expect | 8 +- Tools/BoogieToStrata/Tests/Where.expect | 24 ++--- Tools/BoogieToStrata/Tests/bv9.expect | 2 +- docs/GettingStarted.md | 2 +- 34 files changed, 195 insertions(+), 197 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 304a45c0b..fd5a1c11d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,13 +71,13 @@ jobs: - name: Build and test Strata uses: leanprover/lean-action@v1 - name: Build and run StrataVerify - run: lake exe StrataVerify Examples/SimpleProc.boogie.st + run: lake exe StrataVerify Examples/SimpleProc.core.st - name: Build BoogieToStrata run: dotnet build -warnaserror ${SOLUTION} - name: Test BoogieToStrata run: dotnet test ${SOLUTION} - name: Test Strata Command line - run: .github/scripts/testStrataCommand.sh + run: .github/scripts/testStrataCommand.sh - name: Validate examples against expected output working-directory: Examples shell: bash diff --git a/.kiro/steering/structure.md b/.kiro/steering/structure.md index 510cdf40e..b41f1ed8f 100644 --- a/.kiro/steering/structure.md +++ b/.kiro/steering/structure.md @@ -135,8 +135,8 @@ Top-level structure: ## Other Languages **C_Simp** (`Strata/Languages/C_Simp/`) - Simplified C-like language -- Verification via transformation to Boogie -- Pipeline: Parse → Transform loops → Translate to Boogie → VCG → SMT +- Verification via transformation to Strata Core +- Pipeline: Parse → Transform loops → Translate to Strata Core → VCG → SMT **Dyn** (`Strata/Languages/Dyn/`) - Dynamic language example demonstrating dialect extensibility diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9ccb068cc..ff2a0d7a3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,7 +37,7 @@ this can be okay. However, because we aim for it to be possible to verify core functionality, we prefer that operations over programs or terms -- such as transformations, verification condition generation, or testing -- be total functions and that this fact can, at least in -principle, be proved. That a function is total is also usually a +principle, be proved. That a function is total is also usually a prerequisite for any proofs that use the function in question. In some cases, however, it may be valuable to prove properties of code @@ -131,9 +131,7 @@ main purposes: components (e.g., just the DDM, just the partial evaluator of a specific dialect, etc.). These tests serve as guides to understand how to set up, use, and compose these core components. - -* In the `Examples` directories (e.g., - `Strata/Languages/[Boogie|C_Simp]/Examples`), which showcase + `StrataTest/Languages/[Core|C_Simp]/Examples` showcases end-to-end Strata applications and may include output from external solvers. diff --git a/Examples/HeapReasoning.core.st b/Examples/HeapReasoning.core.st index 211eb4b9f..faac96ede 100644 --- a/Examples/HeapReasoning.core.st +++ b/Examples/HeapReasoning.core.st @@ -1,5 +1,5 @@ program Core; -// lake exe StrataVerify Strata/Languages/Boogie/Examples/HeapReasoning.boogie.st +// lake exe StrataVerify Strata/Languages/Boogie/Examples/HeapReasoning.core.st // Prelude begin -------------------------------------------------- type Ref; diff --git a/Examples/expected/HeapReasoning.core.expected b/Examples/expected/HeapReasoning.core.expected index 4bb12ba2c..dfe411735 100644 --- a/Examples/expected/HeapReasoning.core.expected +++ b/Examples/expected/HeapReasoning.core.expected @@ -1,55 +1,55 @@ Successfully parsed. -HeapReasoning.boogie.st(99, 2) [modifiesFrameRef1]: ✅ pass -HeapReasoning.boogie.st(104, 2) [modifiesFrameRef1]: ✅ pass -HeapReasoning.boogie.st(109, 2) [modifiesFrameRef1]: ✅ pass +HeapReasoning.core.st(99, 2) [modifiesFrameRef1]: ✅ pass +HeapReasoning.core.st(104, 2) [modifiesFrameRef1]: ✅ pass +HeapReasoning.core.st(109, 2) [modifiesFrameRef1]: ✅ pass [Container_ctor_ensures_4]: ✅ pass -HeapReasoning.boogie.st(87, 2) [Container_ctor_ensures_7]: ✅ pass -HeapReasoning.boogie.st(88, 2) [Container_ctor_ensures_8]: ✅ pass -HeapReasoning.boogie.st(89, 2) [Container_ctor_ensures_9]: ✅ pass -HeapReasoning.boogie.st(91, 2) [Container_ctor_ensures_10]: ✅ pass -HeapReasoning.boogie.st(165, 2) [modifiesFrameRef1]: ✅ pass -HeapReasoning.boogie.st(170, 2) [modifiesFrameRef2]: ✅ pass -HeapReasoning.boogie.st(173, 2) [modifiesFrameRef1Next]: ✅ pass -HeapReasoning.boogie.st(178, 2) [modifiesFrameRef2Next]: ✅ pass -HeapReasoning.boogie.st(133, 2) [UpdateContainers_ensures_5]: ✅ pass +HeapReasoning.core.st(87, 2) [Container_ctor_ensures_7]: ✅ pass +HeapReasoning.core.st(88, 2) [Container_ctor_ensures_8]: ✅ pass +HeapReasoning.core.st(89, 2) [Container_ctor_ensures_9]: ✅ pass +HeapReasoning.core.st(91, 2) [Container_ctor_ensures_10]: ✅ pass +HeapReasoning.core.st(165, 2) [modifiesFrameRef1]: ✅ pass +HeapReasoning.core.st(170, 2) [modifiesFrameRef2]: ✅ pass +HeapReasoning.core.st(173, 2) [modifiesFrameRef1Next]: ✅ pass +HeapReasoning.core.st(178, 2) [modifiesFrameRef2Next]: ✅ pass +HeapReasoning.core.st(133, 2) [UpdateContainers_ensures_5]: ✅ pass [UpdateContainers_ensures_6]: ✅ pass -HeapReasoning.boogie.st(151, 2) [UpdateContainers_ensures_14]: ✅ pass -HeapReasoning.boogie.st(152, 2) [UpdateContainers_ensures_15]: ✅ pass -HeapReasoning.boogie.st(153, 2) [UpdateContainers_ensures_16]: ✅ pass -HeapReasoning.boogie.st(154, 2) [UpdateContainers_ensures_17]: ✅ pass -HeapReasoning.boogie.st(156, 2) [UpdateContainers_ensures_18]: ✅ pass -HeapReasoning.boogie.st(157, 2) [UpdateContainers_ensures_19]: ✅ pass -HeapReasoning.boogie.st(75, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_1]: ✅ pass -HeapReasoning.boogie.st(76, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_2]: ✅ pass -HeapReasoning.boogie.st(77, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_3]: ✅ pass -HeapReasoning.boogie.st(85, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_5]: ✅ pass -HeapReasoning.boogie.st(86, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_6]: ✅ pass -HeapReasoning.boogie.st(216, 2) [c1Lychees0]: ✅ pass -HeapReasoning.boogie.st(217, 2) [c1Pineapple1]: ✅ pass -HeapReasoning.boogie.st(75, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_1]: ✅ pass -HeapReasoning.boogie.st(76, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_2]: ✅ pass -HeapReasoning.boogie.st(77, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_3]: ✅ pass -HeapReasoning.boogie.st(85, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_5]: ✅ pass -HeapReasoning.boogie.st(86, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_6]: ✅ pass -HeapReasoning.boogie.st(227, 2) [assert_9]: ✅ pass -HeapReasoning.boogie.st(232, 2) [assert_10]: ✅ pass -HeapReasoning.boogie.st(127, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_1]: ✅ pass -HeapReasoning.boogie.st(128, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_2]: ✅ pass -HeapReasoning.boogie.st(130, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_3]: ✅ pass -HeapReasoning.boogie.st(131, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_4]: ✅ pass -HeapReasoning.boogie.st(141, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_7]: ✅ pass -HeapReasoning.boogie.st(143, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_8]: ✅ pass -HeapReasoning.boogie.st(144, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_9]: ✅ pass -HeapReasoning.boogie.st(146, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_10]: ✅ pass -HeapReasoning.boogie.st(147, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_11]: ✅ pass -HeapReasoning.boogie.st(148, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_12]: ✅ pass -HeapReasoning.boogie.st(149, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_13]: ✅ pass -HeapReasoning.boogie.st(238, 2) [c1Lychees1]: ✅ pass -HeapReasoning.boogie.st(239, 2) [c1Pineapple2]: ✅ pass -HeapReasoning.boogie.st(240, 2) [c2Lychees0]: ✅ pass -HeapReasoning.boogie.st(241, 2) [c2Pineapple0]: ✅ pass -HeapReasoning.boogie.st(243, 2) [c1NextEqC2]: ✅ pass -HeapReasoning.boogie.st(244, 2) [c2NextEqC1]: ✅ pass -HeapReasoning.boogie.st(198, 2) [Main_ensures_2]: ✅ pass +HeapReasoning.core.st(151, 2) [UpdateContainers_ensures_14]: ✅ pass +HeapReasoning.core.st(152, 2) [UpdateContainers_ensures_15]: ✅ pass +HeapReasoning.core.st(153, 2) [UpdateContainers_ensures_16]: ✅ pass +HeapReasoning.core.st(154, 2) [UpdateContainers_ensures_17]: ✅ pass +HeapReasoning.core.st(156, 2) [UpdateContainers_ensures_18]: ✅ pass +HeapReasoning.core.st(157, 2) [UpdateContainers_ensures_19]: ✅ pass +HeapReasoning.core.st(75, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_1]: ✅ pass +HeapReasoning.core.st(76, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_2]: ✅ pass +HeapReasoning.core.st(77, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_3]: ✅ pass +HeapReasoning.core.st(85, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_5]: ✅ pass +HeapReasoning.core.st(86, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_6]: ✅ pass +HeapReasoning.core.st(216, 2) [c1Lychees0]: ✅ pass +HeapReasoning.core.st(217, 2) [c1Pineapple1]: ✅ pass +HeapReasoning.core.st(75, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_1]: ✅ pass +HeapReasoning.core.st(76, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_2]: ✅ pass +HeapReasoning.core.st(77, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_3]: ✅ pass +HeapReasoning.core.st(85, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_5]: ✅ pass +HeapReasoning.core.st(86, 2) [(Origin_Container_ctor_Requires)Container_ctor_requires_6]: ✅ pass +HeapReasoning.core.st(227, 2) [assert_9]: ✅ pass +HeapReasoning.core.st(232, 2) [assert_10]: ✅ pass +HeapReasoning.core.st(127, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_1]: ✅ pass +HeapReasoning.core.st(128, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_2]: ✅ pass +HeapReasoning.core.st(130, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_3]: ✅ pass +HeapReasoning.core.st(131, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_4]: ✅ pass +HeapReasoning.core.st(141, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_7]: ✅ pass +HeapReasoning.core.st(143, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_8]: ✅ pass +HeapReasoning.core.st(144, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_9]: ✅ pass +HeapReasoning.core.st(146, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_10]: ✅ pass +HeapReasoning.core.st(147, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_11]: ✅ pass +HeapReasoning.core.st(148, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_12]: ✅ pass +HeapReasoning.core.st(149, 2) [(Origin_UpdateContainers_Requires)UpdateContainers_requires_13]: ✅ pass +HeapReasoning.core.st(238, 2) [c1Lychees1]: ✅ pass +HeapReasoning.core.st(239, 2) [c1Pineapple2]: ✅ pass +HeapReasoning.core.st(240, 2) [c2Lychees0]: ✅ pass +HeapReasoning.core.st(241, 2) [c2Pineapple0]: ✅ pass +HeapReasoning.core.st(243, 2) [c1NextEqC2]: ✅ pass +HeapReasoning.core.st(244, 2) [c2NextEqC1]: ✅ pass +HeapReasoning.core.st(198, 2) [Main_ensures_2]: ✅ pass [Main_ensures_3]: ✅ pass All 53 goals passed. diff --git a/Examples/expected/LoopSimple.core.expected b/Examples/expected/LoopSimple.core.expected index b07c25f11..d6000ebdd 100644 --- a/Examples/expected/LoopSimple.core.expected +++ b/Examples/expected/LoopSimple.core.expected @@ -1,6 +1,6 @@ Successfully parsed. -LoopSimple.boogie.st(13, 2) [entry_invariant_0]: ✅ pass -LoopSimple.boogie.st(13, 2) [arbitrary_iter_maintain_invariant_0]: ✅ pass -LoopSimple.boogie.st(19, 2) [sum_assert]: ✅ pass -LoopSimple.boogie.st(20, 2) [neg_cond]: ✅ pass +LoopSimple.core.st(13, 2) [entry_invariant_0]: ✅ pass +LoopSimple.core.st(13, 2) [arbitrary_iter_maintain_invariant_0]: ✅ pass +LoopSimple.core.st(19, 2) [sum_assert]: ✅ pass +LoopSimple.core.st(20, 2) [neg_cond]: ✅ pass All 4 goals passed. diff --git a/Examples/expected/SimpleProc.core.expected b/Examples/expected/SimpleProc.core.expected index 1432820ea..1af99fbf4 100644 --- a/Examples/expected/SimpleProc.core.expected +++ b/Examples/expected/SimpleProc.core.expected @@ -1,5 +1,5 @@ Successfully parsed. -SimpleProc.boogie.st(21, 2) [Test_ensures_0]: ✅ pass -SimpleProc.boogie.st(22, 2) [Test_ensures_1]: ✅ pass -SimpleProc.boogie.st(23, 2) [Test_ensures_2]: ✅ pass +SimpleProc.core.st(21, 2) [Test_ensures_0]: ✅ pass +SimpleProc.core.st(22, 2) [Test_ensures_1]: ✅ pass +SimpleProc.core.st(23, 2) [Test_ensures_2]: ✅ pass All 3 goals passed. diff --git a/Examples/expected/TypeError.core.expected b/Examples/expected/TypeError.core.expected index c4324e9dd..8d387f6e2 100644 --- a/Examples/expected/TypeError.core.expected +++ b/Examples/expected/TypeError.core.expected @@ -1,4 +1,4 @@ Successfully parsed. ❌ Type checking error. -TypeError.boogie.st(25, 2) Impossible to unify (Map int (Map bool bool)) with (Map int int). +TypeError.core.st(25, 2) Impossible to unify (Map int (Map bool bool)) with (Map int int). First mismatch: (Map bool bool) with int. diff --git a/README.md b/README.md index 93949bfa9..ddb685e14 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Unit tests are run with `#guard_msgs` commands. No output means the tests passed ## Running Analyses on Existing Strata Programs Strata programs use the `.st` file extension, preceded by the dialect name, -preceded by a second `.` e.g., `SimpleProc.boogie.st` or +preceded by a second `.` e.g., `SimpleProc.core.st` or `LoopSimple.csimp.st`. Note the current `StrataVerify` executable relies on this file extension convention to know what dialect it's parsing (since the Strata IR allows a program to open multiple @@ -51,7 +51,7 @@ dialects). Here is an example invocation that runs Strata's deductive verifier. ```bash -lake exe StrataVerify Examples/SimpleProc.boogie.st +lake exe StrataVerify Examples/SimpleProc.core.st ``` This will: diff --git a/Strata.lean b/Strata.lean index c53656403..15e58f612 100644 --- a/Strata.lean +++ b/Strata.lean @@ -15,7 +15,7 @@ import Strata.DL.SMT.SMT import Strata.DL.Lambda.Lambda import Strata.DL.Imperative.Imperative -/- Boogie -/ +/- Strata Core -/ import Strata.Languages.Core.StatementSemantics /- Code Transforms -/ diff --git a/Strata/Languages/Python/BoogiePrelude.lean b/Strata/Languages/Python/BoogiePrelude.lean index b6c5bf399..b4b71dc59 100644 --- a/Strata/Languages/Python/BoogiePrelude.lean +++ b/Strata/Languages/Python/BoogiePrelude.lean @@ -357,7 +357,7 @@ spec { #end -def Boogie.prelude : Core.Program := +def Core.prelude : Core.Program := Boogie.getProgram Strata.boogiePrelude |>.fst end Strata diff --git a/StrataMain.lean b/StrataMain.lean index 71f1b22db..d11214513 100644 --- a/StrataMain.lean +++ b/StrataMain.lean @@ -184,7 +184,7 @@ def pyTranslateCommand : Command where help := "Translate a Strata Python Ion file to Strata Core. Write results to stdout." callback := fun _ v => do let pgm ← readPythonStrata v[0] - let preludePgm := Strata.Python.Internal.Boogie.prelude + let preludePgm := Strata.Python.Internal.Core.prelude let bpgm := Strata.pythonToBoogie Strata.Python.Internal.signatures pgm let newPgm : Core.Program := { decls := preludePgm.decls ++ bpgm.decls } IO.print newPgm @@ -198,7 +198,7 @@ def pyAnalyzeCommand : Command where let pgm ← readPythonStrata v[0] if verbose then IO.print pgm - let preludePgm := Strata.Python.Internal.Boogie.prelude + let preludePgm := Strata.Python.Internal.Core.prelude let bpgm := Strata.pythonToBoogie Strata.Python.Internal.signatures pgm let newPgm : Core.Program := { decls := preludePgm.decls ++ bpgm.decls } if verbose then diff --git a/StrataTest/Backends/CBMC/run_tests.sh b/StrataTest/Backends/CBMC/run_tests.sh index 8a0417a5d..b5e27352d 100755 --- a/StrataTest/Backends/CBMC/run_tests.sh +++ b/StrataTest/Backends/CBMC/run_tests.sh @@ -7,7 +7,7 @@ pushd ../../../ echo "Boogie -> CBMC: illustrates verification fail." echo "----------------------------------------------------------------------" -Strata/Backends/CBMC/run_strata_cbmc.sh Strata/Backends/CBMC/tests/simpleTest.boogie.st +Strata/Backends/CBMC/run_strata_cbmc.sh Strata/Backends/CBMC/tests/simpleTest.core.st echo "######################################################################" diff --git a/StrataTest/Internal/InternalBoogiePrelude.lean b/StrataTest/Internal/InternalBoogiePrelude.lean index 5f441c05d..f0960b798 100644 --- a/StrataTest/Internal/InternalBoogiePrelude.lean +++ b/StrataTest/Internal/InternalBoogiePrelude.lean @@ -14,7 +14,7 @@ namespace Strata namespace Python namespace Internal -def Boogie.prelude : Core.Program := Strata.Boogie.prelude +def Core.prelude : Core.Program := Strata.Core.prelude end Internal end Python diff --git a/StrataVerify.lean b/StrataVerify.lean index f514b9188..0f7db1e0c 100644 --- a/StrataVerify.lean +++ b/StrataVerify.lean @@ -31,7 +31,7 @@ def parseOptions (args : List String) : Except Std.Format (Options × String) := | _, args => .error f!"Unknown options: {args}" def usageMessage : Std.Format := - f!"Usage: StrataVerify [OPTIONS] {Std.Format.line}\ + f!"Usage: StrataVerify [OPTIONS] {Std.Format.line}\ {Std.Format.line}\ Options:{Std.Format.line}\ {Std.Format.line} \ @@ -61,7 +61,7 @@ def main (args : List String) : IO UInt32 := do let ans := if file.endsWith ".csimp.st" then C_Simp.typeCheck pgm opts else - -- Boogie. + -- Strata Core. typeCheck inputCtx pgm opts match ans with | .error e => diff --git a/Tools/BoogieToStrata/.gitignore b/Tools/BoogieToStrata/.gitignore index c526c45a0..f7478fd4a 100644 --- a/Tools/BoogieToStrata/.gitignore +++ b/Tools/BoogieToStrata/.gitignore @@ -4,6 +4,6 @@ bin obj vcs -Tests/*.boogie.st +Tests/*.core.st Tests/*.out Tests/*.err diff --git a/Tools/BoogieToStrata/Tests/Arrays2.expect b/Tools/BoogieToStrata/Tests/Arrays2.expect index 88950a729..9dce9b04f 100644 --- a/Tools/BoogieToStrata/Tests/Arrays2.expect +++ b/Tools/BoogieToStrata/Tests/Arrays2.expect @@ -1,14 +1,14 @@ Successfully parsed. -Arrays2.boogie.st(22, 2) [P0_ensures_2]: ✅ pass -Arrays2.boogie.st(23, 2) [P0_ensures_3]: ✅ pass -Arrays2.boogie.st(39, 2) [P1_ensures_1]: ✅ pass -Arrays2.boogie.st(55, 2) [P2_ensures_1]: 🟡 unknown -Arrays2.boogie.st(72, 2) [Q0_ensures_2]: ✅ pass -Arrays2.boogie.st(73, 2) [Q0_ensures_3]: ✅ pass -Arrays2.boogie.st(89, 2) [Q1_ensures_1]: ✅ pass -Arrays2.boogie.st(106, 2) [Q2_ensures_2]: ✅ pass -Arrays2.boogie.st(123, 2) [Q3_ensures_2]: ✅ pass -Arrays2.boogie.st(139, 2) [Q4_ensures_1]: 🟡 unknown -Arrays2.boogie.st(156, 2) [Skip0_ensures_2]: ✅ pass -Arrays2.boogie.st(157, 2) [Skip0_ensures_3]: ✅ pass +Arrays2.core.st(22, 2) [P0_ensures_2]: ✅ pass +Arrays2.core.st(23, 2) [P0_ensures_3]: ✅ pass +Arrays2.core.st(39, 2) [P1_ensures_1]: ✅ pass +Arrays2.core.st(55, 2) [P2_ensures_1]: 🟡 unknown +Arrays2.core.st(72, 2) [Q0_ensures_2]: ✅ pass +Arrays2.core.st(73, 2) [Q0_ensures_3]: ✅ pass +Arrays2.core.st(89, 2) [Q1_ensures_1]: ✅ pass +Arrays2.core.st(106, 2) [Q2_ensures_2]: ✅ pass +Arrays2.core.st(123, 2) [Q3_ensures_2]: ✅ pass +Arrays2.core.st(139, 2) [Q4_ensures_1]: 🟡 unknown +Arrays2.core.st(156, 2) [Skip0_ensures_2]: ✅ pass +Arrays2.core.st(157, 2) [Skip0_ensures_3]: ✅ pass Finished with 10 goals passed, 2 failed. diff --git a/Tools/BoogieToStrata/Tests/Axioms.expect b/Tools/BoogieToStrata/Tests/Axioms.expect index 5d3d38c7c..fd1bf11c7 100644 --- a/Tools/BoogieToStrata/Tests/Axioms.expect +++ b/Tools/BoogieToStrata/Tests/Axioms.expect @@ -1,7 +1,7 @@ Successfully parsed. -Axioms.boogie.st(25, 4) [assert_0]: ✅ pass -Axioms.boogie.st(26, 4) [assert_1]: ✅ pass -Axioms.boogie.st(27, 4) [assert_2]: ✅ pass -Axioms.boogie.st(37, 4) [assert_3]: 🟡 unknown -Axioms.boogie.st(48, 4) [assert_4]: ✅ pass +Axioms.core.st(25, 4) [assert_0]: ✅ pass +Axioms.core.st(26, 4) [assert_1]: ✅ pass +Axioms.core.st(27, 4) [assert_2]: ✅ pass +Axioms.core.st(37, 4) [assert_3]: 🟡 unknown +Axioms.core.st(48, 4) [assert_4]: ✅ pass Finished with 4 goals passed, 1 failed. diff --git a/Tools/BoogieToStrata/Tests/B.expect b/Tools/BoogieToStrata/Tests/B.expect index 5011e0494..178125267 100644 --- a/Tools/BoogieToStrata/Tests/B.expect +++ b/Tools/BoogieToStrata/Tests/B.expect @@ -1,6 +1,6 @@ Successfully parsed. -B.boogie.st(36, 4) [assert_0]: ✅ pass -B.boogie.st(62, 4) [assert_1]: ✅ pass -B.boogie.st(88, 4) [assert_2]: ✅ pass -B.boogie.st(115, 4) [assert_3]: ✅ pass +B.core.st(36, 4) [assert_0]: ✅ pass +B.core.st(62, 4) [assert_1]: ✅ pass +B.core.st(88, 4) [assert_2]: ✅ pass +B.core.st(115, 4) [assert_3]: ✅ pass All 4 goals passed. diff --git a/Tools/BoogieToStrata/Tests/BooleanQuantification.expect b/Tools/BoogieToStrata/Tests/BooleanQuantification.expect index 57325b895..ded564550 100644 --- a/Tools/BoogieToStrata/Tests/BooleanQuantification.expect +++ b/Tools/BoogieToStrata/Tests/BooleanQuantification.expect @@ -1,9 +1,9 @@ Successfully parsed. -BooleanQuantification.boogie.st(22, 4) [assert_0]: ✅ pass -BooleanQuantification.boogie.st(31, 4) [assert_1]: ✅ pass -BooleanQuantification.boogie.st(40, 4) [assert_2]: ✅ pass -BooleanQuantification.boogie.st(41, 4) [assert_3]: 🟡 unknown -BooleanQuantification.boogie.st(50, 4) [assert_4]: ✅ pass -BooleanQuantification.boogie.st(51, 4) [assert_5]: ✅ pass -BooleanQuantification.boogie.st(52, 4) [assert_6]: ❌ fail +BooleanQuantification.core.st(22, 4) [assert_0]: ✅ pass +BooleanQuantification.core.st(31, 4) [assert_1]: ✅ pass +BooleanQuantification.core.st(40, 4) [assert_2]: ✅ pass +BooleanQuantification.core.st(41, 4) [assert_3]: 🟡 unknown +BooleanQuantification.core.st(50, 4) [assert_4]: ✅ pass +BooleanQuantification.core.st(51, 4) [assert_5]: ✅ pass +BooleanQuantification.core.st(52, 4) [assert_6]: ❌ fail Finished with 5 goals passed, 2 failed. diff --git a/Tools/BoogieToStrata/Tests/BooleanQuantification2.expect b/Tools/BoogieToStrata/Tests/BooleanQuantification2.expect index 492716be5..bebd6467a 100644 --- a/Tools/BoogieToStrata/Tests/BooleanQuantification2.expect +++ b/Tools/BoogieToStrata/Tests/BooleanQuantification2.expect @@ -1,5 +1,5 @@ Successfully parsed. -BooleanQuantification2.boogie.st(18, 4) [assert_0]: ✅ pass -BooleanQuantification2.boogie.st(19, 4) [assert_1]: ✅ pass -BooleanQuantification2.boogie.st(20, 4) [assert_2]: ❌ fail +BooleanQuantification2.core.st(18, 4) [assert_0]: ✅ pass +BooleanQuantification2.core.st(19, 4) [assert_1]: ✅ pass +BooleanQuantification2.core.st(20, 4) [assert_2]: ❌ fail Finished with 2 goals passed, 1 failed. diff --git a/Tools/BoogieToStrata/Tests/Bubble.expect b/Tools/BoogieToStrata/Tests/Bubble.expect index b4fe61f41..b587d3af1 100644 --- a/Tools/BoogieToStrata/Tests/Bubble.expect +++ b/Tools/BoogieToStrata/Tests/Bubble.expect @@ -1,16 +1,16 @@ Successfully parsed. -Bubble.boogie.st(31, 4) [entry_invariant_0]: ✅ pass -Bubble.boogie.st(31, 4) [arbitrary_iter_maintain_invariant_0]: ✅ pass -Bubble.boogie.st(43, 4) [entry_invariant_0]: ✅ pass -Bubble.boogie.st(20, 2) [BubbleSort_ensures_1]: ✅ pass -Bubble.boogie.st(21, 2) [BubbleSort_ensures_2]: ✅ pass -Bubble.boogie.st(22, 2) [BubbleSort_ensures_3]: ✅ pass -Bubble.boogie.st(23, 2) [BubbleSort_ensures_4]: ✅ pass -Bubble.boogie.st(57, 8) [entry_invariant_1]: ✅ pass -Bubble.boogie.st(57, 8) [arbitrary_iter_maintain_invariant_1]: ✅ pass -Bubble.boogie.st(43, 4) [arbitrary_iter_maintain_invariant_0]: ✅ pass -Bubble.boogie.st(20, 2) [BubbleSort_ensures_1]: ✅ pass -Bubble.boogie.st(21, 2) [BubbleSort_ensures_2]: ✅ pass -Bubble.boogie.st(22, 2) [BubbleSort_ensures_3]: ✅ pass -Bubble.boogie.st(23, 2) [BubbleSort_ensures_4]: ✅ pass +Bubble.core.st(31, 4) [entry_invariant_0]: ✅ pass +Bubble.core.st(31, 4) [arbitrary_iter_maintain_invariant_0]: ✅ pass +Bubble.core.st(43, 4) [entry_invariant_0]: ✅ pass +Bubble.core.st(20, 2) [BubbleSort_ensures_1]: ✅ pass +Bubble.core.st(21, 2) [BubbleSort_ensures_2]: ✅ pass +Bubble.core.st(22, 2) [BubbleSort_ensures_3]: ✅ pass +Bubble.core.st(23, 2) [BubbleSort_ensures_4]: ✅ pass +Bubble.core.st(57, 8) [entry_invariant_1]: ✅ pass +Bubble.core.st(57, 8) [arbitrary_iter_maintain_invariant_1]: ✅ pass +Bubble.core.st(43, 4) [arbitrary_iter_maintain_invariant_0]: ✅ pass +Bubble.core.st(20, 2) [BubbleSort_ensures_1]: ✅ pass +Bubble.core.st(21, 2) [BubbleSort_ensures_2]: ✅ pass +Bubble.core.st(22, 2) [BubbleSort_ensures_3]: ✅ pass +Bubble.core.st(23, 2) [BubbleSort_ensures_4]: ✅ pass All 14 goals passed. diff --git a/Tools/BoogieToStrata/Tests/DivMod.expect b/Tools/BoogieToStrata/Tests/DivMod.expect index 927ad90ab..8e9c51c8e 100644 --- a/Tools/BoogieToStrata/Tests/DivMod.expect +++ b/Tools/BoogieToStrata/Tests/DivMod.expect @@ -1,8 +1,8 @@ Successfully parsed. -DivMod.boogie.st(25, 2) [T_from_E_ensures_1]: ✅ pass -DivMod.boogie.st(26, 2) [T_from_E_ensures_2]: ✅ pass -DivMod.boogie.st(27, 2) [T_from_E_ensures_3]: ✅ pass -DivMod.boogie.st(45, 2) [E_from_T_ensures_1]: ✅ pass -DivMod.boogie.st(46, 2) [E_from_T_ensures_2]: ✅ pass -DivMod.boogie.st(47, 2) [E_from_T_ensures_3]: ✅ pass +DivMod.core.st(25, 2) [T_from_E_ensures_1]: ✅ pass +DivMod.core.st(26, 2) [T_from_E_ensures_2]: ✅ pass +DivMod.core.st(27, 2) [T_from_E_ensures_3]: ✅ pass +DivMod.core.st(45, 2) [E_from_T_ensures_1]: ✅ pass +DivMod.core.st(46, 2) [E_from_T_ensures_2]: ✅ pass +DivMod.core.st(47, 2) [E_from_T_ensures_3]: ✅ pass All 6 goals passed. diff --git a/Tools/BoogieToStrata/Tests/Gauss.expect b/Tools/BoogieToStrata/Tests/Gauss.expect index a7602384a..9524cb15a 100644 --- a/Tools/BoogieToStrata/Tests/Gauss.expect +++ b/Tools/BoogieToStrata/Tests/Gauss.expect @@ -1,5 +1,5 @@ Successfully parsed. -Gauss.boogie.st(18, 4) [entry_invariant_0]: ✅ pass -Gauss.boogie.st(18, 4) [arbitrary_iter_maintain_invariant_0]: ✅ pass -Gauss.boogie.st(11, 2) [sum_ensures_1]: ✅ pass +Gauss.core.st(18, 4) [entry_invariant_0]: ✅ pass +Gauss.core.st(18, 4) [arbitrary_iter_maintain_invariant_0]: ✅ pass +Gauss.core.st(11, 2) [sum_ensures_1]: ✅ pass All 3 goals passed. diff --git a/Tools/BoogieToStrata/Tests/IfThenElse1.expect b/Tools/BoogieToStrata/Tests/IfThenElse1.expect index 801f61136..cbb8e9854 100644 --- a/Tools/BoogieToStrata/Tests/IfThenElse1.expect +++ b/Tools/BoogieToStrata/Tests/IfThenElse1.expect @@ -1,8 +1,8 @@ Successfully parsed. -IfThenElse1.boogie.st(18, 4) [assert_0]: ✅ pass -IfThenElse1.boogie.st(19, 4) [assert_1]: ✅ pass -IfThenElse1.boogie.st(34, 4) [assert_2]: ✅ pass -IfThenElse1.boogie.st(36, 4) [assert_3]: ✅ pass -IfThenElse1.boogie.st(48, 4) [assert_4]: ❌ fail -IfThenElse1.boogie.st(60, 4) [assert_5]: ❌ fail +IfThenElse1.core.st(18, 4) [assert_0]: ✅ pass +IfThenElse1.core.st(19, 4) [assert_1]: ✅ pass +IfThenElse1.core.st(34, 4) [assert_2]: ✅ pass +IfThenElse1.core.st(36, 4) [assert_3]: ✅ pass +IfThenElse1.core.st(48, 4) [assert_4]: ❌ fail +IfThenElse1.core.st(60, 4) [assert_5]: ❌ fail Finished with 4 goals passed, 2 failed. diff --git a/Tools/BoogieToStrata/Tests/Implies.expect b/Tools/BoogieToStrata/Tests/Implies.expect index a79cf3bca..4f4109232 100644 --- a/Tools/BoogieToStrata/Tests/Implies.expect +++ b/Tools/BoogieToStrata/Tests/Implies.expect @@ -1,14 +1,14 @@ Successfully parsed. -Implies.boogie.st(24, 4) [assert_0]: ✅ pass -Implies.boogie.st(25, 4) [assert_1]: 🟡 unknown -Implies.boogie.st(26, 4) [assert_2]: ✅ pass -Implies.boogie.st(27, 4) [assert_3]: 🟡 unknown -Implies.boogie.st(36, 4) [assert_4]: 🟡 unknown -Implies.boogie.st(37, 4) [assert_5]: 🟡 unknown -Implies.boogie.st(46, 4) [assert_6]: 🟡 unknown -Implies.boogie.st(47, 4) [assert_7]: 🟡 unknown -Implies.boogie.st(56, 4) [assert_8]: 🟡 unknown -Implies.boogie.st(57, 4) [assert_9]: 🟡 unknown -Implies.boogie.st(66, 4) [assert_10]: 🟡 unknown -Implies.boogie.st(67, 4) [assert_11]: 🟡 unknown +Implies.core.st(24, 4) [assert_0]: ✅ pass +Implies.core.st(25, 4) [assert_1]: 🟡 unknown +Implies.core.st(26, 4) [assert_2]: ✅ pass +Implies.core.st(27, 4) [assert_3]: 🟡 unknown +Implies.core.st(36, 4) [assert_4]: 🟡 unknown +Implies.core.st(37, 4) [assert_5]: 🟡 unknown +Implies.core.st(46, 4) [assert_6]: 🟡 unknown +Implies.core.st(47, 4) [assert_7]: 🟡 unknown +Implies.core.st(56, 4) [assert_8]: 🟡 unknown +Implies.core.st(57, 4) [assert_9]: 🟡 unknown +Implies.core.st(66, 4) [assert_10]: 🟡 unknown +Implies.core.st(67, 4) [assert_11]: 🟡 unknown Finished with 2 goals passed, 10 failed. diff --git a/Tools/BoogieToStrata/Tests/Lambda.expect b/Tools/BoogieToStrata/Tests/Lambda.expect index 94a7c31b8..21b6b17cc 100644 --- a/Tools/BoogieToStrata/Tests/Lambda.expect +++ b/Tools/BoogieToStrata/Tests/Lambda.expect @@ -1,14 +1,14 @@ Successfully parsed. -Lambda.boogie.st(39, 2) [P_ensures_0]: ✅ pass -Lambda.boogie.st(52, 4) [assert_0]: ✅ pass -Lambda.boogie.st(61, 4) [assert_1]: ✅ pass -Lambda.boogie.st(74, 4) [assert_2]: ✅ pass -Lambda.boogie.st(75, 4) [assert_3]: ✅ pass -Lambda.boogie.st(76, 4) [assert_4]: ✅ pass -Lambda.boogie.st(89, 4) [assert_5]: 🟡 unknown -Lambda.boogie.st(90, 4) [assert_6]: 🟡 unknown -Lambda.boogie.st(103, 4) [assert_7]: ✅ pass -Lambda.boogie.st(104, 4) [assert_8]: ✅ pass -Lambda.boogie.st(106, 4) [assert_9]: ✅ pass -Lambda.boogie.st(107, 4) [assert_10]: ✅ pass +Lambda.core.st(39, 2) [P_ensures_0]: ✅ pass +Lambda.core.st(52, 4) [assert_0]: ✅ pass +Lambda.core.st(61, 4) [assert_1]: ✅ pass +Lambda.core.st(74, 4) [assert_2]: ✅ pass +Lambda.core.st(75, 4) [assert_3]: ✅ pass +Lambda.core.st(76, 4) [assert_4]: ✅ pass +Lambda.core.st(89, 4) [assert_5]: 🟡 unknown +Lambda.core.st(90, 4) [assert_6]: 🟡 unknown +Lambda.core.st(103, 4) [assert_7]: ✅ pass +Lambda.core.st(104, 4) [assert_8]: ✅ pass +Lambda.core.st(106, 4) [assert_9]: ✅ pass +Lambda.core.st(107, 4) [assert_10]: ✅ pass Finished with 10 goals passed, 2 failed. diff --git a/Tools/BoogieToStrata/Tests/McCarthy-91.expect b/Tools/BoogieToStrata/Tests/McCarthy-91.expect index 43c653c88..ad0e41e0c 100644 --- a/Tools/BoogieToStrata/Tests/McCarthy-91.expect +++ b/Tools/BoogieToStrata/Tests/McCarthy-91.expect @@ -1,4 +1,4 @@ Successfully parsed. -McCarthy-91.boogie.st(10, 2) [F_ensures_0]: ✅ pass -McCarthy-91.boogie.st(11, 2) [F_ensures_1]: ✅ pass +McCarthy-91.core.st(10, 2) [F_ensures_0]: ✅ pass +McCarthy-91.core.st(11, 2) [F_ensures_1]: ✅ pass All 2 goals passed. diff --git a/Tools/BoogieToStrata/Tests/Quantifiers.expect b/Tools/BoogieToStrata/Tests/Quantifiers.expect index 378050fa9..b7bca55e6 100644 --- a/Tools/BoogieToStrata/Tests/Quantifiers.expect +++ b/Tools/BoogieToStrata/Tests/Quantifiers.expect @@ -1,16 +1,16 @@ Successfully parsed. -Quantifiers.boogie.st(39, 4) [assert_0]: ✅ pass -Quantifiers.boogie.st(51, 4) [assert_1]: 🟡 unknown -Quantifiers.boogie.st(64, 4) [assert_2]: ✅ pass -Quantifiers.boogie.st(76, 4) [assert_3]: 🟡 unknown -Quantifiers.boogie.st(89, 4) [assert_4]: ✅ pass -Quantifiers.boogie.st(99, 4) [assert_5]: 🟡 unknown -Quantifiers.boogie.st(110, 4) [assert_6]: 🟡 unknown -Quantifiers.boogie.st(123, 4) [assert_7]: ✅ pass -Quantifiers.boogie.st(134, 4) [assert_8]: ✅ pass -Quantifiers.boogie.st(146, 4) [assert_9]: ✅ pass -Quantifiers.boogie.st(158, 4) [assert_10]: ✅ pass -Quantifiers.boogie.st(170, 4) [assert_11]: ✅ pass -Quantifiers.boogie.st(183, 4) [assert_12]: ✅ pass -Quantifiers.boogie.st(195, 4) [assert_13]: ✅ pass +Quantifiers.core.st(39, 4) [assert_0]: ✅ pass +Quantifiers.core.st(51, 4) [assert_1]: 🟡 unknown +Quantifiers.core.st(64, 4) [assert_2]: ✅ pass +Quantifiers.core.st(76, 4) [assert_3]: 🟡 unknown +Quantifiers.core.st(89, 4) [assert_4]: ✅ pass +Quantifiers.core.st(99, 4) [assert_5]: 🟡 unknown +Quantifiers.core.st(110, 4) [assert_6]: 🟡 unknown +Quantifiers.core.st(123, 4) [assert_7]: ✅ pass +Quantifiers.core.st(134, 4) [assert_8]: ✅ pass +Quantifiers.core.st(146, 4) [assert_9]: ✅ pass +Quantifiers.core.st(158, 4) [assert_10]: ✅ pass +Quantifiers.core.st(170, 4) [assert_11]: ✅ pass +Quantifiers.core.st(183, 4) [assert_12]: ✅ pass +Quantifiers.core.st(195, 4) [assert_13]: ✅ pass Finished with 10 goals passed, 4 failed. diff --git a/Tools/BoogieToStrata/Tests/TypeSynonyms2.expect b/Tools/BoogieToStrata/Tests/TypeSynonyms2.expect index d8a27a7e2..266a886bf 100644 --- a/Tools/BoogieToStrata/Tests/TypeSynonyms2.expect +++ b/Tools/BoogieToStrata/Tests/TypeSynonyms2.expect @@ -1,3 +1,3 @@ Successfully parsed. -TypeSynonyms2.boogie.st(27, 4) [assert_0]: ✅ pass +TypeSynonyms2.core.st(27, 4) [assert_0]: ✅ pass All 1 goals passed. diff --git a/Tools/BoogieToStrata/Tests/Unique.expect b/Tools/BoogieToStrata/Tests/Unique.expect index e130ab367..439745846 100644 --- a/Tools/BoogieToStrata/Tests/Unique.expect +++ b/Tools/BoogieToStrata/Tests/Unique.expect @@ -1,6 +1,6 @@ Successfully parsed. -Unique.boogie.st(28, 4) [assert_0]: ❌ fail -Unique.boogie.st(29, 4) [assert_1]: ✅ pass -Unique.boogie.st(38, 4) [assert_2]: ❌ fail -Unique.boogie.st(39, 4) [assert_3]: ✅ pass +Unique.core.st(28, 4) [assert_0]: ❌ fail +Unique.core.st(29, 4) [assert_1]: ✅ pass +Unique.core.st(38, 4) [assert_2]: ❌ fail +Unique.core.st(39, 4) [assert_3]: ✅ pass Finished with 2 goals passed, 2 failed. diff --git a/Tools/BoogieToStrata/Tests/Where.expect b/Tools/BoogieToStrata/Tests/Where.expect index ec3df71b9..f83b927b8 100644 --- a/Tools/BoogieToStrata/Tests/Where.expect +++ b/Tools/BoogieToStrata/Tests/Where.expect @@ -1,14 +1,14 @@ Successfully parsed. -Where.boogie.st(16, 4) [assert_0]: ✅ pass -Where.boogie.st(17, 4) [assert_1]: ✅ pass -Where.boogie.st(18, 4) [assert_2]: ❌ fail -Where.boogie.st(34, 4) [assert_3]: ✅ pass -Where.boogie.st(37, 4) [assert_4]: ✅ pass -Where.boogie.st(38, 4) [assert_5]: ❌ fail -Where.boogie.st(55, 4) [assert_6]: ❌ fail -Where.boogie.st(73, 4) [assert_7]: ✅ pass -Where.boogie.st(74, 4) [assert_8]: ❌ fail -Where.boogie.st(91, 4) [assert_9]: ✅ pass -Where.boogie.st(96, 4) [assert_10]: ✅ pass -Where.boogie.st(97, 4) [assert_11]: ❌ fail +Where.core.st(16, 4) [assert_0]: ✅ pass +Where.core.st(17, 4) [assert_1]: ✅ pass +Where.core.st(18, 4) [assert_2]: ❌ fail +Where.core.st(34, 4) [assert_3]: ✅ pass +Where.core.st(37, 4) [assert_4]: ✅ pass +Where.core.st(38, 4) [assert_5]: ❌ fail +Where.core.st(55, 4) [assert_6]: ❌ fail +Where.core.st(73, 4) [assert_7]: ✅ pass +Where.core.st(74, 4) [assert_8]: ❌ fail +Where.core.st(91, 4) [assert_9]: ✅ pass +Where.core.st(96, 4) [assert_10]: ✅ pass +Where.core.st(97, 4) [assert_11]: ❌ fail Finished with 7 goals passed, 5 failed. diff --git a/Tools/BoogieToStrata/Tests/bv9.expect b/Tools/BoogieToStrata/Tests/bv9.expect index 1ce03c2c9..a686951f7 100644 --- a/Tools/BoogieToStrata/Tests/bv9.expect +++ b/Tools/BoogieToStrata/Tests/bv9.expect @@ -1,3 +1,3 @@ Successfully parsed. -bv9.boogie.st(22, 4) [assert_0]: ✅ pass +bv9.core.st(22, 4) [assert_0]: ✅ pass All 1 goals passed. diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 99cca3561..11fc28009 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -300,7 +300,7 @@ some next steps to explore: to leverage any analysis available for the latter. You may also want to verify any such dialect transformations, i.e., prove that they are semantics-preserving. One such example in Strata is for call - eliminiation in Boogie, [here](../Strata/Transform/). + eliminiation in Strata Core, [here](../Strata/Transform/). - **Create a Language Frontend**: Develop a parser to translate the concrete syntax of your language of interest to Strata. From a10f32b8b1f07d370b4ec770e59683ca3c833f68 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 15:37:20 -0600 Subject: [PATCH 09/19] BoogieGenM -> CoreGenM, and BoogieEval BoogieStore Boogie.true/false in the same pattern --- Strata/Languages/Core/CoreGen.lean | 2 +- Strata/Languages/Core/StatementSemantics.lean | 48 ++-- .../Core/StatementSemanticsProps.lean | 2 +- Strata/Transform/CallElimCorrect.lean | 50 ++-- Strata/Transform/CoreTransform.lean | 16 +- StrataTest/Backends/CBMC/run_tests.sh | 2 +- .../Core/Examples/DDMAxiomsExtraction.lean | 258 +++++++++--------- .../Languages/Core/Examples/SimpleProc.lean | 2 +- StrataTest/Languages/Core/ExprEvalTest.lean | 6 +- StrataTest/Transform/DetToNondet.lean | 6 +- StrataTest/Transform/ProcedureInlining.lean | 2 +- 11 files changed, 197 insertions(+), 197 deletions(-) diff --git a/Strata/Languages/Core/CoreGen.lean b/Strata/Languages/Core/CoreGen.lean index aafa1b1a4..3a56c46e2 100644 --- a/Strata/Languages/Core/CoreGen.lean +++ b/Strata/Languages/Core/CoreGen.lean @@ -108,6 +108,6 @@ instance : LabelGen.WFLabelGen CoreIdent CoreGenState where constructor wf_gen := CoreGenState.WFMono -abbrev BoogieGenM := StateM CoreGenState +abbrev CoreGenM := StateM CoreGenState end Core diff --git a/Strata/Languages/Core/StatementSemantics.lean b/Strata/Languages/Core/StatementSemantics.lean index 25d68fe43..32ebca1d6 100644 --- a/Strata/Languages/Core/StatementSemantics.lean +++ b/Strata/Languages/Core/StatementSemantics.lean @@ -30,24 +30,24 @@ instance : HasFvar Core.Expression where | _ => none @[match_pattern] -def Boogie.true : Core.Expression.Expr := .boolConst () Bool.true +def Core.true : Core.Expression.Expr := .boolConst () Bool.true @[match_pattern] -def Boogie.false : Core.Expression.Expr := .boolConst () Bool.false +def Core.false : Core.Expression.Expr := .boolConst () Bool.false instance : HasBool Core.Expression where - tt := Boogie.true - ff := Boogie.false + tt := Core.true + ff := Core.false instance : HasNot Core.Expression where not - | Boogie.true => Boogie.false - | Boogie.false => Boogie.true + | Core.true => Core.false + | Core.false => Core.true | e => Lambda.LExpr.app () (Lambda.LFunc.opExpr (T:=CoreLParams) Lambda.boolNotFunc) e -abbrev BoogieEval := SemanticEval Expression -abbrev BoogieStore := SemanticStore Expression +abbrev CoreEval := SemanticEval Expression +abbrev CoreStore := SemanticStore Expression -structure WellFormedBoogieEvalCong (δ : BoogieEval): Prop where +structure WellFormedCoreEvalCong (δ : CoreEval): Prop where abscongr: (∀ σ σ' e₁ e₁' , δ σ e₁ = δ σ' e₁' → (∀ ty m, δ σ (.abs ty m e₁) = δ σ' (.abs ty m e₁'))) @@ -163,7 +163,7 @@ def updatedStates -- https://dafny.org/latest/DafnyRef/DafnyRef#sec-two-state -- where this condition will be asserted at procedures utilizing those two-state functions -/ -def WellFormedBoogieEvalTwoState (δ : BoogieEval) (σ₀ σ : BoogieStore) : Prop := +def WellFormedCoreEvalTwoState (δ : CoreEval) (σ₀ σ : CoreStore) : Prop := open Core.OldExpressions in (∃ vs vs' σ₁, HavocVars σ₀ vs σ₁ ∧ InitVars σ₁ vs' σ) ∧ (∀ vs vs' σ₀ σ₁ σ, @@ -181,8 +181,8 @@ def WellFormedBoogieEvalTwoState (δ : BoogieEval) (σ₀ σ : BoogieStore) : Pr -- Might not be needed if we assume all expressions are normalized (∀ e σ, δ σ e = δ σ (normalizeOldExpr e)) -inductive EvalCommand : (String → Option Procedure) → BoogieEval → - BoogieStore → Command → BoogieStore → Prop where +inductive EvalCommand : (String → Option Procedure) → CoreEval → + CoreStore → Command → CoreStore → Prop where | cmd_sem {π δ σ c σ'} : Imperative.EvalCmd (P:=Expression) δ σ c σ' → ---- @@ -206,7 +206,7 @@ inductive EvalCommand : (String → Option Procedure) → BoogieEval → WellFormedSemanticEvalVal δ → WellFormedSemanticEvalVar δ → WellFormedSemanticEvalBool δ → - WellFormedBoogieEvalTwoState δ σ₀ σ → + WellFormedCoreEvalTwoState δ σ₀ σ → isDefinedOver (HasVarsTrans.allVarsTrans π) σ (Statement.call lhs n args) → @@ -233,16 +233,16 @@ inductive EvalCommand : (String → Option Procedure) → BoogieEval → ---- EvalCommand π δ σ (CmdExt.call lhs n args) σ' -abbrev EvalStatement (π : String → Option Procedure) : BoogieEval → - BoogieStore → Statement → BoogieStore → Prop := +abbrev EvalStatement (π : String → Option Procedure) : CoreEval → + CoreStore → Statement → CoreStore → Prop := Imperative.EvalStmt Expression Command (EvalCommand π) -abbrev EvalStatements (π : String → Option Procedure) : BoogieEval → - BoogieStore → List Statement → BoogieStore → Prop := +abbrev EvalStatements (π : String → Option Procedure) : CoreEval → + CoreStore → List Statement → CoreStore → Prop := Imperative.EvalBlock Expression Command (EvalCommand π) -inductive EvalCommandContract : (String → Option Procedure) → BoogieEval → - BoogieStore → Command → BoogieStore → Prop where +inductive EvalCommandContract : (String → Option Procedure) → CoreEval → + CoreStore → Command → CoreStore → Prop where | cmd_sem {π δ σ c σ'} : Imperative.EvalCmd (P:=Expression) δ σ c σ' → ---- @@ -255,7 +255,7 @@ inductive EvalCommandContract : (String → Option Procedure) → BoogieEval WellFormedSemanticEvalVal δ → WellFormedSemanticEvalVar δ → WellFormedSemanticEvalBool δ → - WellFormedBoogieEvalTwoState δ σ₀ σ → + WellFormedCoreEvalTwoState δ σ₀ σ → isDefinedOver (HasVarsTrans.allVarsTrans π) σ (Statement.call lhs n args) → @@ -282,10 +282,10 @@ inductive EvalCommandContract : (String → Option Procedure) → BoogieEval ---- EvalCommandContract π δ σ (.call lhs n args) σ' -abbrev EvalStatementContract (π : String → Option Procedure) : BoogieEval → - BoogieStore → Statement → BoogieStore → Prop := +abbrev EvalStatementContract (π : String → Option Procedure) : CoreEval → + CoreStore → Statement → CoreStore → Prop := Imperative.EvalStmt Expression Command (EvalCommandContract π) -abbrev EvalStatementsContract (π : String → Option Procedure) : BoogieEval → - BoogieStore → List Statement → BoogieStore → Prop := +abbrev EvalStatementsContract (π : String → Option Procedure) : CoreEval → + CoreStore → List Statement → CoreStore → Prop := Imperative.EvalBlock Expression Command (EvalCommandContract π) diff --git a/Strata/Languages/Core/StatementSemanticsProps.lean b/Strata/Languages/Core/StatementSemanticsProps.lean index c931a5814..20f943b5d 100644 --- a/Strata/Languages/Core/StatementSemanticsProps.lean +++ b/Strata/Languages/Core/StatementSemanticsProps.lean @@ -2088,7 +2088,7 @@ theorem EvalStmtRefinesContract : We work around this by requiring this condition at `EvalExpressions`. -/ theorem EvalExpressionIsDefined : - WellFormedBoogieEvalCong δ → + WellFormedCoreEvalCong δ → WellFormedSemanticEvalVar δ → (δ σ e).isSome → isDefined σ (HasVarsPure.getVars e) := by diff --git a/Strata/Transform/CallElimCorrect.lean b/Strata/Transform/CallElimCorrect.lean index 448495187..ba2621629 100644 --- a/Strata/Transform/CallElimCorrect.lean +++ b/Strata/Transform/CallElimCorrect.lean @@ -333,9 +333,9 @@ theorem updatedStateIsDefinedMono : by_cases Heq : (k' = k) <;> simp [Heq] case neg => assumption -theorem EvalExpressionUpdatedState {δ : BoogieEval}: +theorem EvalExpressionUpdatedState {δ : CoreEval}: Imperative.WellFormedSemanticEvalVar δ → -Core.WellFormedBoogieEvalCong δ → +Core.WellFormedCoreEvalCong δ → Imperative.WellFormedSemanticEvalVal δ → ¬ k ∈ (Imperative.HasVarsPure.getVars e) → δ σ e = some v' → @@ -364,9 +364,9 @@ Imperative.WellFormedSemanticEvalVal δ → case eq m e1 e2 e1ih e2ih => apply Hwfc.eqcongr <;> grind -theorem EvalExpressionsUpdatedState {δ : BoogieEval} : +theorem EvalExpressionsUpdatedState {δ : CoreEval} : Imperative.WellFormedSemanticEvalVar δ → - Core.WellFormedBoogieEvalCong δ → + Core.WellFormedCoreEvalCong δ → Imperative.WellFormedSemanticEvalVal δ → ¬ k ∈ es.flatMap Imperative.HasVarsPure.getVars → EvalExpressions (P:=Core.Expression) δ σ es vs → @@ -389,9 +389,9 @@ theorem EvalExpressionsUpdatedState {δ : BoogieEval} : . apply EvalExpressionUpdatedState <;> simp_all . apply ih <;> simp_all -theorem EvalExpressionUpdatedStates {δ : BoogieEval} : +theorem EvalExpressionUpdatedStates {δ : CoreEval} : Imperative.WellFormedSemanticEvalVar δ → - Core.WellFormedBoogieEvalCong δ → + Core.WellFormedCoreEvalCong δ → Imperative.WellFormedSemanticEvalVal δ → ks'.length = vs'.length → ks'.Nodup → @@ -420,9 +420,9 @@ theorem EvalExpressionUpdatedStates {δ : BoogieEval} : simp_all . rw [List.unzip_zip] <;> grind -theorem EvalExpressionsUpdatedStates {δ : BoogieEval} : +theorem EvalExpressionsUpdatedStates {δ : CoreEval} : Imperative.WellFormedSemanticEvalVar δ → - Core.WellFormedBoogieEvalCong δ → + Core.WellFormedCoreEvalCong δ → Imperative.WellFormedSemanticEvalVal δ → ks'.length = vs'.length → ks'.Nodup → @@ -702,7 +702,7 @@ theorem EvalStatementContractInit : theorem EvalStatementsContractInits : Imperative.WellFormedSemanticEvalVar δ → Imperative.WellFormedSemanticEvalVal δ → - WellFormedBoogieEvalCong δ → + WellFormedCoreEvalCong δ → -- the generated old variable names shouldn't overlap with original variables trips.unzip.1.unzip.1.Disjoint (List.flatMap (Imperative.HasVarsPure.getVars (P:=Expression)) trips.unzip.2) → List.Nodup (trips.unzip.1.unzip.1) → @@ -1110,7 +1110,7 @@ case cons h t ih => because then we can't say anything about the stores due to not knowing the exact form of the expressions -/ theorem Lambda.LExpr.substFvarCorrect : - Core.WellFormedBoogieEvalCong δ → + Core.WellFormedCoreEvalCong δ → Imperative.WellFormedSemanticEvalVar (P:=Expression) δ → Imperative.WellFormedSemanticEvalVal (P:=Expression) δ → Imperative.substStores σ σ' [(fro, to)] → @@ -1210,7 +1210,7 @@ theorem Lambda.LExpr.substFvarCorrect : apply Hwfc.eqcongr <;> grind theorem Lambda.LExpr.substFvarsCorrectZero : - Core.WellFormedBoogieEvalCong δ → + Core.WellFormedCoreEvalCong δ → Imperative.WellFormedSemanticEvalVar δ → Imperative.WellFormedSemanticEvalVal δ → Imperative.invStores σ σ' (Imperative.HasVarsPure.getVars e) → @@ -1500,7 +1500,7 @@ case eq fn e fn_ih e_ih => cases e_ih <;> simp_all theorem Lambda.LExpr.substFvarsCorrect : - WellFormedBoogieEvalCong δ → + WellFormedCoreEvalCong δ → Imperative.WellFormedSemanticEvalVar (P:=Expression) δ → Imperative.WellFormedSemanticEvalVal (P:=Expression) δ → fro.length = to.length → @@ -1572,7 +1572,7 @@ theorem createAssertsCorrect : Imperative.WellFormedSemanticEvalVar δ → Imperative.WellFormedSemanticEvalVal δ → -- TODO: remove congruence of old expressions, and require pre to contain no old expressions - Core.WellFormedBoogieEvalCong δ → + Core.WellFormedCoreEvalCong δ → ks.length = ks'.length → Imperative.substNodup (ks.zip ks') → Imperative.substDefined σA σ' (ks.zip ks') → @@ -1630,7 +1630,7 @@ theorem createAssumesCorrect : Imperative.WellFormedSemanticEvalBool δ → Imperative.WellFormedSemanticEvalVar δ → Imperative.WellFormedSemanticEvalVal δ → - Core.WellFormedBoogieEvalCong δ → + Core.WellFormedCoreEvalCong δ → ks.length = ks'.length → Imperative.substNodup (ks.zip ks') → Imperative.substDefined σA σ' (ks.zip ks') → @@ -1719,8 +1719,8 @@ theorem createOldStoreSubstEq : theorem substOldCorrect : Imperative.WellFormedSemanticEvalVar δ → Imperative.WellFormedSemanticEvalVal δ → - Core.WellFormedBoogieEvalCong δ → - Core.WellFormedBoogieEvalTwoState δ σ₀ σ → + Core.WellFormedCoreEvalCong δ → + Core.WellFormedCoreEvalTwoState δ σ₀ σ → OldExpressions.NormalizedOldExpr e → --Imperative.invStores σ₀ σ -- ((OldExpressions.extractOldExprVars e).removeAll [fro]) → @@ -1752,7 +1752,7 @@ theorem substOldCorrect : . -- is an old var that is substituted next x ty eq => simp [eq] at * - simp [WellFormedBoogieEvalTwoState] at Hwf2 + simp [WellFormedCoreEvalTwoState] at Hwf2 cases Hwf2.1 with | intro vs Hwf2' => cases Hwf2' with @@ -1951,12 +1951,12 @@ case cons h t ih => exact fun a => Hne (Eq.symm a) simp_all -theorem updatedStateOldWellFormedBoogieEvalTwoState : +theorem updatedStateOldWellFormedCoreEvalTwoState : σ k = some v → - WellFormedBoogieEvalTwoState δ σ₀ σ → - WellFormedBoogieEvalTwoState δ (updatedState σ₀ k v) σ := by + WellFormedCoreEvalTwoState δ σ₀ σ → + WellFormedCoreEvalTwoState δ (updatedState σ₀ k v) σ := by intros Hsome Hwf2 - simp [WellFormedBoogieEvalTwoState] at * + simp [WellFormedCoreEvalTwoState] at * refine ⟨?_, Hwf2.2⟩ cases Hwf2.1 with | intro vs Hwf2 => @@ -2128,8 +2128,8 @@ theorem substOldExpr_cons: theorem substsOldCorrect : Imperative.WellFormedSemanticEvalVar δ → Imperative.WellFormedSemanticEvalVal δ → - Core.WellFormedBoogieEvalCong δ → - Core.WellFormedBoogieEvalTwoState δ σ₀ σ → + Core.WellFormedCoreEvalCong δ → + Core.WellFormedCoreEvalTwoState δ σ₀ σ → OldExpressions.NormalizedOldExpr e → Imperative.substStores σ₀ σ (createOldStoreSubst oldTrips) → Imperative.substDefined σ₀ σ (createOldStoreSubst oldTrips) → @@ -3276,7 +3276,7 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : -- all global variables in p exist in σ (∀ gk, (p.find? .var gk).isSome → (σ gk).isSome) → EvalStatementsContract π δ σ [st] σ' → - WellFormedBoogieEvalCong δ → + WellFormedCoreEvalCong δ → WF.WFStatementsProp p [st] → WF.WFProgramProp p → CoreGenState.WF γ → @@ -4288,7 +4288,7 @@ theorem callElimStatementCorrect [LawfulBEq Expression.Expr] : . assumption . assumption -- wfTwoState, should be provable by setting inits to the oldVars created - . simp [WellFormedBoogieEvalTwoState] + . simp [WellFormedCoreEvalTwoState] refine ⟨?_, ?_, Hwf2.2⟩ . -- split into havoc and init, by setting inits to the oldVars created simp [← HσR₁] diff --git a/Strata/Transform/CoreTransform.lean b/Strata/Transform/CoreTransform.lean index e4c1cdf96..d4bd7664b 100644 --- a/Strata/Transform/CoreTransform.lean +++ b/Strata/Transform/CoreTransform.lean @@ -34,18 +34,18 @@ def createFvars (ident : List Expression.Ident) := ident.map createFvar def genIdent (ident : Expression.Ident) (pf : String → String) - : BoogieGenM Expression.Ident := + : CoreGenM Expression.Ident := CoreGenState.gen (pf ident.name) /-- Generate identifiers in the form of arg_... that can be used to reduce argument expressions to temporary variables. -/ def genArgExprIdent - : BoogieGenM Expression.Ident := + : CoreGenM Expression.Ident := genIdent "arg" tmpVarPrefix def genArgExprIdents (n:Nat) - : BoogieGenM (List Expression.Ident) := + : CoreGenM (List Expression.Ident) := List.mapM (fun _ => genArgExprIdent) (List.replicate n ()) /-- @@ -53,11 +53,11 @@ Retrieves a fresh identifier from the counter generator the given identifier "id Assumes that ident contains no duplicates -/ def genOutExprIdent (ident : Expression.Ident) - : BoogieGenM Expression.Ident := + : CoreGenM Expression.Ident := genIdent ident tmpVarPrefix def genOutExprIdents (idents : List Expression.Ident) - : BoogieGenM (List Expression.Ident) + : CoreGenM (List Expression.Ident) := List.mapM genOutExprIdent idents /-- @@ -65,11 +65,11 @@ Retrieves a fresh identifier from the counter generator the given identifier "id Assumes that ident contains no duplicates -/ def genOldExprIdent (ident : Expression.Ident) - : BoogieGenM Expression.Ident := + : CoreGenM Expression.Ident := genIdent ident oldVarPrefix def genOldExprIdents (idents : List Expression.Ident) - : BoogieGenM (List Expression.Ident) + : CoreGenM (List Expression.Ident) := List.mapM genOldExprIdent idents /-- Checks whether a variable `ident` can be found in program `p` -/ @@ -78,7 +78,7 @@ def isGlobalVar (p : Program) (ident : Expression.Ident) : Bool := abbrev Err := String -abbrev CoreTransformM := ExceptT Err BoogieGenM +abbrev CoreTransformM := ExceptT Err CoreGenM def getIdentTy? (p : Program) (id : Expression.Ident) := p.getVarTy? id diff --git a/StrataTest/Backends/CBMC/run_tests.sh b/StrataTest/Backends/CBMC/run_tests.sh index b5e27352d..f83f02c4d 100755 --- a/StrataTest/Backends/CBMC/run_tests.sh +++ b/StrataTest/Backends/CBMC/run_tests.sh @@ -5,7 +5,7 @@ echo "First: tests for the C-like AST interface." pushd ../../../ -echo "Boogie -> CBMC: illustrates verification fail." +echo "Strata Core -> CBMC: illustrates verification fail." echo "----------------------------------------------------------------------" Strata/Backends/CBMC/run_strata_cbmc.sh Strata/Backends/CBMC/tests/simpleTest.core.st diff --git a/StrataTest/Languages/Core/Examples/DDMAxiomsExtraction.lean b/StrataTest/Languages/Core/Examples/DDMAxiomsExtraction.lean index cfbe54864..539731c45 100644 --- a/StrataTest/Languages/Core/Examples/DDMAxiomsExtraction.lean +++ b/StrataTest/Languages/Core/Examples/DDMAxiomsExtraction.lean @@ -10,7 +10,7 @@ import Strata.Languages.Core.Verifier --------------------------------------------------------------------- namespace Strata --- Example Boogie program with axioms +-- Example Strata Core program with axioms def examplePgm := #strata program Core; @@ -21,7 +21,7 @@ axiom [updatePreserves]: forall m: Map k v, okk: k, kk: k, vv: v :: m[kk := vv][ #end /-- - This function extracts the Boogie.Decl in the given program that are axiom declarations + This function extracts the Core.Decl in the given program that are axiom declarations -/ def extractAxiomsDecl (prg: Core.Program) : (List Core.Decl) := let rec loop (acc: List Core.Decl) (l: List Core.Decl): List Core.Decl := @@ -94,302 +94,302 @@ axiom [updatePreserves]:forall((((m):(Map v k)),((okk):(k))),((kk):(k))),((vv):( #eval IO.println examplePgm.format.render /-- -info: #[{ ann := { start := { byteIdx := 291 }, stop := { byteIdx := 298 } }, +info: #[{ ann := { start := { byteIdx := 296 }, stop := { byteIdx := 303 } }, name := { dialect := "Core", name := "command_typedecl" }, args := - ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 296 }, stop := { byteIdx := 297 } } "k")).push - (ArgF.option { start := { byteIdx := 297 }, stop := { byteIdx := 297 } } none) }, - { ann := { start := { byteIdx := 299 }, stop := { byteIdx := 306 } }, + ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 301 }, stop := { byteIdx := 302 } } "k")).push + (ArgF.option { start := { byteIdx := 302 }, stop := { byteIdx := 302 } } none) }, + { ann := { start := { byteIdx := 304 }, stop := { byteIdx := 311 } }, name := { dialect := "Core", name := "command_typedecl" }, args := - ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 304 }, stop := { byteIdx := 305 } } "v")).push - (ArgF.option { start := { byteIdx := 305 }, stop := { byteIdx := 305 } } none) }, - { ann := { start := { byteIdx := 307 }, stop := { byteIdx := 386 } }, + ((Array.mkEmpty 2).push (ArgF.ident { start := { byteIdx := 309 }, stop := { byteIdx := 310 } } "v")).push + (ArgF.option { start := { byteIdx := 310 }, stop := { byteIdx := 310 } } none) }, + { ann := { start := { byteIdx := 312 }, stop := { byteIdx := 391 } }, name := { dialect := "Core", name := "command_axiom" }, args := ((Array.mkEmpty 2).push - (ArgF.option { start := { byteIdx := 313 }, stop := { byteIdx := 328 } } + (ArgF.option { start := { byteIdx := 318 }, stop := { byteIdx := 333 } } (some (ArgF.op - { ann := { start := { byteIdx := 313 }, stop := { byteIdx := 328 } }, + { ann := { start := { byteIdx := 318 }, stop := { byteIdx := 333 } }, name := { dialect := "Core", name := "label" }, args := (Array.mkEmpty 1).push - (ArgF.ident { start := { byteIdx := 314 }, stop := { byteIdx := 326 } } + (ArgF.ident { start := { byteIdx := 319 }, stop := { byteIdx := 331 } } "updateSelect") })))).push (ArgF.expr - (ExprF.app { start := { byteIdx := 329 }, stop := { byteIdx := 385 } } - (ExprF.app { start := { byteIdx := 329 }, stop := { byteIdx := 385 } } - (ExprF.fn { start := { byteIdx := 329 }, stop := { byteIdx := 385 } } + (ExprF.app { start := { byteIdx := 334 }, stop := { byteIdx := 390 } } + (ExprF.app { start := { byteIdx := 334 }, stop := { byteIdx := 390 } } + (ExprF.fn { start := { byteIdx := 334 }, stop := { byteIdx := 390 } } { dialect := "Core", name := "forall" }) (ArgF.op - { ann := { start := { byteIdx := 336 }, stop := { byteIdx := 360 } }, + { ann := { start := { byteIdx := 341 }, stop := { byteIdx := 365 } }, name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 336 }, stop := { byteIdx := 353 } }, + { ann := { start := { byteIdx := 341 }, stop := { byteIdx := 358 } }, name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 336 }, stop := { byteIdx := 346 } }, + { ann := { start := { byteIdx := 341 }, stop := { byteIdx := 351 } }, name := { dialect := "Core", name := "declAtom" }, args := (Array.mkEmpty 1).push (ArgF.op - { ann := { start := { byteIdx := 336 }, stop := { byteIdx := 346 } }, + { ann := { start := { byteIdx := 341 }, stop := { byteIdx := 351 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 336 }, - stop := { byteIdx := 337 } } + { start := { byteIdx := 341 }, + stop := { byteIdx := 342 } } "m")).push (ArgF.option - { start := { byteIdx := 339 }, stop := { byteIdx := 339 } } + { start := { byteIdx := 344 }, stop := { byteIdx := 344 } } none)).push (ArgF.type (TypeExprF.ident - { start := { byteIdx := 339 }, stop := { byteIdx := 342 } } + { start := { byteIdx := 344 }, stop := { byteIdx := 347 } } { dialect := "Core", name := "Map" } (((Array.mkEmpty 2).push (TypeExprF.fvar - { start := { byteIdx := 345 }, - stop := { byteIdx := 346 } } + { start := { byteIdx := 350 }, + stop := { byteIdx := 351 } } 1 (Array.mkEmpty 0))).push (TypeExprF.fvar - { start := { byteIdx := 343 }, - stop := { byteIdx := 344 } } + { start := { byteIdx := 348 }, + stop := { byteIdx := 349 } } 0 (Array.mkEmpty 0))))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 348 }, stop := { byteIdx := 353 } }, + { ann := { start := { byteIdx := 353 }, stop := { byteIdx := 358 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 348 }, stop := { byteIdx := 350 } } + { start := { byteIdx := 353 }, stop := { byteIdx := 355 } } "kk")).push - (ArgF.option { start := { byteIdx := 352 }, stop := { byteIdx := 352 } } + (ArgF.option { start := { byteIdx := 357 }, stop := { byteIdx := 357 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 352 }, stop := { byteIdx := 353 } } + (TypeExprF.fvar { start := { byteIdx := 357 }, stop := { byteIdx := 358 } } 0 (Array.mkEmpty 0))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 355 }, stop := { byteIdx := 360 } }, + { ann := { start := { byteIdx := 360 }, stop := { byteIdx := 365 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push - (ArgF.ident { start := { byteIdx := 355 }, stop := { byteIdx := 357 } } + (ArgF.ident { start := { byteIdx := 360 }, stop := { byteIdx := 362 } } "vv")).push - (ArgF.option { start := { byteIdx := 359 }, stop := { byteIdx := 359 } } none)).push + (ArgF.option { start := { byteIdx := 364 }, stop := { byteIdx := 364 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 359 }, stop := { byteIdx := 360 } } 1 + (TypeExprF.fvar { start := { byteIdx := 364 }, stop := { byteIdx := 365 } } 1 (Array.mkEmpty 0))) }) })) (ArgF.expr - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 385 } } - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 385 } } - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 385 } } - (ExprF.fn { start := { byteIdx := 364 }, stop := { byteIdx := 385 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 390 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 390 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 390 } } + (ExprF.fn { start := { byteIdx := 369 }, stop := { byteIdx := 390 } } { dialect := "Core", name := "equal" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 345 }, stop := { byteIdx := 346 } } 1 (Array.mkEmpty 0)))) + (TypeExprF.fvar { start := { byteIdx := 350 }, stop := { byteIdx := 351 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 379 } } - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 379 } } - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 379 } } - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 379 } } - (ExprF.fn { start := { byteIdx := 364 }, stop := { byteIdx := 379 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 384 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 384 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 384 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 384 } } + (ExprF.fn { start := { byteIdx := 369 }, stop := { byteIdx := 384 } } { dialect := "Core", name := "map_get" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 343 }, stop := { byteIdx := 344 } } 0 + (TypeExprF.fvar { start := { byteIdx := 348 }, stop := { byteIdx := 349 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 345 }, stop := { byteIdx := 346 } } 1 + (TypeExprF.fvar { start := { byteIdx := 350 }, stop := { byteIdx := 351 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } - (ExprF.app { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } - (ExprF.fn { start := { byteIdx := 364 }, stop := { byteIdx := 375 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 380 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 380 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 380 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 380 } } + (ExprF.app { start := { byteIdx := 369 }, stop := { byteIdx := 380 } } + (ExprF.fn { start := { byteIdx := 369 }, stop := { byteIdx := 380 } } { dialect := "Core", name := "map_set" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 343 }, stop := { byteIdx := 344 } } 0 + (TypeExprF.fvar { start := { byteIdx := 348 }, stop := { byteIdx := 349 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 345 }, stop := { byteIdx := 346 } } 1 + (TypeExprF.fvar { start := { byteIdx := 350 }, stop := { byteIdx := 351 } } 1 (Array.mkEmpty 0)))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 364 }, stop := { byteIdx := 365 } } 2))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 366 }, stop := { byteIdx := 368 } } 1))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 372 }, stop := { byteIdx := 374 } } 0))))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 376 }, stop := { byteIdx := 378 } } 1))))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 383 }, stop := { byteIdx := 385 } } 0)))))) }, - { ann := { start := { byteIdx := 387 }, stop := { byteIdx := 482 } }, + (ArgF.expr (ExprF.bvar { start := { byteIdx := 369 }, stop := { byteIdx := 370 } } 2))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 371 }, stop := { byteIdx := 373 } } 1))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 377 }, stop := { byteIdx := 379 } } 0))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 381 }, stop := { byteIdx := 383 } } 1))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 388 }, stop := { byteIdx := 390 } } 0)))))) }, + { ann := { start := { byteIdx := 392 }, stop := { byteIdx := 487 } }, name := { dialect := "Core", name := "command_axiom" }, args := ((Array.mkEmpty 2).push - (ArgF.option { start := { byteIdx := 393 }, stop := { byteIdx := 411 } } + (ArgF.option { start := { byteIdx := 398 }, stop := { byteIdx := 416 } } (some (ArgF.op - { ann := { start := { byteIdx := 393 }, stop := { byteIdx := 411 } }, + { ann := { start := { byteIdx := 398 }, stop := { byteIdx := 416 } }, name := { dialect := "Core", name := "label" }, args := (Array.mkEmpty 1).push - (ArgF.ident { start := { byteIdx := 394 }, stop := { byteIdx := 409 } } + (ArgF.ident { start := { byteIdx := 399 }, stop := { byteIdx := 414 } } "updatePreserves") })))).push (ArgF.expr - (ExprF.app { start := { byteIdx := 412 }, stop := { byteIdx := 481 } } - (ExprF.app { start := { byteIdx := 412 }, stop := { byteIdx := 481 } } - (ExprF.fn { start := { byteIdx := 412 }, stop := { byteIdx := 481 } } + (ExprF.app { start := { byteIdx := 417 }, stop := { byteIdx := 486 } } + (ExprF.app { start := { byteIdx := 417 }, stop := { byteIdx := 486 } } + (ExprF.fn { start := { byteIdx := 417 }, stop := { byteIdx := 486 } } { dialect := "Core", name := "forall" }) (ArgF.op - { ann := { start := { byteIdx := 419 }, stop := { byteIdx := 451 } }, + { ann := { start := { byteIdx := 424 }, stop := { byteIdx := 456 } }, name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 419 }, stop := { byteIdx := 444 } }, + { ann := { start := { byteIdx := 424 }, stop := { byteIdx := 449 } }, name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op - { ann := { start := { byteIdx := 419 }, stop := { byteIdx := 437 } }, + { ann := { start := { byteIdx := 424 }, stop := { byteIdx := 442 } }, name := { dialect := "Core", name := "declPush" }, args := ((Array.mkEmpty 2).push (ArgF.op { ann := - { start := { byteIdx := 419 }, stop := { byteIdx := 429 } }, + { start := { byteIdx := 424 }, stop := { byteIdx := 434 } }, name := { dialect := "Core", name := "declAtom" }, args := (Array.mkEmpty 1).push (ArgF.op { ann := - { start := { byteIdx := 419 }, - stop := { byteIdx := 429 } }, + { start := { byteIdx := 424 }, + stop := { byteIdx := 434 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 419 }, - stop := { byteIdx := 420 } } + { start := { byteIdx := 424 }, + stop := { byteIdx := 425 } } "m")).push (ArgF.option - { start := { byteIdx := 422 }, - stop := { byteIdx := 422 } } + { start := { byteIdx := 427 }, + stop := { byteIdx := 427 } } none)).push (ArgF.type (TypeExprF.ident - { start := { byteIdx := 422 }, - stop := { byteIdx := 425 } } + { start := { byteIdx := 427 }, + stop := { byteIdx := 430 } } { dialect := "Core", name := "Map" } (((Array.mkEmpty 2).push (TypeExprF.fvar - { start := { byteIdx := 428 }, - stop := { byteIdx := 429 } } + { start := { byteIdx := 433 }, + stop := { byteIdx := 434 } } 1 (Array.mkEmpty 0))).push (TypeExprF.fvar - { start := { byteIdx := 426 }, - stop := { byteIdx := 427 } } + { start := { byteIdx := 431 }, + stop := { byteIdx := 432 } } 0 (Array.mkEmpty 0))))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 431 }, stop := { byteIdx := 437 } }, + { ann := { start := { byteIdx := 436 }, stop := { byteIdx := 442 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 431 }, - stop := { byteIdx := 434 } } + { start := { byteIdx := 436 }, + stop := { byteIdx := 439 } } "okk")).push (ArgF.option - { start := { byteIdx := 436 }, stop := { byteIdx := 436 } } + { start := { byteIdx := 441 }, stop := { byteIdx := 441 } } none)).push (ArgF.type (TypeExprF.fvar - { start := { byteIdx := 436 }, stop := { byteIdx := 437 } } 0 + { start := { byteIdx := 441 }, stop := { byteIdx := 442 } } 0 (Array.mkEmpty 0))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 439 }, stop := { byteIdx := 444 } }, + { ann := { start := { byteIdx := 444 }, stop := { byteIdx := 449 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push (ArgF.ident - { start := { byteIdx := 439 }, stop := { byteIdx := 441 } } + { start := { byteIdx := 444 }, stop := { byteIdx := 446 } } "kk")).push - (ArgF.option { start := { byteIdx := 443 }, stop := { byteIdx := 443 } } + (ArgF.option { start := { byteIdx := 448 }, stop := { byteIdx := 448 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 443 }, stop := { byteIdx := 444 } } + (TypeExprF.fvar { start := { byteIdx := 448 }, stop := { byteIdx := 449 } } 0 (Array.mkEmpty 0))) }) })).push (ArgF.op - { ann := { start := { byteIdx := 446 }, stop := { byteIdx := 451 } }, + { ann := { start := { byteIdx := 451 }, stop := { byteIdx := 456 } }, name := { dialect := "Core", name := "bind_mk" }, args := (((Array.mkEmpty 3).push - (ArgF.ident { start := { byteIdx := 446 }, stop := { byteIdx := 448 } } + (ArgF.ident { start := { byteIdx := 451 }, stop := { byteIdx := 453 } } "vv")).push - (ArgF.option { start := { byteIdx := 450 }, stop := { byteIdx := 450 } } none)).push + (ArgF.option { start := { byteIdx := 455 }, stop := { byteIdx := 455 } } none)).push (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 450 }, stop := { byteIdx := 451 } } 1 + (TypeExprF.fvar { start := { byteIdx := 455 }, stop := { byteIdx := 456 } } 1 (Array.mkEmpty 0))) }) })) (ArgF.expr - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 481 } } - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 481 } } - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 481 } } - (ExprF.fn { start := { byteIdx := 455 }, stop := { byteIdx := 481 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 486 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 486 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 486 } } + (ExprF.fn { start := { byteIdx := 460 }, stop := { byteIdx := 486 } } { dialect := "Core", name := "equal" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 1 (Array.mkEmpty 0)))) + (TypeExprF.fvar { start := { byteIdx := 433 }, stop := { byteIdx := 434 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 471 } } - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 471 } } - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 471 } } - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 471 } } - (ExprF.fn { start := { byteIdx := 455 }, stop := { byteIdx := 471 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 476 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 476 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 476 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 476 } } + (ExprF.fn { start := { byteIdx := 460 }, stop := { byteIdx := 476 } } { dialect := "Core", name := "map_get" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 426 }, stop := { byteIdx := 427 } } 0 + (TypeExprF.fvar { start := { byteIdx := 431 }, stop := { byteIdx := 432 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 1 + (TypeExprF.fvar { start := { byteIdx := 433 }, stop := { byteIdx := 434 } } 1 (Array.mkEmpty 0)))) (ArgF.expr - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } - (ExprF.app { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } - (ExprF.fn { start := { byteIdx := 455 }, stop := { byteIdx := 466 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 471 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 471 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 471 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 471 } } + (ExprF.app { start := { byteIdx := 460 }, stop := { byteIdx := 471 } } + (ExprF.fn { start := { byteIdx := 460 }, stop := { byteIdx := 471 } } { dialect := "Core", name := "map_set" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 426 }, stop := { byteIdx := 427 } } 0 + (TypeExprF.fvar { start := { byteIdx := 431 }, stop := { byteIdx := 432 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 1 + (TypeExprF.fvar { start := { byteIdx := 433 }, stop := { byteIdx := 434 } } 1 (Array.mkEmpty 0)))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 455 }, stop := { byteIdx := 456 } } 3))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 457 }, stop := { byteIdx := 459 } } 1))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 463 }, stop := { byteIdx := 465 } } 0))))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 467 }, stop := { byteIdx := 470 } } 2))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 460 }, stop := { byteIdx := 461 } } 3))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 462 }, stop := { byteIdx := 464 } } 1))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 468 }, stop := { byteIdx := 470 } } 0))))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 472 }, stop := { byteIdx := 475 } } 2))))) (ArgF.expr - (ExprF.app { start := { byteIdx := 475 }, stop := { byteIdx := 481 } } - (ExprF.app { start := { byteIdx := 475 }, stop := { byteIdx := 481 } } - (ExprF.app { start := { byteIdx := 475 }, stop := { byteIdx := 481 } } - (ExprF.app { start := { byteIdx := 475 }, stop := { byteIdx := 481 } } - (ExprF.fn { start := { byteIdx := 475 }, stop := { byteIdx := 481 } } + (ExprF.app { start := { byteIdx := 480 }, stop := { byteIdx := 486 } } + (ExprF.app { start := { byteIdx := 480 }, stop := { byteIdx := 486 } } + (ExprF.app { start := { byteIdx := 480 }, stop := { byteIdx := 486 } } + (ExprF.app { start := { byteIdx := 480 }, stop := { byteIdx := 486 } } + (ExprF.fn { start := { byteIdx := 480 }, stop := { byteIdx := 486 } } { dialect := "Core", name := "map_get" }) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 426 }, stop := { byteIdx := 427 } } 0 + (TypeExprF.fvar { start := { byteIdx := 431 }, stop := { byteIdx := 432 } } 0 (Array.mkEmpty 0)))) (ArgF.type - (TypeExprF.fvar { start := { byteIdx := 428 }, stop := { byteIdx := 429 } } 1 + (TypeExprF.fvar { start := { byteIdx := 433 }, stop := { byteIdx := 434 } } 1 (Array.mkEmpty 0)))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 475 }, stop := { byteIdx := 476 } } 3))) - (ArgF.expr (ExprF.bvar { start := { byteIdx := 477 }, stop := { byteIdx := 480 } } 2)))))))) }] + (ArgF.expr (ExprF.bvar { start := { byteIdx := 480 }, stop := { byteIdx := 481 } } 3))) + (ArgF.expr (ExprF.bvar { start := { byteIdx := 482 }, stop := { byteIdx := 485 } } 2)))))))) }] -/ #guard_msgs in #eval examplePgm.commands diff --git a/StrataTest/Languages/Core/Examples/SimpleProc.lean b/StrataTest/Languages/Core/Examples/SimpleProc.lean index 39ab804c0..045106b66 100644 --- a/StrataTest/Languages/Core/Examples/SimpleProc.lean +++ b/StrataTest/Languages/Core/Examples/SimpleProc.lean @@ -24,7 +24,7 @@ spec { }; #end --- Translation from DDM AST to Boogie/Strata AST +-- Translation from DDM AST to Strata Core AST /-- info: true -/ #guard_msgs in diff --git a/StrataTest/Languages/Core/ExprEvalTest.lean b/StrataTest/Languages/Core/ExprEvalTest.lean index b25857418..b9711fdc5 100644 --- a/StrataTest/Languages/Core/ExprEvalTest.lean +++ b/StrataTest/Languages/Core/ExprEvalTest.lean @@ -20,7 +20,7 @@ import Strata.DL.Lambda.TestGen import Strata.DL.Lambda.PlausibleHelpers import Plausible.Gen -/-! This file does random testing of Boogie operations registered in factory, by +/-! This file does random testing of Strata Core operations registered in factory, by (1) choosing random constant inputs to the operations (2) doing concrete evaluation and getting the results, (3) SMT encoding the expression, and @@ -196,8 +196,8 @@ deriving instance Arbitrary for Visibility def test_lctx : LContext CoreLParams := { LContext.empty with - functions := Boogie.Factory - knownTypes := Boogie.KnownTypes + functions := Core.Factory + knownTypes := Core.KnownTypes } def test_ctx : TContext Visibility := ⟨[[]], []⟩ diff --git a/StrataTest/Transform/DetToNondet.lean b/StrataTest/Transform/DetToNondet.lean index 93d233751..321067ab1 100644 --- a/StrataTest/Transform/DetToNondet.lean +++ b/StrataTest/Transform/DetToNondet.lean @@ -18,12 +18,12 @@ section NondetExamples open Imperative def NondetTest1 : Stmt Expression (Cmd Expression) := - .ite (Boogie.true) [.cmd $ .havoc "x" ] [.cmd $ .havoc "y" ] + .ite (Core.true) [.cmd $ .havoc "x" ] [.cmd $ .havoc "y" ] def NondetTest1Ans : NondetStmt Expression (Cmd Expression) := .choice - (.seq (.cmd (.assume "true_cond" Boogie.true)) (.seq (.cmd $ .havoc "x") (.assume "skip" Imperative.HasBool.tt))) - (.seq (.cmd (.assume "false_cond" Boogie.false)) (.seq (.cmd $ .havoc "y") (.assume "skip" Imperative.HasBool.tt))) + (.seq (.cmd (.assume "true_cond" Core.true)) (.seq (.cmd $ .havoc "x") (.assume "skip" Imperative.HasBool.tt))) + (.seq (.cmd (.assume "false_cond" Core.false)) (.seq (.cmd $ .havoc "y") (.assume "skip" Imperative.HasBool.tt))) -- #eval toString $ Std.format (StmtToNondetStmt NondetTest1) diff --git a/StrataTest/Transform/ProcedureInlining.lean b/StrataTest/Transform/ProcedureInlining.lean index 4d1158efc..91d859de3 100644 --- a/StrataTest/Transform/ProcedureInlining.lean +++ b/StrataTest/Transform/ProcedureInlining.lean @@ -64,7 +64,7 @@ private def substExpr (e1:Expression.Expr) (map:Map String String) (isReverse: B map.foldl (fun (e:Expression.Expr) ((i1,i2):String × String) => -- old_id has visibility of temp because the new local variables were - -- created by BoogieGenM. + -- created by CoreGenM. -- new_expr has visibility of unres because that is the default setting -- from DDM parsed program, and the substituted program is supposed to be -- equivalent to the answer program translated from DDM From a76f6b2a820b8f239eeb3c4b75670c19fda866f7 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 15:42:25 -0600 Subject: [PATCH 10/19] PythonToBoogie -> PythonToCore, and ReToBoogie and all Python translation fns --- .../Languages/Python/FunctionSignatures.lean | 4 +- Strata/Languages/Python/PyFactory.lean | 6 +- Strata/Languages/Python/Python.lean | 2 +- ...{PythonToBoogie.lean => PythonToCore.lean} | 130 +++++++-------- .../Regex/{ReToBoogie.lean => ReToCore.lean} | 152 +++++++++--------- StrataMain.lean | 4 +- 6 files changed, 149 insertions(+), 149 deletions(-) rename Strata/Languages/Python/{PythonToBoogie.lean => PythonToCore.lean} (85%) rename Strata/Languages/Python/Regex/{ReToBoogie.lean => ReToCore.lean} (73%) diff --git a/Strata/Languages/Python/FunctionSignatures.lean b/Strata/Languages/Python/FunctionSignatures.lean index 35a239400..1870bdef7 100644 --- a/Strata/Languages/Python/FunctionSignatures.lean +++ b/Strata/Languages/Python/FunctionSignatures.lean @@ -9,7 +9,7 @@ import Strata.Languages.Core.Core namespace Strata namespace Python -/-- A type identifier in the Python Boogie prelude. -/ +/-- A type identifier in the Strata Core prelude for Python. -/ abbrev TypeId := String /-- An argument declaration for a Python method -/ @@ -143,7 +143,7 @@ def coreSignatures : Signatures := addCoreDecls |>.run end -def TypeStrToBoogieExpr (ty: String) : Core.Expression.Expr := +def TypeStrToCoreExpr (ty: String) : Core.Expression.Expr := if !ty.endsWith "OrNone" then panic! s!"Should only be called for possibly None types. Called for: {ty}" else diff --git a/Strata/Languages/Python/PyFactory.lean b/Strata/Languages/Python/PyFactory.lean index 018cfc535..9a620ff80 100644 --- a/Strata/Languages/Python/PyFactory.lean +++ b/Strata/Languages/Python/PyFactory.lean @@ -5,7 +5,7 @@ -/ import Strata.Languages.Core.Verifier -import Strata.Languages.Python.Regex.ReToBoogie +import Strata.Languages.Python.Regex.ReToCore namespace Strata namespace Python @@ -78,10 +78,10 @@ def reCompileFunc : LFunc Core.CoreLParams := -- (FIXME): We use `.match` mode below because we support only -- `re.match` for now. However, `re.compile` isn't mode-specific in -- general. - let (expr, maybe_err) := pythonRegexToBoogie s .match + let (expr, maybe_err) := pythonRegexToCore s .match match maybe_err with | none => - -- Note: Do not use `eb` (in Boogie.Syntax) here (e.g., see below) + -- Note: Do not use `eb` (in Strata Core Syntax) here (e.g., see below) -- eb[(~ExceptErrorRegex_mkOK expr)] -- that captures `expr` as an `.fvar`. .some (LExpr.mkApp () (.op () "ExceptErrorRegex_mkOK" none) [expr]) diff --git a/Strata/Languages/Python/Python.lean b/Strata/Languages/Python/Python.lean index dc56fc802..b6e791705 100644 --- a/Strata/Languages/Python/Python.lean +++ b/Strata/Languages/Python/Python.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import Strata.Languages.Python.PythonToBoogie +import Strata.Languages.Python.PythonToCore import Strata.Languages.Python.PythonDialect import StrataTest.Internal.InternalBoogiePrelude import StrataTest.Internal.InternalFunctionSignatures diff --git a/Strata/Languages/Python/PythonToBoogie.lean b/Strata/Languages/Python/PythonToCore.lean similarity index 85% rename from Strata/Languages/Python/PythonToBoogie.lean rename to Strata/Languages/Python/PythonToCore.lean index de01e2a11..c7e5ea579 100644 --- a/Strata/Languages/Python/PythonToBoogie.lean +++ b/Strata/Languages/Python/PythonToCore.lean @@ -12,7 +12,7 @@ import Strata.Languages.Core.DDMTransform.Parse import Strata.Languages.Core.Core import Strata.Languages.Python.PythonDialect import Strata.Languages.Python.FunctionSignatures -import Strata.Languages.Python.Regex.ReToBoogie +import Strata.Languages.Python.Regex.ReToCore import Strata.Languages.Python.PyFactory import Strata.Languages.Python.FunctionSignatures @@ -83,10 +83,10 @@ def unwrapModule (c : Python.Command SourceRange) : Array (Python.stmt SourceRan | Python.Command.Module _ body _ => body.val | _ => panic! "Expected module" -def strToBoogieExpr (s: String) : Core.Expression.Expr := +def strToCoreExpr (s: String) : Core.Expression.Expr := .strConst () s -def intToBoogieExpr (i: Int) : Core.Expression.Expr := +def intToCoreExpr (i: Int) : Core.Expression.Expr := .intConst () i def PyIntToInt (i : Python.int SourceRange) : Int := @@ -94,7 +94,7 @@ def PyIntToInt (i : Python.int SourceRange) : Int := | .IntPos _ n => n.val | .IntNeg _ n => -n.val -def PyConstToBoogie (c: Python.constant SourceRange) : Core.Expression.Expr := +def PyConstToCore (c: Python.constant SourceRange) : Core.Expression.Expr := match c with | .ConString _ s => .strConst () s.val | .ConPos _ i => .intConst () i.val @@ -103,7 +103,7 @@ def PyConstToBoogie (c: Python.constant SourceRange) : Core.Expression.Expr := | .ConFloat _ f => .strConst () (f.val) | _ => panic! s!"Unhandled Constant: {repr c}" -def PyAliasToBoogieExpr (a : Python.alias SourceRange) : Core.Expression.Expr := +def PyAliasToCoreExpr (a : Python.alias SourceRange) : Core.Expression.Expr := match a with | .mk_alias _ n as_n => assert! as_n.val.isNone @@ -170,8 +170,8 @@ def PyExprIdent (e1 e2: Python.expr SourceRange) : Bool := | _ , _ => false -- TODO: handle rest of names -def PyListStrToBoogie (names : Array (Python.alias SourceRange)) : Core.Expression.Expr := - .app () (.app () (.op () "ListStr_cons" mty[string → (ListStr → ListStr)]) (PyAliasToBoogieExpr names[0]!)) +def PyListStrToCore (names : Array (Python.alias SourceRange)) : Core.Expression.Expr := + .app () (.app () (.op () "ListStr_cons" mty[string → (ListStr → ListStr)]) (PyAliasToCoreExpr names[0]!)) (.op () "ListStr_nil" mty[ListStr]) def handleList (_elmts: Array (Python.expr SourceRange)) (expected_type : Lambda.LMonoTy): PyExprTranslated := @@ -334,14 +334,14 @@ def remapFname (translation_ctx: TranslationContext) (fname: String) : String := mutual -partial def PyExprToBoogieWithSubst (translation_ctx : TranslationContext) (substitution_records : Option (List SubstitutionRecord)) (e : Python.expr SourceRange) : PyExprTranslated := - PyExprToBoogie translation_ctx e substitution_records +partial def PyExprToCoreWithSubst (translation_ctx : TranslationContext) (substitution_records : Option (List SubstitutionRecord)) (e : Python.expr SourceRange) : PyExprTranslated := + PyExprToCore translation_ctx e substitution_records -partial def PyKWordsToBoogie (substitution_records : Option (List SubstitutionRecord)) (kw : Python.keyword SourceRange) : (String × PyExprTranslated) := +partial def PyKWordsToCore (substitution_records : Option (List SubstitutionRecord)) (kw : Python.keyword SourceRange) : (String × PyExprTranslated) := match kw with | .mk_keyword _ name expr => match name.val with - | some n => (n.val, PyExprToBoogieWithSubst default substitution_records expr) + | some n => (n.val, PyExprToCoreWithSubst default substitution_records expr) | none => panic! "Keyword arg should have a name" -- TODO: we should be checking that args are right @@ -352,19 +352,19 @@ partial def argsAndKWordsToCanonicalList (translation_ctx : TranslationContext) (substitution_records : Option (List SubstitutionRecord) := none) : List Core.Expression.Expr × List Core.Statement := if translation_ctx.func_infos.any (λ e => e.name == fname) || translation_ctx.class_infos.any (λ e => e.name++"___init__" == fname) then if translation_ctx.func_infos.any (λ e => e.name == fname) then - (args.toList.map (λ a => (PyExprToBoogieWithSubst default substitution_records a).expr), []) + (args.toList.map (λ a => (PyExprToCoreWithSubst default substitution_records a).expr), []) else - (args.toList.map (λ a => (PyExprToBoogieWithSubst default substitution_records a).expr), []) + (args.toList.map (λ a => (PyExprToCoreWithSubst default substitution_records a).expr), []) else let required_order := translation_ctx.signatures.getFuncSigOrder fname assert! args.size <= required_order.length let remaining := required_order.drop args.size - let kws_and_exprs := kwords.toList.map (PyKWordsToBoogie substitution_records) + let kws_and_exprs := kwords.toList.map (PyKWordsToCore substitution_records) let ordered_remaining_args := remaining.map (λ n => match kws_and_exprs.find? (λ p => p.fst == n) with | .some p => noneOrExpr translation_ctx fname n p.snd.expr - | .none => Strata.Python.TypeStrToBoogieExpr (translation_ctx.signatures.getFuncSigType fname n)) - let args := args.map (PyExprToBoogieWithSubst default substitution_records) + | .none => Strata.Python.TypeStrToCoreExpr (translation_ctx.signatures.getFuncSigType fname n)) + let args := args.map (PyExprToCoreWithSubst default substitution_records) let args := (List.range required_order.length).filterMap (λ n => if n < args.size then let arg_name := required_order[n]! -- Guaranteed by range. Using finRange causes breaking coercions to Nat. @@ -386,7 +386,7 @@ partial def handleDict (keys: Array (Python.opt_expr SourceRange)) (values: Arra match f with | .Name _ {ann := _ , val := "str"} _ => assert! args.val.size == 1 - let dt := (.app () (.op () "datetime_to_str" none) ((PyExprToBoogie default args.val[0]!).expr)) + let dt := (.app () (.op () "datetime_to_str" none) ((PyExprToCore default args.val[0]!).expr)) let dict_of_v_is_k := (.assume s!"assume_{n}_key" (.eq () (.app () (.app () (.op () "dict_str_any_get_str" none) dict) (.strConst () n)) dt)) [in_dict, dict_of_v_is_k] | _ => panic! "Unsupported function when constructing map" @@ -396,7 +396,7 @@ partial def handleDict (keys: Array (Python.opt_expr SourceRange)) (values: Arra {stmts := res , expr := dict, post_stmts := []} -partial def PyExprToBoogie (translation_ctx : TranslationContext) (e : Python.expr SourceRange) (substitution_records : Option (List SubstitutionRecord) := none) : PyExprTranslated := +partial def PyExprToCore (translation_ctx : TranslationContext) (e : Python.expr SourceRange) (substitution_records : Option (List SubstitutionRecord) := none) : PyExprTranslated := if h : substitution_records.isSome && (substitution_records.get!.find? (λ r => PyExprIdent r.pyExpr e)).isSome then have hr : (List.find? (fun r => PyExprIdent r.pyExpr e) substitution_records.get!).isSome = true := by rw [Bool.and_eq_true] at h; exact h.2 let record := (substitution_records.get!.find? (λ r => PyExprIdent r.pyExpr e)).get hr @@ -405,7 +405,7 @@ partial def PyExprToBoogie (translation_ctx : TranslationContext) (e : Python.ex match e with | .Call _ f args kwords => panic! s!"Call should be handled at stmt level: \n(func: {repr f}) \n(Records: {repr substitution_records}) \n(AST: {repr e.toAst})" - | .Constant _ c _ => {stmts := [], expr := PyConstToBoogie c} + | .Constant _ c _ => {stmts := [], expr := PyConstToCore c} | .Name _ n _ => match n.val with | "AssertionError" | "Exception" => {stmts := [], expr := .strConst () n.val} @@ -419,10 +419,10 @@ partial def PyExprToBoogie (translation_ctx : TranslationContext) (e : Python.ex else {stmts := [], expr := .fvar () n.val none} | .none => {stmts := [], expr := .fvar () n.val none} - | .JoinedStr _ ss => PyExprToBoogie translation_ctx ss.val[0]! -- TODO: need to actually join strings + | .JoinedStr _ ss => PyExprToCore translation_ctx ss.val[0]! -- TODO: need to actually join strings | .BinOp _ lhs op rhs => - let lhs := (PyExprToBoogie translation_ctx lhs) - let rhs := (PyExprToBoogie translation_ctx rhs) + let lhs := (PyExprToCore translation_ctx lhs) + let rhs := (PyExprToCore translation_ctx rhs) match op with | .Add _ => {stmts := lhs.stmts ++ rhs.stmts, expr := handleAdd lhs.expr rhs.expr} @@ -432,9 +432,9 @@ partial def PyExprToBoogie (translation_ctx : TranslationContext) (e : Python.ex {stmts := lhs.stmts ++ rhs.stmts, expr := handleMult translation_ctx lhs.expr rhs.expr} | _ => panic! s!"Unhandled BinOp: {repr e}" | .Compare _ lhs op rhs => - let lhs := PyExprToBoogie translation_ctx lhs + let lhs := PyExprToCore translation_ctx lhs assert! rhs.val.size == 1 - let rhs := PyExprToBoogie translation_ctx rhs.val[0]! + let rhs := PyExprToCore translation_ctx rhs.val[0]! match op.val with | #[v] => match v with | Strata.Python.cmpop.Eq _ => @@ -452,11 +452,11 @@ partial def PyExprToBoogie (translation_ctx : TranslationContext) (e : Python.ex res | .ListComp _ keys values => panic! "ListComp must be handled at stmt level" | .UnaryOp _ op arg => match op with - | .Not _ => {stmts := [], expr := handleNot (PyExprToBoogie translation_ctx arg).expr} + | .Not _ => {stmts := [], expr := handleNot (PyExprToCore translation_ctx arg).expr} | _ => panic! "Unsupported UnaryOp: {repr e}" | .Subscript _ v slice _ => - let l := PyExprToBoogie translation_ctx v - let k := PyExprToBoogie translation_ctx slice + let l := PyExprToCore translation_ctx v + let k := PyExprToCore translation_ctx slice -- TODO: we need to plumb the type of `v` here match s!"{repr l.expr}" with | "LExpr.fvar () { name := \"keys\", metadata := Core.Visibility.unres } none" => @@ -488,16 +488,16 @@ partial def initTmpParam (p: Python.expr SourceRange × String) : List Core.Stat match f with | .Name _ n _ => match n.val with - | "json_dumps" => [(.init p.snd t[string] (.strConst () "")), .call [p.snd, "maybe_except"] "json_dumps" [(.app () (.op () "DictStrAny_mk" none) (.strConst () "DefaultDict")), (Strata.Python.TypeStrToBoogieExpr "IntOrNone")]] + | "json_dumps" => [(.init p.snd t[string] (.strConst () "")), .call [p.snd, "maybe_except"] "json_dumps" [(.app () (.op () "DictStrAny_mk" none) (.strConst () "DefaultDict")), (Strata.Python.TypeStrToCoreExpr "IntOrNone")]] | "str" => assert! args.val.size == 1 - [(.init p.snd t[string] (.strConst () "")), .set p.snd (.app () (.op () "datetime_to_str" none) ((PyExprToBoogie default args.val[0]!).expr))] + [(.init p.snd t[string] (.strConst () "")), .set p.snd (.app () (.op () "datetime_to_str" none) ((PyExprToCore default args.val[0]!).expr))] | "int" => [(.init p.snd t[int] (.intConst () 0)), .set p.snd (.op () "datetime_to_int" none)] | _ => panic! s!"Unsupported name {n.val}" | _ => panic! s!"Unsupported tmp param init call: {repr f}" | _ => panic! "Expected Call" -partial def exceptHandlersToBoogie (jmp_targets: List String) (translation_ctx: TranslationContext) (h : Python.excepthandler SourceRange) : List Core.Statement := +partial def exceptHandlersToCore (jmp_targets: List String) (translation_ctx: TranslationContext) (h : Python.excepthandler SourceRange) : List Core.Statement := assert! jmp_targets.length >= 2 match h with | .ExceptHandler _ ex_ty _ body => @@ -507,14 +507,14 @@ partial def exceptHandlersToBoogie (jmp_targets: List String) (translation_ctx: let get_ex_tag : Core.CoreIdent := "ExceptOrNone_code_val" let exception_ty : Core.Expression.Expr := .app () (.op () get_ex_tag none) (.fvar () "maybe_except" none) let rhs_curried : Core.Expression.Expr := .app () (.op () inherits_from none) exception_ty - let res := PyExprToBoogie translation_ctx ex_ty + let res := PyExprToCore translation_ctx ex_ty let rhs : Core.Expression.Expr := .app () rhs_curried (res.expr) let call := .set "exception_ty_matches" rhs res.stmts ++ [call] | .none => [.set "exception_ty_matches" (.boolConst () false)] let cond := .fvar () "exception_ty_matches" none - let body_if_matches := body.val.toList.flatMap (λ s => (PyStmtToBoogie jmp_targets translation_ctx s).fst) ++ [.goto jmp_targets[1]!] + let body_if_matches := body.val.toList.flatMap (λ s => (PyStmtToCore jmp_targets translation_ctx s).fst) ++ [.goto jmp_targets[1]!] set_ex_ty_matches ++ [.ite cond body_if_matches []] partial def handleFunctionCall (lhs: List Core.Expression.Ident) @@ -547,25 +547,25 @@ partial def handleComprehension (lhs: Python.expr SourceRange) (gen: Array (Pyth assert! gen.size == 1 match gen[0]! with | .mk_comprehension _ _ itr _ _ => - let res := PyExprToBoogie default itr + let res := PyExprToCore default itr let guard := .app () (.op () "Bool.Not" none) (.eq () (.app () (.op () "dict_str_any_length" none) res.expr) (.intConst () 0)) let then_ss: List Core.Statement := [.havoc (PyExprToString lhs)] let else_ss: List Core.Statement := [.set (PyExprToString lhs) (.op () "ListStr_nil" none)] res.stmts ++ [.ite guard then_ss else_ss] -partial def PyStmtToBoogie (jmp_targets: List String) (translation_ctx : TranslationContext) (s : Python.stmt SourceRange) : List Core.Statement × TranslationContext := +partial def PyStmtToCore (jmp_targets: List String) (translation_ctx : TranslationContext) (s : Python.stmt SourceRange) : List Core.Statement × TranslationContext := assert! jmp_targets.length > 0 let non_throw : List Core.Statement × Option (String × Lambda.LMonoTy) := match s with | .Import _ names => - ([.call [] "import" [PyListStrToBoogie names.val]], none) + ([.call [] "import" [PyListStrToCore names.val]], none) | .ImportFrom _ s names i => let n := match s.val with - | some s => [strToBoogieExpr s.val] + | some s => [strToCoreExpr s.val] | none => [] let i := match i.val with - | some i => [intToBoogieExpr (PyIntToInt i)] + | some i => [intToCoreExpr (PyIntToInt i)] | none => [] - ([.call [] "importFrom" (n ++ [PyListStrToBoogie names.val] ++ i)], none) + ([.call [] "importFrom" (n ++ [PyListStrToCore names.val] ++ i)], none) | .Expr _ (.Call _ func args kwords) => let fname := PyExprToString func if callCanThrow translation_ctx.func_infos s then @@ -583,7 +583,7 @@ partial def PyStmtToBoogie (jmp_targets: List String) (translation_ctx : Transla (handleFunctionCall [PyExprToString lhs.val[0]!, "maybe_except"] fname args kwords jmp_targets translation_ctx s, none) | .Assign _ lhs rhs _ => assert! lhs.val.size == 1 - let res := PyExprToBoogie translation_ctx rhs + let res := PyExprToCore translation_ctx rhs (res.stmts ++ [.set (PyExprToString lhs.val[0]!) res.expr], none) | .AnnAssign _ lhs ty { ann := _ , val := (.some (.Call _ func args kwords))} _ => let fname := PyExprToString func @@ -591,54 +591,54 @@ partial def PyStmtToBoogie (jmp_targets: List String) (translation_ctx : Transla | .AnnAssign _ lhs ty { ann := _ , val := (.some (.ListComp _ _ gen))} _ => (handleComprehension lhs gen.val, some (PyExprToString lhs, PyExprToMonoTy ty)) | .AnnAssign _ lhs ty {ann := _, val := (.some e)} _ => - let res := (PyExprToBoogie {translation_ctx with expectedType := PyExprToMonoTy ty} e) + let res := (PyExprToCore {translation_ctx with expectedType := PyExprToMonoTy ty} e) (res.stmts ++ [.set (PyExprToString lhs) res.expr], some (PyExprToString lhs, PyExprToMonoTy ty)) | .Try _ body handlers _orelse _finalbody => let new_target := s!"excepthandlers_{jmp_targets[0]!}" let entry_except_handlers := [.block new_target []] let new_jmp_stack := new_target :: jmp_targets - let except_handlers := handlers.val.toList.flatMap (exceptHandlersToBoogie new_jmp_stack translation_ctx) + let except_handlers := handlers.val.toList.flatMap (exceptHandlersToCore new_jmp_stack translation_ctx) let var_decls := collectVarDecls translation_ctx body.val - ([.block "try_block" (var_decls ++ body.val.toList.flatMap (λ s => (PyStmtToBoogie new_jmp_stack translation_ctx s).fst) ++ entry_except_handlers ++ except_handlers)], none) + ([.block "try_block" (var_decls ++ body.val.toList.flatMap (λ s => (PyStmtToCore new_jmp_stack translation_ctx s).fst) ++ entry_except_handlers ++ except_handlers)], none) | .FunctionDef _ _ _ _ _ _ _ _ => panic! "Can't translate FunctionDef to Boogie statement" | .If _ test then_b else_b => let guard_ctx := {translation_ctx with expectedType := some (.tcons "bool" [])} - ([.ite (PyExprToBoogie guard_ctx test).expr (ArrPyStmtToBoogie translation_ctx then_b.val).fst (ArrPyStmtToBoogie translation_ctx else_b.val).fst], none) + ([.ite (PyExprToCore guard_ctx test).expr (ArrPyStmtToCore translation_ctx then_b.val).fst (ArrPyStmtToCore translation_ctx else_b.val).fst], none) | .Return _ v => match v.val with - | .some v => ([.set "ret" (PyExprToBoogie translation_ctx v).expr, .goto jmp_targets[0]!], none) -- TODO: need to thread return value name here. For now, assume "ret" + | .some v => ([.set "ret" (PyExprToCore translation_ctx v).expr, .goto jmp_targets[0]!], none) -- TODO: need to thread return value name here. For now, assume "ret" | .none => ([.goto jmp_targets[0]!], none) | .For _ tgt itr body _ _ => -- Do one unrolling: - let guard := .app () (.op () "Bool.Not" none) (.eq () (.app () (.op () "dict_str_any_length" none) (PyExprToBoogie default itr).expr) (.intConst () 0)) + let guard := .app () (.op () "Bool.Not" none) (.eq () (.app () (.op () "dict_str_any_length" none) (PyExprToCore default itr).expr) (.intConst () 0)) match tgt with | .Name _ n _ => let assign_tgt := [(.init n.val dictStrAnyType dummyDictStrAny)] - ([.ite guard (assign_tgt ++ (ArrPyStmtToBoogie translation_ctx body.val).fst) []], none) + ([.ite guard (assign_tgt ++ (ArrPyStmtToCore translation_ctx body.val).fst) []], none) | _ => panic! s!"tgt must be single name: {repr tgt}" -- TODO: missing havoc | .While _ test body _ => -- Do one unrolling: - let guard := .app () (.op () "Bool.Not" none) (.eq () (.app () (.op () "dict_str_any_length" none) (PyExprToBoogie default test).expr) (.intConst () 0)) - ([.ite guard (ArrPyStmtToBoogie translation_ctx body.val).fst []], none) + let guard := .app () (.op () "Bool.Not" none) (.eq () (.app () (.op () "dict_str_any_length" none) (PyExprToCore default test).expr) (.intConst () 0)) + ([.ite guard (ArrPyStmtToCore translation_ctx body.val).fst []], none) -- TODO: missing havoc | .Assert _ a _ => - let res := PyExprToBoogie translation_ctx a + let res := PyExprToCore translation_ctx a ([(.assert "py_assertion" res.expr)], none) | .AugAssign _ lhs op rhs => match op with | .Add _ => match lhs with | .Name _ n _ => - let rhs := PyExprToBoogie translation_ctx rhs + let rhs := PyExprToCore translation_ctx rhs let new_lhs := (.strConst () "DUMMY_FLOAT") (rhs.stmts ++ [.set n.val new_lhs], none) | _ => panic! s!"Expected lhs to be name: {repr lhs}" | .FloorDiv _ => match lhs with | .Name _ n _ => - let lhs := PyExprToBoogie translation_ctx lhs - let rhs := PyExprToBoogie translation_ctx rhs + let lhs := PyExprToCore translation_ctx lhs + let rhs := PyExprToCore translation_ctx rhs let new_lhs := .app () (.app () (.op () "Int.Div" mty[int → (int → int)]) lhs.expr) rhs.expr (rhs.stmts ++ [.set n.val new_lhs], none) | _ => panic! s!"Expected lhs to be name: {repr lhs}" @@ -653,9 +653,9 @@ partial def PyStmtToBoogie (jmp_targets: List String) (translation_ctx : Transla else (non_throw.fst, new_translation_ctx) -partial def ArrPyStmtToBoogie (translation_ctx: TranslationContext) (a : Array (Python.stmt SourceRange)) : (List Core.Statement × TranslationContext) := +partial def ArrPyStmtToCore (translation_ctx: TranslationContext) (a : Array (Python.stmt SourceRange)) : (List Core.Statement × TranslationContext) := a.foldl (fun (stmts, ctx) stmt => - let (newStmts, newCtx) := PyStmtToBoogie ["end"] ctx stmt + let (newStmts, newCtx) := PyStmtToCore ["end"] ctx stmt (stmts ++ newStmts, newCtx) ) ([], translation_ctx) @@ -674,7 +674,7 @@ def translateFunctions (a : Array (Python.stmt SourceRange)) (translation_ctx: T inputs := [], outputs := [("maybe_except", (.tcons "ExceptOrNone" []))]}, spec := default, - body := varDecls ++ (ArrPyStmtToBoogie translation_ctx body.val).fst ++ [.block "end" []] + body := varDecls ++ (ArrPyStmtToCore translation_ctx body.val).fst ++ [.block "end" []] } some (.proc proc) | _ => none) @@ -686,10 +686,10 @@ def pyTyStrToLMonoTy (ty_str: String) : Lambda.LMonoTy := | "datetime" => (.tcons "Datetime" []) | _ => panic! s!"Unsupported type: {ty_str}" -def pythonFuncToBoogie (name : String) (args: List (String × String)) (body: Array (Python.stmt SourceRange)) (ret : Option (Python.expr SourceRange)) (spec : Core.Procedure.Spec) (translation_ctx : TranslationContext) : Core.Procedure := +def pythonFuncToCore (name : String) (args: List (String × String)) (body: Array (Python.stmt SourceRange)) (ret : Option (Python.expr SourceRange)) (spec : Core.Procedure.Spec) (translation_ctx : TranslationContext) : Core.Procedure := let inputs : List (Lambda.Identifier Core.Visibility × Lambda.LMonoTy) := args.map (λ p => (p.fst, pyTyStrToLMonoTy p.snd)) let varDecls := collectVarDecls translation_ctx body ++ [(.init "exception_ty_matches" t[bool] (.boolConst () false)), (.havoc "exception_ty_matches")] - let stmts := (ArrPyStmtToBoogie translation_ctx body).fst + let stmts := (ArrPyStmtToCore translation_ctx body).fst let body := varDecls ++ stmts ++ [.block "end" []] let constructor := name.endsWith "___init__" let outputs : Lambda.LMonoTySignature := if not constructor then @@ -725,14 +725,14 @@ def unpackPyArguments (args: Python.arguments SourceRange) : List (String × Str | .some ty => some (name.val, PyExprToString ty) | _ => panic! s!"Missing type annotation on arg: {repr a} ({repr args})") -def PyFuncDefToBoogie (s: Python.stmt SourceRange) (translation_ctx: TranslationContext) : List Core.Decl × PythonFunctionDecl := +def PyFuncDefToCore (s: Python.stmt SourceRange) (translation_ctx: TranslationContext) : List Core.Decl × PythonFunctionDecl := match s with | .FunctionDef _ name args body _ ret _ _ => let args := unpackPyArguments args - ([.proc (pythonFuncToBoogie name.val args body.val ret.val default translation_ctx)], {name := name.val, args, ret := s!"{repr ret}"}) + ([.proc (pythonFuncToCore name.val args body.val ret.val default translation_ctx)], {name := name.val, args, ret := s!"{repr ret}"}) | _ => panic! s!"Expected function def: {repr s}" -def PyClassDefToBoogie (s: Python.stmt SourceRange) (translation_ctx: TranslationContext) : List Core.Decl × PythonClassDecl := +def PyClassDefToCore (s: Python.stmt SourceRange) (translation_ctx: TranslationContext) : List Core.Decl × PythonClassDecl := match s with | .ClassDef _ c_name _ _ body _ _ => let member_fn_defs := body.val.toList.filterMap (λ s => match s with @@ -743,10 +743,10 @@ def PyClassDefToBoogie (s: Python.stmt SourceRange) (translation_ctx: Translatio let args := unpackPyArguments f.snd.fst let body := f.snd.snd.fst.val let ret := f.snd.snd.snd.val - .proc (pythonFuncToBoogie (c_name.val++"_"++name) args body ret default translation_ctx)), {name := c_name.val}) + .proc (pythonFuncToCore (c_name.val++"_"++name) args body ret default translation_ctx)), {name := c_name.val}) | _ => panic! s!"Expected function def: {repr s}" -def pythonToBoogie (signatures : Python.Signatures) (pgm: Strata.Program): Core.Program := +def pythonToCore (signatures : Python.Signatures) (pgm: Strata.Program): Core.Program := let pyCmds := toPyCommands pgm.commands assert! pyCmds.size == 1 let insideMod := unwrapModule pyCmds[0]! @@ -777,15 +777,15 @@ def pythonToBoogie (signatures : Python.Signatures) (pgm: Strata.Program): Core. (y ++ ys, acc'') let func_info : TranslationContext := { signatures } - let func_defs_and_infos := helper PyFuncDefToBoogie (fun acc info => {acc with func_infos := info :: acc.func_infos}) func_info func_defs.toList + let func_defs_and_infos := helper PyFuncDefToCore (fun acc info => {acc with func_infos := info :: acc.func_infos}) func_info func_defs.toList let func_defs := func_defs_and_infos.fst let func_infos := func_defs_and_infos.snd - let class_defs_and_infos := helper PyClassDefToBoogie (fun acc info => {acc with class_infos := info :: acc.class_infos}) func_infos class_defs.toList + let class_defs_and_infos := helper PyClassDefToCore (fun acc info => {acc with class_infos := info :: acc.class_infos}) func_infos class_defs.toList let class_defs := class_defs_and_infos.fst let class_infos := class_defs_and_infos.snd let class_ty_decls := [(.type (.con {name := "LatencyAnalyzer", numargs := 0})) ] - {decls := globals ++ class_ty_decls ++ func_defs ++ class_defs ++ [.proc (pythonFuncToBoogie "__main__" [] non_func_blocks none default class_infos)]} + {decls := globals ++ class_ty_decls ++ func_defs ++ class_defs ++ [.proc (pythonFuncToCore "__main__" [] non_func_blocks none default class_infos)]} end Strata diff --git a/Strata/Languages/Python/Regex/ReToBoogie.lean b/Strata/Languages/Python/Regex/ReToCore.lean similarity index 73% rename from Strata/Languages/Python/Regex/ReToBoogie.lean rename to Strata/Languages/Python/Regex/ReToCore.lean index 581fde622..79c209fba 100644 --- a/Strata/Languages/Python/Regex/ReToBoogie.lean +++ b/Strata/Languages/Python/Regex/ReToCore.lean @@ -66,16 +66,16 @@ def RegexAST.alwaysConsume (r : RegexAST) : Bool := /-- Empty regex pattern; matches an empty string. -/ -def Boogie.emptyRegex : Core.Expression.Expr := +def Core.emptyRegex : Core.Expression.Expr := mkApp () (.op () strToRegexFunc.name none) [strConst () ""] /-- Unmatchable regex pattern. -/ -def Boogie.unmatchableRegex : Core.Expression.Expr := +def Core.unmatchableRegex : Core.Expression.Expr := mkApp () (.op () reNoneFunc.name none) [] -partial def RegexAST.toBoogie (r : RegexAST) (atStart atEnd : Bool) : +partial def RegexAST.toCore (r : RegexAST) (atStart atEnd : Bool) : Core.Expression.Expr := match r with | .char c => @@ -84,78 +84,78 @@ partial def RegexAST.toBoogie (r : RegexAST) (atStart atEnd : Bool) : mkApp () (.op () reRangeFunc.name none) [strConst () (toString c1), strConst () (toString c2)] | .anychar => mkApp () (.op () reAllCharFunc.name none) [] - | .empty => Boogie.emptyRegex + | .empty => Core.emptyRegex | .complement r => - let rb := toBoogie r atStart atEnd + let rb := toCore r atStart atEnd mkApp () (.op () reCompFunc.name none) [rb] | .anchor_start => - if atStart then Boogie.emptyRegex else Boogie.unmatchableRegex + if atStart then Core.emptyRegex else Core.unmatchableRegex | .anchor_end => - if atEnd then Boogie.emptyRegex else Boogie.unmatchableRegex + if atEnd then Core.emptyRegex else Core.unmatchableRegex | .plus r1 => - toBoogie (.concat r1 (.star r1)) atStart atEnd + toCore (.concat r1 (.star r1)) atStart atEnd | .star r1 => - let r1b := toBoogie r1 atStart atEnd + let r1b := toCore r1 atStart atEnd let r2b := match (alwaysConsume r1) with | true => - let r1b := toBoogie r1 atStart false -- r1 at the beginning - let r2b := toBoogie r1 false false -- r1s in the middle - let r3b := toBoogie r1 false atEnd -- r1 at the end + let r1b := toCore r1 atStart false -- r1 at the beginning + let r2b := toCore r1 false false -- r1s in the middle + let r3b := toCore r1 false atEnd -- r1 at the end let r2b := mkApp () (.op () reStarFunc.name none) [r2b] mkApp () (.op () reConcatFunc.name none) [mkApp () (.op () reConcatFunc.name none) [r1b, r2b], r3b] | false => mkApp () (.op () reStarFunc.name none) [r1b] mkApp () (.op () reUnionFunc.name none) - [mkApp () (.op () reUnionFunc.name none) [Boogie.emptyRegex, r1b], r2b] + [mkApp () (.op () reUnionFunc.name none) [Core.emptyRegex, r1b], r2b] | .optional r1 => - toBoogie (.union .empty r1) atStart atEnd + toCore (.union .empty r1) atStart atEnd | .loop r1 n m => match n, m with - | 0, 0 => Boogie.emptyRegex - | 0, 1 => toBoogie (.union .empty r1) atStart atEnd + | 0, 0 => Core.emptyRegex + | 0, 1 => toCore (.union .empty r1) atStart atEnd | 0, m => -- Note: m >= 2 - let r1b := toBoogie r1 atStart atEnd + let r1b := toCore r1 atStart atEnd let r2b := match (alwaysConsume r1) with | true => - let r1b := toBoogie r1 atStart false -- r1 at the beginning - let r2b := toBoogie r1 false false -- r1s in the middle - let r3b := toBoogie r1 false atEnd -- r1 at the end + let r1b := toCore r1 atStart false -- r1 at the beginning + let r2b := toCore r1 false false -- r1s in the middle + let r3b := toCore r1 false atEnd -- r1 at the end let r2b := mkApp () (.op () reLoopFunc.name none) [r2b, intConst () 0, intConst () (m-2)] mkApp () (.op () reConcatFunc.name none) [mkApp () (.op () reConcatFunc.name none) [r1b, r2b], r3b] | false => mkApp () (.op () reLoopFunc.name none) [r1b, intConst () 0, intConst () m] mkApp () (.op () reUnionFunc.name none) - [mkApp () (.op () reUnionFunc.name none) [Boogie.emptyRegex, r1b], + [mkApp () (.op () reUnionFunc.name none) [Core.emptyRegex, r1b], r2b] | _, _ => - toBoogie (.concat r1 (.loop r1 (n - 1) (m - 1))) atStart atEnd - | .group r1 => toBoogie r1 atStart atEnd + toCore (.concat r1 (.loop r1 (n - 1) (m - 1))) atStart atEnd + | .group r1 => toCore r1 atStart atEnd | .concat r1 r2 => match (alwaysConsume r1), (alwaysConsume r2) with | true, true => - let r1b := toBoogie r1 atStart false - let r2b := toBoogie r2 false atEnd + let r1b := toCore r1 atStart false + let r2b := toCore r2 false atEnd mkApp () (.op () reConcatFunc.name none) [r1b, r2b] | true, false => - let r1b := toBoogie r1 atStart atEnd - let r2b := toBoogie r2 false atEnd + let r1b := toCore r1 atStart atEnd + let r2b := toCore r2 false atEnd mkApp () (.op () reConcatFunc.name none) [r1b, r2b] | false, true => - let r1b := toBoogie r1 atStart false - let r2b := toBoogie r2 true atEnd + let r1b := toCore r1 atStart false + let r2b := toCore r2 true atEnd mkApp () (.op () reConcatFunc.name none) [r1b, r2b] | false, false => - let r1b := toBoogie r1 atStart atEnd - let r2b := toBoogie r2 atStart atEnd + let r1b := toCore r1 atStart atEnd + let r2b := toCore r2 atStart atEnd mkApp () (.op () reConcatFunc.name none) [r1b, r2b] | .union r1 r2 => - let r1b := toBoogie r1 atStart atEnd - let r2b := toBoogie r2 atStart atEnd + let r1b := toCore r1 atStart atEnd + let r2b := toCore r2 atStart atEnd mkApp () (.op () reUnionFunc.name none) [r1b, r2b] -def pythonRegexToBoogie (pyRegex : String) (mode : MatchMode := .fullmatch) : +def pythonRegexToCore (pyRegex : String) (mode : MatchMode := .fullmatch) : Core.Expression.Expr × Option ParseError := match parseTop pyRegex with | .error err => (mkApp () (.op () reAllFunc.name none) [], some err) @@ -166,7 +166,7 @@ def pythonRegexToBoogie (pyRegex : String) (mode : MatchMode := .fullmatch) : | .fullmatch => ast | .match => .concat ast dotStar | .search => .concat dotStar (.concat ast dotStar) - let result := RegexAST.toBoogie ast true true + let result := RegexAST.toCore ast true true (result, none) /-- @@ -174,208 +174,208 @@ info: (((~Re.Concat ((~Re.Concat (~Str.ToRegEx #a)) (~Str.ToRegEx #b))) ((~Re.Un none) -/ #guard_msgs in -#eval Std.format$ pythonRegexToBoogie "ab.*" -- Encoded as `ab(|.|..*.)` +#eval Std.format$ pythonRegexToCore "ab.*" -- Encoded as `ab(|.|..*.)` /-- info: (((~Re.Concat ((~Re.Concat (~Str.ToRegEx #a)) (~Str.ToRegEx #b))) ((~Re.Union ((~Re.Union (~Str.ToRegEx #)) ((~Re.Concat (~Str.ToRegEx #c)) (~Str.ToRegEx #)))) ((~Re.Concat ((~Re.Concat ((~Re.Concat (~Str.ToRegEx #c)) ~Re.None)) (~Re.Star ((~Re.Concat (~Str.ToRegEx #c)) ~Re.None)))) ((~Re.Concat (~Str.ToRegEx #c)) (~Str.ToRegEx #))))), none) -/ #guard_msgs in -#eval Std.format$ pythonRegexToBoogie "ab(c$)*" +#eval Std.format$ pythonRegexToCore "ab(c$)*" /-- info: (((~Re.Concat ((~Re.Concat (~Str.ToRegEx #a)) (~Str.ToRegEx #b))) ((~Re.Union ((~Re.Union (~Str.ToRegEx #)) ((~Re.Concat ((~Re.Concat ~Re.None) (~Str.ToRegEx #c))) (~Str.ToRegEx #)))) ((~Re.Concat ((~Re.Concat ((~Re.Concat ((~Re.Concat ~Re.None) (~Str.ToRegEx #c))) ~Re.None)) (~Re.Star ((~Re.Concat ((~Re.Concat ~Re.None) (~Str.ToRegEx #c))) ~Re.None)))) ((~Re.Concat ((~Re.Concat ~Re.None) (~Str.ToRegEx #c))) (~Str.ToRegEx #))))), none) -/ #guard_msgs in -#eval Std.format$ pythonRegexToBoogie "ab(^c$)*" +#eval Std.format$ pythonRegexToCore "ab(^c$)*" /-- info: (((~Re.Concat (~Str.ToRegEx #a)) (~Str.ToRegEx #b)), none) -/ #guard_msgs in -#eval Std.format$ pythonRegexToBoogie "ab" +#eval Std.format$ pythonRegexToCore "ab" /-- info: (((~Re.Union (~Str.ToRegEx #a)) (~Str.ToRegEx #b)), none) -/ #guard_msgs in -#eval Std.format$ pythonRegexToBoogie "a|b" +#eval Std.format$ pythonRegexToCore "a|b" /-- info: (((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #a))) (~Str.ToRegEx #b)), none) -/ #guard_msgs in -#eval Std.format$ pythonRegexToBoogie "^ab" +#eval Std.format$ pythonRegexToCore "^ab" /-- info: (((~Re.Concat ((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #a))) (~Str.ToRegEx #b))) (~Str.ToRegEx #)), none) -/ #guard_msgs in -#eval Std.format$ pythonRegexToBoogie "^ab$" +#eval Std.format$ pythonRegexToCore "^ab$" /-- info: (((~Re.Concat ((~Re.Concat (~Str.ToRegEx #a)) ~Re.None)) (~Str.ToRegEx #b)), none) -/ #guard_msgs in -#eval Std.format$ pythonRegexToBoogie "(a$)b" +#eval Std.format$ pythonRegexToCore "(a$)b" /-- info: (((~Re.Concat ((~Re.Concat ((~Re.Concat ((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #))) (~Str.ToRegEx #))) (~Str.ToRegEx #a))) (~Str.ToRegEx #))) (~Str.ToRegEx #)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "^^^a$$" +#eval Std.format $ pythonRegexToCore "^^^a$$" /-- info: (((~Re.Concat (~Str.ToRegEx #)) ((~Re.Concat ((~Re.Concat ((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #))) (~Str.ToRegEx #a))) (~Str.ToRegEx #))) (~Str.ToRegEx #))), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "^(^^a$$)" +#eval Std.format $ pythonRegexToCore "^(^^a$$)" /-- info: (((~Re.Union ((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #a))) (~Str.ToRegEx #))) ((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #b))) (~Str.ToRegEx #))), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "(^a$)|(^b$)" +#eval Std.format $ pythonRegexToCore "(^a$)|(^b$)" /-- info: (((~Re.Concat (~Str.ToRegEx #c)) ((~Re.Union ((~Re.Concat ~Re.None) (~Str.ToRegEx #a))) ((~Re.Concat ~Re.None) (~Str.ToRegEx #b)))), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "c((^a)|(^b))" +#eval Std.format $ pythonRegexToCore "c((^a)|(^b))" /-- info: (((~Re.Concat ((~Re.Union ((~Re.Concat (~Str.ToRegEx #a)) ~Re.None)) ((~Re.Concat (~Str.ToRegEx #b)) ~Re.None))) (~Str.ToRegEx #c)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "((a$)|(b$))c" +#eval Std.format $ pythonRegexToCore "((a$)|(b$))c" /-- info: (((~Re.Concat ((~Re.Union ((~Re.Concat (~Str.ToRegEx #a)) ~Re.None)) (~Str.ToRegEx #b))) (~Str.ToRegEx #c)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "((a$)|(b))c" +#eval Std.format $ pythonRegexToCore "((a$)|(b))c" /-- info: (((~Re.Concat (~Str.ToRegEx #c)) ((~Re.Union ((~Re.Concat (~Str.ToRegEx #a)) (~Str.ToRegEx #))) ((~Re.Concat ((~Re.Concat ~Re.None) (~Str.ToRegEx #b))) (~Str.ToRegEx #)))), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "c((a$)|(^b$))" +#eval Std.format $ pythonRegexToCore "c((a$)|(^b$))" /-- info: (((~Re.Concat ((~Re.Union ((~Re.Concat (~Str.ToRegEx #a)) ~Re.None)) (~Str.ToRegEx #b))) (~Str.ToRegEx #c)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "((a$)|(b))c" +#eval Std.format $ pythonRegexToCore "((a$)|(b))c" /-- info: (((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) ~Re.None)) (~Str.ToRegEx #b)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "^$b" +#eval Std.format $ pythonRegexToCore "^$b" /-- info: (((~Re.Union ((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #a))) (~Str.ToRegEx #))) ((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) ~Re.None)) (~Str.ToRegEx #b))), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "^a$|^$b" +#eval Std.format $ pythonRegexToCore "^a$|^$b" /-- info: (((~Re.Concat ((~Re.Concat (~Str.ToRegEx #c)) ((~Re.Union ((~Re.Concat ~Re.None) (~Str.ToRegEx #a))) ((~Re.Concat (~Str.ToRegEx #b)) ~Re.None)))) (~Str.ToRegEx #d)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "c(^a|b$)d" +#eval Std.format $ pythonRegexToCore "c(^a|b$)d" /-- info: (((~Re.Concat ((~Re.Concat (~Str.ToRegEx #c)) ((~Re.Union ((~Re.Concat ~Re.None) (~Str.ToRegEx #a))) ((~Re.Concat (~Str.ToRegEx #b)) ~Re.None)))) (~Str.ToRegEx #d)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "(c(^a|b$))d" +#eval Std.format $ pythonRegexToCore "(c(^a|b$))d" /-- info: (((~Re.Concat ((~Re.Union ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #a))) ((~Re.Concat (~Str.ToRegEx #b)) ~Re.None))) ((~Re.Union ((~Re.Concat ~Re.None) (~Str.ToRegEx #c))) ((~Re.Concat (~Str.ToRegEx #d)) (~Str.ToRegEx #)))), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "(^a|b$)(^c|d$)" +#eval Std.format $ pythonRegexToCore "(^a|b$)(^c|d$)" /-- info: (((~Re.Concat ((~Re.Concat ((~Re.Union ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #a))) ((~Re.Concat (~Str.ToRegEx #b)) ~Re.None))) ~Re.None)) (~Str.ToRegEx #c)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "((^a|b$)^)c" +#eval Std.format $ pythonRegexToCore "((^a|b$)^)c" /-- info: (((~Re.Concat ((~Re.Union (~Str.ToRegEx #)) ~Re.None)) (~Str.ToRegEx #c)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "(^|$)c" +#eval Std.format $ pythonRegexToCore "(^|$)c" /-- info: (((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "^^" +#eval Std.format $ pythonRegexToCore "^^" /-- info: (((~Re.Concat ((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #))) (~Str.ToRegEx #))) (~Str.ToRegEx #)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "^$$^" +#eval Std.format $ pythonRegexToCore "^$$^" /-- info: (((~Re.Concat ((~Re.Union (~Str.ToRegEx #)) (~Str.ToRegEx #))) (~Str.ToRegEx #)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "(^|$)^" +#eval Std.format $ pythonRegexToCore "(^|$)^" /-- info: (((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #a))) (~Str.ToRegEx #)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "^a$" .fullmatch +#eval Std.format $ pythonRegexToCore "^a$" .fullmatch /-- info: (~Re.All, some Pattern error at position 1: Invalid repeat bounds {100,2}: maximum 2 is less than minimum 100 in pattern 'x{100,2}') -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "x{100,2}" .fullmatch +#eval Std.format $ pythonRegexToCore "x{100,2}" .fullmatch -- (unmatchable) /-- info: (((~Re.Concat ((~Re.Concat (~Str.ToRegEx #a)) ~Re.None)) (~Str.ToRegEx #b)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "a^b" .fullmatch +#eval Std.format $ pythonRegexToCore "a^b" .fullmatch /-- info: (((~Re.Concat ((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #a))) ~Re.None)) (~Str.ToRegEx #b)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "^a^b" .fullmatch +#eval Std.format $ pythonRegexToCore "^a^b" .fullmatch /-- info: (((~Re.Concat ((~Re.Concat (~Str.ToRegEx #a)) ~Re.None)) (~Str.ToRegEx #b)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "a$b" .fullmatch +#eval Std.format $ pythonRegexToCore "a$b" .fullmatch /-- info: ((~Re.Comp (~Str.ToRegEx #b)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "[^b]" .fullmatch +#eval Std.format $ pythonRegexToCore "[^b]" .fullmatch /-- info: ((~Re.Comp ((~Re.Range #A) #Z)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "[^A-Z]" .fullmatch +#eval Std.format $ pythonRegexToCore "[^A-Z]" .fullmatch /-- info: ((~Re.Comp (~Str.ToRegEx #^)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "[^^]" .fullmatch +#eval Std.format $ pythonRegexToCore "[^^]" .fullmatch /-- info: ((~Str.ToRegEx #a), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "a" .fullmatch +#eval Std.format $ pythonRegexToCore "a" .fullmatch /-- info: (((~Re.Concat (~Str.ToRegEx #a)) ((~Re.Union ((~Re.Union (~Str.ToRegEx #)) ~Re.AllChar)) ((~Re.Concat ((~Re.Concat ~Re.AllChar) (~Re.Star ~Re.AllChar))) ~Re.AllChar))), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "a" .match +#eval Std.format $ pythonRegexToCore "a" .match -- search mode tests /-- @@ -383,24 +383,24 @@ info: (((~Re.Concat ((~Re.Union ((~Re.Union (~Str.ToRegEx #)) ~Re.AllChar)) ((~R none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "a" .search +#eval Std.format $ pythonRegexToCore "a" .search /-- info: (((~Re.Concat ((~Re.Union ((~Re.Union (~Str.ToRegEx #)) ~Re.AllChar)) ((~Re.Concat ((~Re.Concat ~Re.AllChar) (~Re.Star ~Re.AllChar))) ~Re.AllChar))) ((~Re.Concat ((~Re.Concat ((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #a))) (~Str.ToRegEx #))) ((~Re.Union ((~Re.Union (~Str.ToRegEx #)) ~Re.AllChar)) ((~Re.Concat ((~Re.Concat ~Re.AllChar) (~Re.Star ~Re.AllChar))) ~Re.AllChar)))), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "^a$" .search +#eval Std.format $ pythonRegexToCore "^a$" .search /-- info: (((~Re.Concat (~Str.ToRegEx #)) (~Str.ToRegEx #a)), none) -/ #guard_msgs in -#eval Std.format $ pythonRegexToBoogie "^a" .fullmatch +#eval Std.format $ pythonRegexToCore "^a" .fullmatch -- -- BAD --- #eval Std.format $ pythonRegexToBoogie "a$.*" .fullmatch +-- #eval Std.format $ pythonRegexToCore "a$.*" .fullmatch -- -- -- BAD --- #eval Std.format $ pythonRegexToBoogie "a$" .match +-- #eval Std.format $ pythonRegexToCore "a$" .match ------------------------------------------------------------------------------- diff --git a/StrataMain.lean b/StrataMain.lean index d11214513..eb0b911f8 100644 --- a/StrataMain.lean +++ b/StrataMain.lean @@ -185,7 +185,7 @@ def pyTranslateCommand : Command where callback := fun _ v => do let pgm ← readPythonStrata v[0] let preludePgm := Strata.Python.Internal.Core.prelude - let bpgm := Strata.pythonToBoogie Strata.Python.Internal.signatures pgm + let bpgm := Strata.pythonToCore Strata.Python.Internal.signatures pgm let newPgm : Core.Program := { decls := preludePgm.decls ++ bpgm.decls } IO.print newPgm @@ -199,7 +199,7 @@ def pyAnalyzeCommand : Command where if verbose then IO.print pgm let preludePgm := Strata.Python.Internal.Core.prelude - let bpgm := Strata.pythonToBoogie Strata.Python.Internal.signatures pgm + let bpgm := Strata.pythonToCore Strata.Python.Internal.signatures pgm let newPgm : Core.Program := { decls := preludePgm.decls ++ bpgm.decls } if verbose then IO.print newPgm From c05c32c945a8b39243913c3c58d73cb57b661bd2 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 15:45:56 -0600 Subject: [PATCH 11/19] Updates in CBMC, Boogie.getProgram -> Core.getProgram --- .../Backends/CBMC/{BoogieToCBMC.lean => CoreToCBMC.lean} | 0 Strata/Languages/Core/Verifier.lean | 4 ++-- Strata/Languages/Python/BoogiePrelude.lean | 2 +- StrataTest/Languages/Core/Examples/Axioms.lean | 2 +- StrataTest/Languages/Core/Examples/Functions.lean | 2 +- StrataTest/Languages/Core/Examples/ProcedureCall.lean | 2 +- StrataToCBMC.lean | 8 ++++---- 7 files changed, 10 insertions(+), 10 deletions(-) rename Strata/Backends/CBMC/{BoogieToCBMC.lean => CoreToCBMC.lean} (100%) diff --git a/Strata/Backends/CBMC/BoogieToCBMC.lean b/Strata/Backends/CBMC/CoreToCBMC.lean similarity index 100% rename from Strata/Backends/CBMC/BoogieToCBMC.lean rename to Strata/Backends/CBMC/CoreToCBMC.lean diff --git a/Strata/Languages/Core/Verifier.lean b/Strata/Languages/Core/Verifier.lean index a60dbd56a..2e08c2d1e 100644 --- a/Strata/Languages/Core/Verifier.lean +++ b/Strata/Languages/Core/Verifier.lean @@ -433,7 +433,7 @@ def typeCheck (ictx : InputContext) (env : Program) (options : Options := Option else .error s!"DDM Transform Error: {repr errors}" -def Boogie.getProgram +def Core.getProgram (p : Strata.Program) (ictx : InputContext := Inhabited.default) : Core.Program × Array String := TransM.run ictx (translateProgram p) @@ -444,7 +444,7 @@ def verify (options : Options := Options.default) (moreFns : @Lambda.Factory Core.CoreLParams := Lambda.Factory.default) : IO Core.VCResults := do - let (program, errors) := Boogie.getProgram env ictx + let (program, errors) := Core.getProgram env ictx if errors.isEmpty then -- dbg_trace f!"AST: {program}" EIO.toIO (fun f => IO.Error.userError (toString f)) diff --git a/Strata/Languages/Python/BoogiePrelude.lean b/Strata/Languages/Python/BoogiePrelude.lean index b4b71dc59..13226d121 100644 --- a/Strata/Languages/Python/BoogiePrelude.lean +++ b/Strata/Languages/Python/BoogiePrelude.lean @@ -358,6 +358,6 @@ spec { #end def Core.prelude : Core.Program := - Boogie.getProgram Strata.boogiePrelude |>.fst + Core.getProgram Strata.boogiePrelude |>.fst end Strata diff --git a/StrataTest/Languages/Core/Examples/Axioms.lean b/StrataTest/Languages/Core/Examples/Axioms.lean index df3cb302a..c37860357 100644 --- a/StrataTest/Languages/Core/Examples/Axioms.lean +++ b/StrataTest/Languages/Core/Examples/Axioms.lean @@ -129,7 +129,7 @@ assert [axiomPgm2_main_assert]: (x >= 0 ==> f(x) > x); /-- info: [] -/ #guard_msgs in -#eval let (program, _) := Boogie.getProgram axiomPgm2 +#eval let (program, _) := Core.getProgram axiomPgm2 Std.format (Core.Program.getIrrelevantAxioms program ["f"]) /-- diff --git a/StrataTest/Languages/Core/Examples/Functions.lean b/StrataTest/Languages/Core/Examples/Functions.lean index 9fa0aaf30..f68e06fd1 100644 --- a/StrataTest/Languages/Core/Examples/Functions.lean +++ b/StrataTest/Languages/Core/Examples/Functions.lean @@ -35,7 +35,7 @@ barTest1 callers: [barTest4, barTest3] fooConst callees: [] -/ #guard_msgs in -#eval let (program, _) := Boogie.getProgram funcPgm +#eval let (program, _) := Core.getProgram funcPgm let cg := (Core.Program.toFunctionCG program) let ans1 := Core.CallGraph.getCalleesClosure cg "barTest4" let ans2 := Core.CallGraph.getCallersClosure cg "barTest1" diff --git a/StrataTest/Languages/Core/Examples/ProcedureCall.lean b/StrataTest/Languages/Core/Examples/ProcedureCall.lean index 55f51bf13..8bcf696d0 100644 --- a/StrataTest/Languages/Core/Examples/ProcedureCall.lean +++ b/StrataTest/Languages/Core/Examples/ProcedureCall.lean @@ -54,7 +54,7 @@ info: { callees := Std.HashMap.ofList [("Inc", []), ("Q2", ["Q1"]), ("P", ["Inc" callers := Std.HashMap.ofList [("Inc", ["P"]), ("Q1", ["Q2"])] } -/ #guard_msgs in -#eval let (program, _) := Boogie.getProgram globalCounterPgm +#eval let (program, _) := Core.getProgram globalCounterPgm Core.Program.toProcedureCG program /-- diff --git a/StrataToCBMC.lean b/StrataToCBMC.lean index 7ecf3007e..4d97039a8 100644 --- a/StrataToCBMC.lean +++ b/StrataToCBMC.lean @@ -6,7 +6,7 @@ import Lean.Data.Json import Strata.Backends.CBMC.StrataToCBMC -import Strata.Backends.CBMC.BoogieToCBMC +import Strata.Backends.CBMC.CoreToCBMC import Strata.Languages.Core.Verifier import Strata.Languages.C_Simp.Verify import Strata.Util.IO @@ -34,10 +34,10 @@ def main (args : List String) : IO Unit := do let csimp_prog := C_Simp.get_program pgm IO.println (CSimp.testSymbols csimp_prog.funcs.head!) else if file.endsWith ".core.st" then - let boogie_prog := (Boogie.getProgram pgm inputCtx).fst - match boogie_prog.decls.head! with + let core_prog := (Core.getProgram pgm inputCtx).fst + match core_prog.decls.head! with | .proc f => IO.println (Core.testSymbols f) - | _ => IO.println "Error: expected boogie procedure" + | _ => IO.println "Error: expected Strata Core procedure" else IO.println "Error: Unrecognized file extension" | .error errors => From 9be26990a284999baa7e0a3d3a69a3e6bd8dd273 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 15:53:33 -0600 Subject: [PATCH 12/19] Python's BoogiePrelude, and more updates in other places --- Examples/HeapReasoning.core.st | 2 +- Strata/Languages/C_Simp/Verify.lean | 16 +++++++------- Strata/Languages/Core/Axiom.lean | 2 +- Strata/Languages/Core/Function.lean | 2 +- Strata/Languages/Core/Program.lean | 2 +- Strata/Languages/Core/Verifier.lean | 4 ++-- .../{BoogiePrelude.lean => CorePrelude.lean} | 4 ++-- Strata/Languages/Python/Python.lean | 2 +- .../Backends/CBMC/SimpleAdd/mkGotoBin.sh | 2 +- .../Internal/InternalBoogiePrelude.lean | 21 ------------------- .../Languages/C_Simp/Examples/Coprime.lean | 2 +- .../C_Simp/Examples/LinearSearch.lean | 2 +- .../Languages/C_Simp/Examples/LoopSimple.lean | 2 +- .../C_Simp/Examples/LoopTrivial.lean | 2 +- 14 files changed, 22 insertions(+), 43 deletions(-) rename Strata/Languages/Python/{BoogiePrelude.lean => CorePrelude.lean} (99%) delete mode 100644 StrataTest/Internal/InternalBoogiePrelude.lean diff --git a/Examples/HeapReasoning.core.st b/Examples/HeapReasoning.core.st index faac96ede..4f6b654b7 100644 --- a/Examples/HeapReasoning.core.st +++ b/Examples/HeapReasoning.core.st @@ -1,5 +1,5 @@ program Core; -// lake exe StrataVerify Strata/Languages/Boogie/Examples/HeapReasoning.core.st +// lake exe StrataVerify Examples/HeapReasoning.core.st // Prelude begin -------------------------------------------------- type Ref; diff --git a/Strata/Languages/C_Simp/Verify.lean b/Strata/Languages/C_Simp/Verify.lean index 1fa788d8b..d3da739d9 100644 --- a/Strata/Languages/C_Simp/Verify.lean +++ b/Strata/Languages/C_Simp/Verify.lean @@ -103,16 +103,16 @@ def loop_elimination_statement(s : C_Simp.Statement) : Core.Statement := | _, _ => panic! "Loop elimination require measure and invariant" | _ => translate_stmt s --- C_Simp functions are Boogie procedures +-- C_Simp functions are Strata Core procedures def loop_elimination_function(f : C_Simp.Function) : Core.Procedure := - let boogie_preconditions := [("pre", {expr := translate_expr f.pre })] - let boogie_postconditions := [("post", {expr := translate_expr f.post })] + let core_preconditions := [("pre", {expr := translate_expr f.pre })] + let core_postconditions := [("post", {expr := translate_expr f.post })] {header := {name := f.name.name, typeArgs := [], inputs := f.inputs.map (λ p => (p.fst.name, p.snd)), outputs := [("return", f.ret_ty)]}, spec := {modifies := [], - preconditions := boogie_preconditions, - postconditions := boogie_postconditions}, + preconditions := core_preconditions, + postconditions := core_postconditions}, body := f.body.map loop_elimination_statement} @@ -120,7 +120,7 @@ def loop_elimination(program : C_Simp.Program) : Core.Program := {decls := program.funcs.map (λ f => .proc (loop_elimination_function f) {})} -- Do loop elimination -def to_boogie(program : C_Simp.Program) : Core.Program := +def to_core(program : C_Simp.Program) : Core.Program := loop_elimination program def C_Simp.get_program (p : Strata.Program) : C_Simp.Program := @@ -129,12 +129,12 @@ def C_Simp.get_program (p : Strata.Program) : C_Simp.Program := def C_Simp.typeCheck (p : Strata.Program) (options : Options := Options.default): Except Std.Format Core.Program := do let program := C_Simp.get_program p - Core.typeCheck options (to_boogie program) + Core.typeCheck options (to_core program) def C_Simp.verify (smtsolver : String) (p : Strata.Program) (options : Options := Options.default): IO Core.VCResults := do let program := C_Simp.get_program p EIO.toIO (fun f => IO.Error.userError (toString f)) - (Core.verify smtsolver (to_boogie program) options) + (Core.verify smtsolver (to_core program) options) end Strata diff --git a/Strata/Languages/Core/Axiom.lean b/Strata/Languages/Core/Axiom.lean index ea2da837e..a88781357 100644 --- a/Strata/Languages/Core/Axiom.lean +++ b/Strata/Languages/Core/Axiom.lean @@ -20,7 +20,7 @@ open Lambda /-! ## Axioms -Axioms are propositions assumed to be true throughout a Strata.Boogie program. +Axioms are propositions assumed to be true throughout a Strata Core program. They are passed on as assumptions to the SMT solver during VC generation. It's the responsibility of the user to ensure that they are consistent. -/ diff --git a/Strata/Languages/Core/Function.lean b/Strata/Languages/Core/Function.lean index 4823c029f..d2ff685bc 100644 --- a/Strata/Languages/Core/Function.lean +++ b/Strata/Languages/Core/Function.lean @@ -15,7 +15,7 @@ namespace Core open Std (ToFormat Format format) open Lambda -/-! # Boogie Functions -/ +/-! # Strata Core Functions -/ abbrev Function := Lambda.LFunc CoreLParams diff --git a/Strata/Languages/Core/Program.lean b/Strata/Languages/Core/Program.lean index 7fa81ad09..67fe33ddd 100644 --- a/Strata/Languages/Core/Program.lean +++ b/Strata/Languages/Core/Program.lean @@ -39,7 +39,7 @@ instance : ToFormat DeclKind where | .func => "function" /-- -A Boogie declaration. +A Strata Core declaration. Note: constants are 0-ary functions. -/ inductive Decl where diff --git a/Strata/Languages/Core/Verifier.lean b/Strata/Languages/Core/Verifier.lean index 2e08c2d1e..1930ca5cb 100644 --- a/Strata/Languages/Core/Verifier.lean +++ b/Strata/Languages/Core/Verifier.lean @@ -19,7 +19,7 @@ namespace Strata.SMT.Encoder open Strata.SMT.Encoder -- Derived from Strata.SMT.Encoder.encode. -def encodeBoogie (ctx : Core.SMT.Context) (prelude : SolverM Unit) (ts : List Term) : +def encodeCore (ctx : Core.SMT.Context) (prelude : SolverM Unit) (ts : List Term) : SolverM (List String × EncoderState) := do Solver.reset Solver.setLogic "ALL" @@ -193,7 +193,7 @@ def dischargeObligation let handle ← IO.FS.Handle.mk filename IO.FS.Mode.write let solver ← Solver.fileWriter handle let prelude := getSolverPrelude smtsolver - let (ids, estate) ← Strata.SMT.Encoder.encodeBoogie ctx prelude terms solver + let (ids, estate) ← Strata.SMT.Encoder.encodeCore ctx prelude terms solver let _ ← solver.checkSat ids -- Will return unknown for Solver.fileWriter if options.verbose then IO.println s!"Wrote problem to {filename}." let flags := getSolverFlags options smtsolver diff --git a/Strata/Languages/Python/BoogiePrelude.lean b/Strata/Languages/Python/CorePrelude.lean similarity index 99% rename from Strata/Languages/Python/BoogiePrelude.lean rename to Strata/Languages/Python/CorePrelude.lean index 13226d121..c58fc0951 100644 --- a/Strata/Languages/Python/BoogiePrelude.lean +++ b/Strata/Languages/Python/CorePrelude.lean @@ -11,7 +11,7 @@ import Strata.Languages.Core.Verifier namespace Strata -def boogiePrelude := +def corePrelude := #strata program Core; @@ -358,6 +358,6 @@ spec { #end def Core.prelude : Core.Program := - Core.getProgram Strata.boogiePrelude |>.fst + Core.getProgram Strata.corePrelude |>.fst end Strata diff --git a/Strata/Languages/Python/Python.lean b/Strata/Languages/Python/Python.lean index b6e791705..c704939eb 100644 --- a/Strata/Languages/Python/Python.lean +++ b/Strata/Languages/Python/Python.lean @@ -6,5 +6,5 @@ import Strata.Languages.Python.PythonToCore import Strata.Languages.Python.PythonDialect -import StrataTest.Internal.InternalBoogiePrelude +import StrataTest.Internal.InternalCorePrelude import StrataTest.Internal.InternalFunctionSignatures diff --git a/StrataTest/Backends/CBMC/SimpleAdd/mkGotoBin.sh b/StrataTest/Backends/CBMC/SimpleAdd/mkGotoBin.sh index ae2709533..95735407c 100755 --- a/StrataTest/Backends/CBMC/SimpleAdd/mkGotoBin.sh +++ b/StrataTest/Backends/CBMC/SimpleAdd/mkGotoBin.sh @@ -4,7 +4,7 @@ echo "Cleaning any previous artifacts" rm -f *.json rm -f *.gb -echo "Writing out JSON files from a Strata.Boogie program SimpleAdd" +echo "Writing out JSON files from a Strata Core program SimpleAdd" pushd ../../../../ lake exe StrataCoreToGoto writeFiles popd diff --git a/StrataTest/Internal/InternalBoogiePrelude.lean b/StrataTest/Internal/InternalBoogiePrelude.lean deleted file mode 100644 index f0960b798..000000000 --- a/StrataTest/Internal/InternalBoogiePrelude.lean +++ /dev/null @@ -1,21 +0,0 @@ -/- - Copyright Strata Contributors - - SPDX-License-Identifier: Apache-2.0 OR MIT --/ - -import Strata.DDM.Elab -import Strata.DDM.AST -import Strata.Languages.Core.DDMTransform.Parse -import Strata.Languages.Core.Verifier -import Strata.Languages.Python.BoogiePrelude - -namespace Strata -namespace Python -namespace Internal - -def Core.prelude : Core.Program := Strata.Core.prelude - -end Internal -end Python -end Strata diff --git a/StrataTest/Languages/C_Simp/Examples/Coprime.lean b/StrataTest/Languages/C_Simp/Examples/Coprime.lean index f69b104da..9cbed9350 100644 --- a/StrataTest/Languages/C_Simp/Examples/Coprime.lean +++ b/StrataTest/Languages/C_Simp/Examples/Coprime.lean @@ -111,4 +111,4 @@ else{} return := #true -/ #guard_msgs in -#eval Strata.to_boogie (Strata.C_Simp.get_program CoprimePgm) +#eval Strata.to_core (Strata.C_Simp.get_program CoprimePgm) diff --git a/StrataTest/Languages/C_Simp/Examples/LinearSearch.lean b/StrataTest/Languages/C_Simp/Examples/LinearSearch.lean index 43862c6c2..fce0cb5fc 100644 --- a/StrataTest/Languages/C_Simp/Examples/LinearSearch.lean +++ b/StrataTest/Languages/C_Simp/Examples/LinearSearch.lean @@ -102,4 +102,4 @@ else{} return := #false -/ #guard_msgs in -#eval Strata.to_boogie (Strata.C_Simp.get_program LinearSearchEnv) +#eval Strata.to_core (Strata.C_Simp.get_program LinearSearchEnv) diff --git a/StrataTest/Languages/C_Simp/Examples/LoopSimple.lean b/StrataTest/Languages/C_Simp/Examples/LoopSimple.lean index a7c952f0c..a996e5235 100644 --- a/StrataTest/Languages/C_Simp/Examples/LoopSimple.lean +++ b/StrataTest/Languages/C_Simp/Examples/LoopSimple.lean @@ -104,7 +104,7 @@ assert [sum_assert] (((~Int.Div ((~Int.Mul n) ((~Int.Sub n) #1))) #2) == sum) return := sum -/ #guard_msgs in -#eval Strata.to_boogie (Strata.C_Simp.get_program LoopSimplePgm) +#eval Strata.to_core (Strata.C_Simp.get_program LoopSimplePgm) /-- info: [Strata.Core] Type checking succeeded. diff --git a/StrataTest/Languages/C_Simp/Examples/LoopTrivial.lean b/StrataTest/Languages/C_Simp/Examples/LoopTrivial.lean index 64acb39b1..a115d542f 100644 --- a/StrataTest/Languages/C_Simp/Examples/LoopTrivial.lean +++ b/StrataTest/Languages/C_Simp/Examples/LoopTrivial.lean @@ -94,7 +94,7 @@ assert [i_eq_n] (i == n) return := i -/ #guard_msgs in -#eval Strata.to_boogie (Strata.C_Simp.get_program LoopTrivialPgm) +#eval Strata.to_core (Strata.C_Simp.get_program LoopTrivialPgm) /-- info: [Strata.Core] Type checking succeeded. From 1c76e161dc4dfa5bee9b558a5056c64d70ba10dd Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 15:57:51 -0600 Subject: [PATCH 13/19] More Boogie -> Core updates --- .kiro/steering/structure.md | 6 +++--- Strata/DL/Imperative/HasVars.lean | 1 - Strata/DL/Lambda/TestGen.lean | 2 +- Strata/Languages/Core/CallGraph.lean | 4 ++-- Strata/Languages/Core/CmdType.lean | 2 +- Strata/Languages/Core/DDMTransform/Translate.lean | 8 ++++---- Strata/Languages/Core/Factory.lean | 2 +- Strata/Languages/Core/Procedure.lean | 2 +- Strata/Languages/Core/Statement.lean | 2 +- Strata/Languages/Core/StatementEval.lean | 4 ++-- Strata/Languages/Core/TypeDecl.lean | 4 ++-- docs/Architecture.md | 2 +- 12 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.kiro/steering/structure.md b/.kiro/steering/structure.md index b41f1ed8f..4370bb3e8 100644 --- a/.kiro/steering/structure.md +++ b/.kiro/steering/structure.md @@ -6,7 +6,7 @@ inclusion: always ## Overview -Strata is a Lean4 verification framework using **dialects** as composable language building blocks. The primary target is the **Boogie dialect** for deductive program verification. +Strata is a Lean4 verification framework using **dialects** as composable language building blocks. The primary target is the **Strata Core dialect** for deductive program verification. ## Repository Structure @@ -210,7 +210,7 @@ Generated VCs saved in `vcs/*.smt2` Before starting any implementation task: -1. **Identify the layer** you're working on (Lambda, Imperative, Boogie, Transform) +1. **Identify the layer** you're working on (Lambda, Imperative, Strata Core, Transform) 2. **Read the core files** for that layer from the Key Files Quick Reference table 3. **Read related files** in the same directory to understand patterns and conventions 4. **Check for similar implementations** in other dialects or transformations @@ -237,6 +237,6 @@ Before starting any implementation task: - **Expressions:** Start with Lambda dialect (`Strata/DL/Lambda/`) - **Statements:** Build on Imperative dialect (`Strata/DL/Imperative/`) -- **New languages:** Extend existing dialects, follow Boogie as reference +- **New languages:** Extend existing dialects, follow Strata Core as reference - **Transformations:** Implement in `Strata/Transform/`, add tests in `StrataTest/Transform/` - **Testing:** Add examples in `Examples/`, unit tests and property-based tests in `StrataTest/` diff --git a/Strata/DL/Imperative/HasVars.lean b/Strata/DL/Imperative/HasVars.lean index ef4dff3a1..4658df925 100644 --- a/Strata/DL/Imperative/HasVars.lean +++ b/Strata/DL/Imperative/HasVars.lean @@ -6,7 +6,6 @@ import Strata.DL.Imperative.PureExpr --- open Imperative Boogie namespace Imperative /-! # Pure Expression Variable Lookup : HasVarsPure -/ diff --git a/Strata/DL/Lambda/TestGen.lean b/Strata/DL/Lambda/TestGen.lean index 187aa8f45..c72e90401 100644 --- a/Strata/DL/Lambda/TestGen.lean +++ b/Strata/DL/Lambda/TestGen.lean @@ -1051,7 +1051,7 @@ instance {T : LExprParams} return Lambda.LExpr.fvar m x.fst none else throw Gen.genericFailure), - (0, -- FIXME: for now we avoid generating lambdas for the boogie translator. + (0, -- FIXME: for now we avoid generating lambdas for the Strata Core translator. match ty_1 with | Lambda.LTy.forAll (List.nil) diff --git a/Strata/Languages/Core/CallGraph.lean b/Strata/Languages/Core/CallGraph.lean index e502fd073..26ebda9ab 100644 --- a/Strata/Languages/Core/CallGraph.lean +++ b/Strata/Languages/Core/CallGraph.lean @@ -68,8 +68,8 @@ def buildCallGraph (items : List (String × List String)) : CallGraph := { callees := calleeMap, callers := callerMap } /-- -Extract function calls from an expression. We ignore Boogie's builtin functions -(`Boogie.builtinFunctions`) here. +Extract function calls from an expression. We ignore builtin functions +(`Core.builtinFunctions`) here. -/ def extractFunctionCallsFromExpr (expr : Expression.Expr) : List String := match expr with diff --git a/Strata/Languages/Core/CmdType.lean b/Strata/Languages/Core/CmdType.lean index 53fd21de8..db6528ce9 100644 --- a/Strata/Languages/Core/CmdType.lean +++ b/Strata/Languages/Core/CmdType.lean @@ -34,7 +34,7 @@ def freeVars (e : (LExpr CoreLParams.mono)) : List CoreIdent := (LExpr.freeVars e).map (fun (i, _) => i) /-- -Preprocess a user-facing type in Boogie amounts to converting a poly-type (i.e., +Preprocess a user-facing type in Core amounts to converting a poly-type (i.e., `LTy`) to a mono-type (i.e., `LMonoTy`) via instantiation. We still return an `LTy`, with no bound variables. -/ diff --git a/Strata/Languages/Core/DDMTransform/Translate.lean b/Strata/Languages/Core/DDMTransform/Translate.lean index 861516deb..668b09f1b 100644 --- a/Strata/Languages/Core/DDMTransform/Translate.lean +++ b/Strata/Languages/Core/DDMTransform/Translate.lean @@ -245,7 +245,7 @@ partial def translateLMonoTy (bindings : TransBindings) (arg : Arg) : -- Type Declaration let ty := tcons.toType -- While the "unsafe" below looks scary, we should be alright as far as - -- Boogie is concerned. See `Boogie.TypeConstructor`, where there is no + -- Core is concerned. See `Core.TypeConstructor`, where there is no -- facility for providing the type arguments. pure ty.toMonoTypeUnsafe | .type (.syn syn) _md => @@ -1438,7 +1438,7 @@ def translateGlobalVar (bindings : TransBindings) (op : Operation) : --------------------------------------------------------------------- -partial def translateBoogieDecls (p : Program) (bindings : TransBindings) : +partial def translateCoreDecls (p : Program) (bindings : TransBindings) : TransM Core.Decls := do let (decls, _) ← go 0 p.commands.size bindings p.commands return decls @@ -1474,13 +1474,13 @@ partial def translateBoogieDecls (p : Program) (bindings : TransBindings) : translateFunction .Definition p bindings op | q`Core.command_fndecl => translateFunction .Declaration p bindings op - | _ => TransM.error s!"translateBoogieDecls unimplemented for {repr op}" + | _ => TransM.error s!"translateCoreDecls unimplemented for {repr op}" pure ([decl], bindings) let (decls, bindings) ← go (count + 1) max bindings ops return (newDecls ++ decls, bindings) def translateProgram (p : Program) : TransM Core.Program := do - let decls ← translateBoogieDecls p {} + let decls ← translateCoreDecls p {} return { decls := decls } --------------------------------------------------------------------- diff --git a/Strata/Languages/Core/Factory.lean b/Strata/Languages/Core/Factory.lean index 939b32287..4cbc61ec9 100644 --- a/Strata/Languages/Core/Factory.lean +++ b/Strata/Languages/Core/Factory.lean @@ -558,7 +558,7 @@ def mkTriggerExpr (ts : List (List Expression.Expr)) : Expression.Expr := groups.foldl (fun gs g => .app () (.app () addTriggerGroupOp g) gs) emptyTriggersOp /-- -Get all the built-in functions supported by Boogie. +Get all the built-in functions supported by Strata Core. -/ def builtinFunctions : Array String := Factory.map (fun f => CoreIdent.toPretty f.name) diff --git a/Strata/Languages/Core/Procedure.lean b/Strata/Languages/Core/Procedure.lean index 1c2d9a2d9..e1fd6bf42 100644 --- a/Strata/Languages/Core/Procedure.lean +++ b/Strata/Languages/Core/Procedure.lean @@ -44,7 +44,7 @@ instance : Repr (⟨⟨ExpressionMetadata, CoreIdent⟩, LMonoTy⟩ : LExprParam instance : Repr Expression.Expr := show Repr Expression.Expr from inferInstance -/-! # Boogie Procedures -/ +/-! # Strata Core Procedures -/ structure Procedure.Header where name : CoreIdent diff --git a/Strata/Languages/Core/Statement.lean b/Strata/Languages/Core/Statement.lean index da9300829..eaa843393 100644 --- a/Strata/Languages/Core/Statement.lean +++ b/Strata/Languages/Core/Statement.lean @@ -34,7 +34,7 @@ inductive CmdExt (P : PureExpr) where (md : MetaData P := .empty) /-- -We parameterize Boogie's Commands with Lambda dialect's expressions. +We parameterize Strata Core's Commands with Lambda dialect's expressions. -/ abbrev Command := CmdExt Expression diff --git a/Strata/Languages/Core/StatementEval.lean b/Strata/Languages/Core/StatementEval.lean index 76de86875..34749e28e 100644 --- a/Strata/Languages/Core/StatementEval.lean +++ b/Strata/Languages/Core/StatementEval.lean @@ -60,7 +60,7 @@ Evaluate a procedure call `lhs := pname(args)`. def Command.evalCall (E : Env) (old_var_subst : SubstMap) (lhs : List Expression.Ident) (pname : String) (args : List Expression.Expr) (md : Imperative.MetaData Expression) : Command × Env := - -- Procedures in Boogie have a `modifies` clause that contain global variables that + -- Procedures in Strata Core have a `modifies` clause that contain global variables that -- can be modified by the procedure. Also, the procedure's post-conditions can -- contain `old ` expressions, which refer to the value of -- `` before the execution of the procedure (i.e., pre-state). See also @@ -375,7 +375,7 @@ def evalAuxGo (steps : Nat) (old_var_subst : SubstMap) (Ewn : EnvWithNext) (ss : | .loop _ _ _ _ _ => panic! "Cannot evaluate `loop` statement. \ Please transform your program to eliminate loops before \ - calling Boogie.Statement.evalAux" + calling Core.Statement.evalAux" | .goto l md => [{ Ewn with stk := Ewn.stk.appendToTop [.goto l md], nextLabel := (some l)}] diff --git a/Strata/Languages/Core/TypeDecl.lean b/Strata/Languages/Core/TypeDecl.lean index 65fdac52b..f059da067 100644 --- a/Strata/Languages/Core/TypeDecl.lean +++ b/Strata/Languages/Core/TypeDecl.lean @@ -51,7 +51,7 @@ open Lambda.LTy.Syntax in #guard_msgs in #eval format $ TypeConstructor.toType { name := "Foo", numargs := 3 } -/-! # Boogie Type Synonyms -/ +/-! # Strata Core Type Synonyms -/ structure TypeSynonym where name : String @@ -81,7 +81,7 @@ def TypeSynonym.toLHSLTy (t : TypeSynonym) : LTy := def TypeSynonym.toRHSLTy (t : TypeSynonym) : LTy := .forAll t.typeArgs t.type -/-! # Boogie Type Declarations -/ +/-! # Strata Core Type Declarations -/ inductive TypeDecl where | con : TypeConstructor → TypeDecl diff --git a/docs/Architecture.md b/docs/Architecture.md index ff7e98b1a..2defda269 100644 --- a/docs/Architecture.md +++ b/docs/Architecture.md @@ -54,7 +54,7 @@ The `Imperative` dialect also includes a verification condition generator (VCG) The C_Simp dialect ([`Strata.Languages.C_Simp`](../Strata//Languages/C_Simp/)) is a vaguely C-like language intended to show how to model common programming language constructs in Strata. There are many examples in `C_Simp/Examples`. C_Simp builds on the `Imperative` dialect parameterized by the `Lambda` dialect. -`C_Simp/Verify.lean` demonstrates verification via transformation to Strata Core. A loop elimination pass is first run to transform loops into the appropriate `assume` and `assert` commands, and then Boogie’s VCG, described above, is used to verify the program. +`C_Simp/Verify.lean` demonstrates verification via transformation to Strata Core. A loop elimination pass is first run to transform loops into the appropriate `assume` and `assert` commands, and then Strata Core's VCG, described above, is used to verify the program. ### Laurel From 52763869fb8c3cfada8bab5b2f865676842376e4 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 15:59:24 -0600 Subject: [PATCH 14/19] Laurel to Core --- ...lator.lean => LaurelToCoreTranslator.lean} | 26 +++++++++---------- StrataTest/Languages/Laurel/TestExamples.lean | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) rename Strata/Languages/Laurel/{LaurelToBoogieTranslator.lean => LaurelToCoreTranslator.lean} (92%) diff --git a/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean b/Strata/Languages/Laurel/LaurelToCoreTranslator.lean similarity index 92% rename from Strata/Languages/Laurel/LaurelToBoogieTranslator.lean rename to Strata/Languages/Laurel/LaurelToCoreTranslator.lean index 56e2c8891..27c40c439 100644 --- a/Strata/Languages/Laurel/LaurelToBoogieTranslator.lean +++ b/Strata/Languages/Laurel/LaurelToCoreTranslator.lean @@ -25,7 +25,7 @@ open Core (intAddOp intSubOp intMulOp intDivOp intModOp intNegOp intLtOp intLeOp open Lambda (LMonoTy LTy LExpr) /- -Translate Laurel HighType to Boogie Type +Translate Laurel HighType to Core Type -/ def translateType (ty : HighType) : LMonoTy := match ty with @@ -35,7 +35,7 @@ def translateType (ty : HighType) : LMonoTy := | _ => panic s!"unsupported type {repr ty}" /-- -Translate Laurel StmtExpr to Boogie Expression +Translate Laurel StmtExpr to Core Expression -/ def translateExpr (expr : StmtExpr) : Core.Expression.Expr := match h: expr with @@ -92,7 +92,7 @@ def getNameFromMd (md : Imperative.MetaData Core.Expression): String := s!"({fileRange.start.column},{fileRange.start.line})" /-- -Translate Laurel StmtExpr to Boogie Statements +Translate Laurel StmtExpr to Core Statements Takes the list of output parameter names to handle return statements correctly -/ def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Core.Statement := @@ -133,13 +133,13 @@ def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Core. let belse := match elseBranch with | some e => translateStmt outputParams e | none => [] - -- Use Boogie's if-then-else construct + -- Use Core's if-then-else construct [Imperative.Stmt.ite bcond bthen belse .empty] | .StaticCall name args => let boogieArgs := args.map translateExpr [Core.Statement.call [] name boogieArgs] | .Return valueOpt => - -- In Boogie, returns are done by assigning to output parameters + -- In Core, returns are done by assigning to output parameters match valueOpt, outputParams.head? with | some value, some outParam => -- Assign to the first output parameter, then assume false for no fallthrough @@ -158,26 +158,26 @@ def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Core. | _ => panic! Std.Format.pretty (Std.ToFormat.format stmt) /-- -Translate Laurel Parameter to Boogie Signature entry +Translate Laurel Parameter to Core Signature entry -/ -def translateParameterToBoogie (param : Parameter) : (Core.CoreIdent × LMonoTy) := +def translateParameterToCore (param : Parameter) : (Core.CoreIdent × LMonoTy) := let ident := Core.CoreIdent.locl param.name let ty := translateType param.type (ident, ty) /-- -Translate Laurel Procedure to Boogie Procedure +Translate Laurel Procedure to Core Procedure -/ def translateProcedure (proc : Procedure) : Core.Procedure := -- Translate input parameters - let inputPairs := proc.inputs.map translateParameterToBoogie + let inputPairs := proc.inputs.map translateParameterToCore let inputs := inputPairs let header : Core.Procedure.Header := { name := proc.name typeArgs := [] inputs := inputs - outputs := proc.outputs.map translateParameterToBoogie + outputs := proc.outputs.map translateParameterToCore } let spec : Core.Procedure.Spec := { modifies := [] @@ -195,7 +195,7 @@ def translateProcedure (proc : Procedure) : Core.Procedure := } /-- -Translate Laurel Program to Boogie Program +Translate Laurel Program to Core Program -/ def translate (program : Program) : Core.Program := -- First, sequence all assignments (move them out of expression positions) @@ -203,7 +203,7 @@ def translate (program : Program) : Core.Program := dbg_trace "=== Sequenced program Program ===" dbg_trace (toString (Std.Format.pretty (Std.ToFormat.format sequencedProgram))) dbg_trace "=================================" - -- Then translate to Boogie + -- Then translate to Core let procedures := sequencedProgram.staticProcedures.map translateProcedure let decls := procedures.map (fun p => Core.Decl.proc p .empty) { decls := decls } @@ -214,7 +214,7 @@ Verify a Laurel program using an SMT solver def verifyToVcResults (smtsolver : String) (program : Program) (options : Options := Options.default) : IO VCResults := do let boogieProgram := translate program - -- Debug: Print the generated Boogie program + -- Debug: Print the generated Core program dbg_trace "=== Generated Core.Program ===" dbg_trace (toString (Std.Format.pretty (Std.ToFormat.format boogieProgram))) dbg_trace "=================================" diff --git a/StrataTest/Languages/Laurel/TestExamples.lean b/StrataTest/Languages/Laurel/TestExamples.lean index 473eacb03..d333b6a9f 100644 --- a/StrataTest/Languages/Laurel/TestExamples.lean +++ b/StrataTest/Languages/Laurel/TestExamples.lean @@ -10,7 +10,7 @@ import Strata.DDM.BuiltinDialects.Init import Strata.Util.IO import Strata.Languages.Laurel.Grammar.LaurelGrammar import Strata.Languages.Laurel.Grammar.ConcreteToAbstractTreeTranslator -import Strata.Languages.Laurel.LaurelToBoogieTranslator +import Strata.Languages.Laurel.LaurelToCoreTranslator open StrataTest.Util open Strata From 03df913514f86294c3ff1ca0e16e5ab40c8e8432 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 16:04:42 -0600 Subject: [PATCH 15/19] BoogieToCProverGOTO, many other updates --- .../C_Simp/DDMTransform/Translate.lean | 2 +- Strata/Languages/Core/CoreGen.lean | 2 +- .../Core/DDMTransform/Translate.lean | 8 ++-- Strata/Languages/Core/Identifiers.lean | 2 +- Strata/Languages/Core/SMTEncoder.lean | 2 +- Strata/Languages/Core/StatementType.lean | 2 +- Strata/Languages/Core/WF.lean | 4 +- .../Laurel/LaurelToCoreTranslator.lean | 36 +++++++------- Strata/Languages/Python/PythonToCore.lean | 18 +++---- Strata/Transform/CallElimCorrect.lean | 2 +- ...ProverGOTO.lean => CoreToCProverGOTO.lean} | 48 +++++++++---------- .../Backends/CBMC/SimpleAdd/SimpleAdd.lean | 6 +-- .../Core/Examples/AssertionDefaultNames.lean | 2 +- .../Core/Examples/ProcedureCall.lean | 2 +- .../Examples/TypeVarImplicitlyQuantified.lean | 6 +-- 15 files changed, 71 insertions(+), 71 deletions(-) rename StrataTest/Backends/CBMC/{BoogieToCProverGOTO.lean => CoreToCProverGOTO.lean} (85%) diff --git a/Strata/Languages/C_Simp/DDMTransform/Translate.lean b/Strata/Languages/C_Simp/DDMTransform/Translate.lean index b7df8b3b4..fbca8ca84 100644 --- a/Strata/Languages/C_Simp/DDMTransform/Translate.lean +++ b/Strata/Languages/C_Simp/DDMTransform/Translate.lean @@ -11,7 +11,7 @@ import Strata.Languages.C_Simp.C_Simp namespace Strata namespace C_Simp --- (TODO) A bunch of this is just copied from Boogie (or copied with very minor changes) +-- (TODO) A bunch of this is just copied from Strata Core (or copied with very minor changes) -- What can we factor out to shared code (and where should we put it)? diff --git a/Strata/Languages/Core/CoreGen.lean b/Strata/Languages/Core/CoreGen.lean index 3a56c46e2..338c6957a 100644 --- a/Strata/Languages/Core/CoreGen.lean +++ b/Strata/Languages/Core/CoreGen.lean @@ -11,7 +11,7 @@ import Strata.DL.Util.ListUtils open Core Lambda Imperative /-! ## Strata Core Identifier Generator - This file contains a Boogie Identifier generator `CoreGenState.gen`, where the + This file contains a Strata Core Identifier generator `CoreGenState.gen`, where the uniqueness of the generated identifiers is designed to be provable. It relies on a `StringGenState` to generate unique strings (See `StringGen.lean`). diff --git a/Strata/Languages/Core/DDMTransform/Translate.lean b/Strata/Languages/Core/DDMTransform/Translate.lean index 668b09f1b..0ab640b09 100644 --- a/Strata/Languages/Core/DDMTransform/Translate.lean +++ b/Strata/Languages/Core/DDMTransform/Translate.lean @@ -785,7 +785,7 @@ partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : | .fn _ q`Core.map_get, [_ktp, _vtp, ma, ia] => let kty ← translateLMonoTy bindings _ktp let vty ← translateLMonoTy bindings _vtp - -- TODO: use Boogie.mapSelectOp, but specialized + -- TODO: use Core.mapSelectOp, but specialized let fn : LExpr CoreLParams.mono := (LExpr.op () "select" (.some (LMonoTy.mkArrow (mapTy kty vty) [kty, vty]))) let m ← translateExpr p bindings ma let i ← translateExpr p bindings ia @@ -793,7 +793,7 @@ partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : | .fn _ q`Core.map_set, [_ktp, _vtp, ma, ia, xa] => let kty ← translateLMonoTy bindings _ktp let vty ← translateLMonoTy bindings _vtp - -- TODO: use Boogie.mapUpdateOp, but specialized + -- TODO: use Core.mapUpdateOp, but specialized let fn : LExpr CoreLParams.mono := (LExpr.op () "update" (.some (LMonoTy.mkArrow (mapTy kty vty) [kty, vty, mapTy kty vty]))) let m ← translateExpr p bindings ma let i ← translateExpr p bindings ia @@ -879,7 +879,7 @@ partial def translateExpr (p : Program) (bindings : TransBindings) (arg : Arg) : | _ => TransM.error s!"translateExpr unimplemented fvar decl (no args): {format decl}" | .fvar _ i, argsa => - -- Call of a function declared/defined in Boogie. + -- Call of a function declared/defined in Core. assert! i < bindings.freeVars.size let decl := bindings.freeVars[i]! match decl with @@ -1268,7 +1268,7 @@ def translateFunction (status : FnInterp) (p : Program) (bindings : TransBinding /-- Information about a single constructor extracted during translation. -This is the Boogie-specific version of `ConstructorInfo` from AST.lean, +This is the Strata Core-specific version of `ConstructorInfo` from AST.lean, with types translated from `TypeExpr` to `LMonoTy`. -/ structure TransConstructorInfo where diff --git a/Strata/Languages/Core/Identifiers.lean b/Strata/Languages/Core/Identifiers.lean index 88d1d82b6..4c2b5367f 100644 --- a/Strata/Languages/Core/Identifiers.lean +++ b/Strata/Languages/Core/Identifiers.lean @@ -107,7 +107,7 @@ instance : DecidableEq CoreLParams.Identifier := -/-- Full representation of Boogie Identifier with scope. +/-- Full representation of Strata Core Identifier with scope. This can be useful for both debugging and generating "unique" strings, for example, as labels of proof obligations in the VC generator. diff --git a/Strata/Languages/Core/SMTEncoder.lean b/Strata/Languages/Core/SMTEncoder.lean index 74881de2b..7819858bb 100644 --- a/Strata/Languages/Core/SMTEncoder.lean +++ b/Strata/Languages/Core/SMTEncoder.lean @@ -386,7 +386,7 @@ partial def toSMTOp (E : Env) (fn : CoreIdent) (fnty : LMonoTy) (ctx : SMT.Conte | none => -- Not a constructor, tester, or destructor match E.factory.getFactoryLFunc fn.name with - | none => .error f!"Cannot find function {fn} in Boogie's Factory!" + | none => .error f!"Cannot find function {fn} in Strata Core's Factory!" | some func => match func.name.name with | "Bool.And" => .ok (.app Op.and, .bool, ctx) diff --git a/Strata/Languages/Core/StatementType.lean b/Strata/Languages/Core/StatementType.lean index 1dd9967db..8e7c3a400 100644 --- a/Strata/Languages/Core/StatementType.lean +++ b/Strata/Languages/Core/StatementType.lean @@ -20,7 +20,7 @@ open Std (ToFormat Format format) --------------------------------------------------------------------- /-- -Type checker for Boogie commands. +Type checker for Strata Core commands. Note that this function needs the entire program to type-check `call` commands by looking up the corresponding procedure's information. diff --git a/Strata/Languages/Core/WF.lean b/Strata/Languages/Core/WF.lean index 51634c9e4..4a79db2d3 100644 --- a/Strata/Languages/Core/WF.lean +++ b/Strata/Languages/Core/WF.lean @@ -8,8 +8,8 @@ import Strata.DL.Util.ListUtils import Strata.Languages.Core.Program import Strata.Languages.Core.OldExpressions -/-! # Well-Formedness of Boogie Programs - This file contains well-formedness definitions of Boogie `Program`s Note that +/-! # Well-Formedness of Strata Core Programs + This file contains well-formedness definitions of Strata Core `Program`s Note that the substructures such as `WFStatementProp` also carry a `Program` instance, and this allows us to state more expressive well-formedness conditions than a typical inductive relation. diff --git a/Strata/Languages/Laurel/LaurelToCoreTranslator.lean b/Strata/Languages/Laurel/LaurelToCoreTranslator.lean index 27c40c439..a530eb4c4 100644 --- a/Strata/Languages/Laurel/LaurelToCoreTranslator.lean +++ b/Strata/Languages/Laurel/LaurelToCoreTranslator.lean @@ -98,34 +98,34 @@ Takes the list of output parameter names to handle return statements correctly def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Core.Statement := match stmt with | @StmtExpr.Assert cond md => - let boogieExpr := translateExpr cond - [Core.Statement.assert ("assert" ++ getNameFromMd md) boogieExpr md] + let coreExpr := translateExpr cond + [Core.Statement.assert ("assert" ++ getNameFromMd md) coreExpr md] | @StmtExpr.Assume cond md => - let boogieExpr := translateExpr cond - [Core.Statement.assume ("assume" ++ getNameFromMd md) boogieExpr md] + let coreExpr := translateExpr cond + [Core.Statement.assume ("assume" ++ getNameFromMd md) coreExpr md] | .Block stmts _ => stmts.flatMap (translateStmt outputParams) | .LocalVariable name ty initializer => - let boogieMonoType := translateType ty - let boogieType := LTy.forAll [] boogieMonoType + let coreMonoType := translateType ty + let coreType := LTy.forAll [] coreMonoType let ident := Core.CoreIdent.locl name match initializer with | some initExpr => - let boogieExpr := translateExpr initExpr - [Core.Statement.init ident boogieType boogieExpr] + let coreExpr := translateExpr initExpr + [Core.Statement.init ident coreType coreExpr] | none => -- Initialize with default value let defaultExpr := match ty with | .TInt => .const () (.intConst 0) | .TBool => .const () (.boolConst false) | _ => .const () (.intConst 0) - [Core.Statement.init ident boogieType defaultExpr] + [Core.Statement.init ident coreType defaultExpr] | .Assign target value => match target with | .Identifier name => let ident := Core.CoreIdent.locl name - let boogieExpr := translateExpr value - [Core.Statement.set ident boogieExpr] + let coreExpr := translateExpr value + [Core.Statement.set ident coreExpr] | _ => [] -- Can only assign to simple identifiers | .IfThenElse cond thenBranch elseBranch => let bcond := translateExpr cond @@ -136,16 +136,16 @@ def translateStmt (outputParams : List Parameter) (stmt : StmtExpr) : List Core. -- Use Core's if-then-else construct [Imperative.Stmt.ite bcond bthen belse .empty] | .StaticCall name args => - let boogieArgs := args.map translateExpr - [Core.Statement.call [] name boogieArgs] + let coreArgs := args.map translateExpr + [Core.Statement.call [] name coreArgs] | .Return valueOpt => -- In Core, returns are done by assigning to output parameters match valueOpt, outputParams.head? with | some value, some outParam => -- Assign to the first output parameter, then assume false for no fallthrough let ident := Core.CoreIdent.locl outParam.name - let boogieExpr := translateExpr value - let assignStmt := Core.Statement.set ident boogieExpr + let coreExpr := translateExpr value + let assignStmt := Core.Statement.set ident coreExpr let noFallThrough := Core.Statement.assume "return" (.const () (.boolConst false)) .empty [assignStmt, noFallThrough] | none, _ => @@ -213,13 +213,13 @@ Verify a Laurel program using an SMT solver -/ def verifyToVcResults (smtsolver : String) (program : Program) (options : Options := Options.default) : IO VCResults := do - let boogieProgram := translate program + let coreProgram := translate program -- Debug: Print the generated Core program dbg_trace "=== Generated Core.Program ===" - dbg_trace (toString (Std.Format.pretty (Std.ToFormat.format boogieProgram))) + dbg_trace (toString (Std.Format.pretty (Std.ToFormat.format coreProgram))) dbg_trace "=================================" EIO.toIO (fun f => IO.Error.userError (toString f)) - (Core.verify smtsolver boogieProgram options) + (Core.verify smtsolver coreProgram options) def verifyToDiagnostics (smtsolver : String) (program : Program): IO (Array Diagnostic) := do let results <- verifyToVcResults smtsolver program diff --git a/Strata/Languages/Python/PythonToCore.lean b/Strata/Languages/Python/PythonToCore.lean index c7e5ea579..06dd2a1d7 100644 --- a/Strata/Languages/Python/PythonToCore.lean +++ b/Strata/Languages/Python/PythonToCore.lean @@ -43,7 +43,7 @@ def dummyTimedelta : Core.Expression.Expr := .fvar () "DUMMY_Timedelta" none ------------------------------------------------------------------------------- --- Translating a Python expression can require Boogie statements, e.g., a function call +-- Translating a Python expression can require Strata Core statements, e.g., a function call -- We translate these by first defining temporary variables to store the results of the stmts -- and then using those variables in the expression. structure PyExprTranslated where @@ -157,7 +157,7 @@ def handleGt (lhs rhs: Core.Expression.Expr) : Core.Expression.Expr := structure SubstitutionRecord where pyExpr : Python.expr SourceRange - boogieExpr : Core.Expression.Expr + coreExpr : Core.Expression.Expr instance : Repr (List SubstitutionRecord) where reprPrec xs _ := @@ -292,7 +292,7 @@ partial def collectVarDecls (translation_ctx : TranslationContext) (stmts: Array | _ => [] let dup := stmts.toList.flatMap go let dedup := deduplicateTypeAnnotations dup - let toBoogie (p: String × String) : List Core.Statement := + let toCore (p: String × String) : List Core.Statement := let name := p.fst let ty_name := p.snd match ty_name with @@ -315,7 +315,7 @@ partial def collectVarDecls (translation_ctx : TranslationContext) (stmts: Array let user_defined_class_dummy := .fvar () ("DUMMY_" ++ i.name) none [(.init name user_defined_class_ty user_defined_class_dummy), (.havoc name)] | .none => panic! s!"Unsupported type annotation: `{ty_name}`" - let foo := dedup.map toBoogie + let foo := dedup.map toCore foo.flatten def isCall (e: Python.expr SourceRange) : Bool := @@ -400,7 +400,7 @@ partial def PyExprToCore (translation_ctx : TranslationContext) (e : Python.expr if h : substitution_records.isSome && (substitution_records.get!.find? (λ r => PyExprIdent r.pyExpr e)).isSome then have hr : (List.find? (fun r => PyExprIdent r.pyExpr e) substitution_records.get!).isSome = true := by rw [Bool.and_eq_true] at h; exact h.2 let record := (substitution_records.get!.find? (λ r => PyExprIdent r.pyExpr e)).get hr - {stmts := [], expr := record.boogieExpr} + {stmts := [], expr := record.coreExpr} else match e with | .Call _ f args kwords => @@ -527,7 +527,7 @@ partial def handleFunctionCall (lhs: List Core.Expression.Ident) let fname := remapFname translation_ctx fname - -- Boogie doesn't allow nested function calls, so we need to introduce temporary variables for each nested call + -- Strata Core doesn't allow nested function calls, so we need to introduce temporary variables for each nested call let nested_args_calls := args.val.filterMap (λ a => if isCall a then some a else none) let args_calls_to_tmps := nested_args_calls.map (λ a => (a, s!"call_arg_tmp_{a.toAst.ann.start}")) let nested_kwords_calls := kwords.val.filterMap (λ a => @@ -536,8 +536,8 @@ partial def handleFunctionCall (lhs: List Core.Expression.Ident) if isCall arg then some arg else none) let kwords_calls_to_tmps := nested_kwords_calls.map (λ a => (a, s!"call_kword_tmp_{a.toAst.ann.start}")) - let substitution_records : List SubstitutionRecord := args_calls_to_tmps.toList.map (λ p => {pyExpr := p.fst, boogieExpr := .fvar () p.snd none}) ++ - kwords_calls_to_tmps.toList.map (λ p => {pyExpr := p.fst, boogieExpr := .fvar () p.snd none}) + let substitution_records : List SubstitutionRecord := args_calls_to_tmps.toList.map (λ p => {pyExpr := p.fst, coreExpr := .fvar () p.snd none}) ++ + kwords_calls_to_tmps.toList.map (λ p => {pyExpr := p.fst, coreExpr := .fvar () p.snd none}) let res := argsAndKWordsToCanonicalList translation_ctx fname args.val kwords.val substitution_records args_calls_to_tmps.toList.flatMap initTmpParam ++ kwords_calls_to_tmps.toList.flatMap initTmpParam ++ @@ -600,7 +600,7 @@ partial def PyStmtToCore (jmp_targets: List String) (translation_ctx : Translati let except_handlers := handlers.val.toList.flatMap (exceptHandlersToCore new_jmp_stack translation_ctx) let var_decls := collectVarDecls translation_ctx body.val ([.block "try_block" (var_decls ++ body.val.toList.flatMap (λ s => (PyStmtToCore new_jmp_stack translation_ctx s).fst) ++ entry_except_handlers ++ except_handlers)], none) - | .FunctionDef _ _ _ _ _ _ _ _ => panic! "Can't translate FunctionDef to Boogie statement" + | .FunctionDef _ _ _ _ _ _ _ _ => panic! "Can't translate FunctionDef to Strata Core statement" | .If _ test then_b else_b => let guard_ctx := {translation_ctx with expectedType := some (.tcons "bool" [])} ([.ite (PyExprToCore guard_ctx test).expr (ArrPyStmtToCore translation_ctx then_b.val).fst (ArrPyStmtToCore translation_ctx else_b.val).fst], none) diff --git a/Strata/Transform/CallElimCorrect.lean b/Strata/Transform/CallElimCorrect.lean index ba2621629..75416bcc4 100644 --- a/Strata/Transform/CallElimCorrect.lean +++ b/Strata/Transform/CallElimCorrect.lean @@ -2473,7 +2473,7 @@ case cons h t ih => . simp [StateT.pure,pure] at Hgen cases Hgen -/--! Theorems about well-formedness of BoogieGen -/ +/--! Theorems about well-formedness of CoreGen -/ theorem genArgExprIdentTemp : genArgExprIdent s = (l, s') → CoreIdent.isTemp l := diff --git a/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean b/StrataTest/Backends/CBMC/CoreToCProverGOTO.lean similarity index 85% rename from StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean rename to StrataTest/Backends/CBMC/CoreToCProverGOTO.lean index c15973edf..0c604fbe3 100644 --- a/StrataTest/Backends/CBMC/BoogieToCProverGOTO.lean +++ b/StrataTest/Backends/CBMC/CoreToCProverGOTO.lean @@ -11,7 +11,7 @@ import StrataTest.Backends.CBMC.ToCProverGOTO open Std (ToFormat Format format) /- -We map Boogie's procedures to a CProverGOTO program, which is then written to +We map Strata Core's procedures to a CProverGOTO program, which is then written to CBMC-compatible JSON files that contain all the necessary information to construct a GOTO binary. @@ -21,16 +21,16 @@ model-check a Strata-generated GOTO binary. ------------------------------------------------------------------------------- -abbrev BoogieParams : Lambda.LExprParams := ⟨Unit, Core.Visibility⟩ +abbrev CoreParams : Lambda.LExprParams := ⟨Unit, Core.Visibility⟩ -abbrev Boogie.ExprStr : Imperative.PureExpr := - { Ident := BoogieParams.Identifier, - Expr := Lambda.LExpr BoogieParams.mono, +abbrev Core.ExprStr : Imperative.PureExpr := + { Ident := CoreParams.Identifier, + Expr := Lambda.LExpr CoreParams.mono, Ty := Lambda.LTy, - TyEnv := @Lambda.TEnv BoogieParams.IDMeta, - TyContext := @Lambda.LContext BoogieParams, - EvalEnv := Lambda.LState BoogieParams - EqIdent := inferInstanceAs (DecidableEq BoogieParams.Identifier) } + TyEnv := @Lambda.TEnv CoreParams.IDMeta, + TyContext := @Lambda.LContext CoreParams, + EvalEnv := Lambda.LState CoreParams + EqIdent := inferInstanceAs (DecidableEq CoreParams.Identifier) } namespace CoreToGOTO @@ -55,7 +55,7 @@ instance : Imperative.ToGoto Core.Expression where toGotoType := (fun ty => Lambda.LMonoTy.toGotoType ty.toMonoTypeUnsafe) toGotoExpr := Lambda.LExpr.toGotoExpr -private def lookupTypeStr (T : Boogie.ExprStr.TyEnv) (i : Boogie.ExprStr.Ident) : +private def lookupTypeStr (T : Core.ExprStr.TyEnv) (i : Core.ExprStr.Ident) : Except Format CProverGOTO.Ty := match T.context.types.find? i with | none => .error s!"Cannot find {i} in the type context!" @@ -65,11 +65,11 @@ private def lookupTypeStr (T : Boogie.ExprStr.TyEnv) (i : Boogie.ExprStr.Ident) ty.toGotoType else .error f!"Poly-type unexpected in the context for {i}: {ty}" -private def updateTypeStr (T : Boogie.ExprStr.TyEnv) (i : Boogie.ExprStr.Ident) - (ty : Boogie.ExprStr.Ty) : Boogie.ExprStr.TyEnv := +private def updateTypeStr (T : Core.ExprStr.TyEnv) (i : Core.ExprStr.Ident) + (ty : Core.ExprStr.Ty) : Core.ExprStr.TyEnv := T.insertInContext i ty -instance : Imperative.ToGoto Boogie.ExprStr where +instance : Imperative.ToGoto Core.ExprStr where lookupType := lookupTypeStr updateType := updateTypeStr identToString := (fun x => x.name) @@ -92,8 +92,8 @@ def substVarNames {Metadata IDMeta: Type} [DecidableEq IDMeta] | .ite _ c t e' => .ite () (substVarNames c frto) (substVarNames t frto) (substVarNames e' frto) | .eq _ e1 e2 => .eq () (substVarNames e1 frto) (substVarNames e2 frto) -def Boogie.Cmd.renameVars (frto : Map String String) (c : Imperative.Cmd Core.Expression) - : Imperative.Cmd Boogie.ExprStr := +def Core.Cmd.renameVars (frto : Map String String) (c : Imperative.Cmd Core.Expression) + : Imperative.Cmd Core.ExprStr := match c with | .init name ty e _ => let e' := substVarNames e frto @@ -119,11 +119,11 @@ def Boogie.Cmd.renameVars (frto : Map String String) (c : Imperative.Cmd Core.Ex let e' := substVarNames e frto .cover label e' .empty -def Boogie.Cmds.renameVars (frto : Map String String) - (cs : Imperative.Cmds Core.Expression) : Imperative.Cmds Boogie.ExprStr := +def Core.Cmds.renameVars (frto : Map String String) + (cs : Imperative.Cmds Core.Expression) : Imperative.Cmds Core.ExprStr := match cs with | [] => [] - | c :: crest => [(Boogie.Cmd.renameVars frto c)] ++ (renameVars frto crest) + | c :: crest => [(Core.Cmd.renameVars frto c)] ++ (renameVars frto crest) ------------------------------------------------------------------------------- @@ -169,16 +169,16 @@ def transformToGoto (boogie : Core.Program) : Except Format CProverGOTO.Context let pname := Core.CoreIdent.toPretty p.header.name if !p.header.typeArgs.isEmpty then - .error f!"[transformToGoto] Translation for polymorphic Boogie procedures is unimplemented." + .error f!"[transformToGoto] Translation for polymorphic Strata Core procedures is unimplemented." let cmds ← p.body.mapM (fun b => match b with | .cmd (.cmd c) => return c - | _ => .error f!"[transformToGoto] We can process Boogie commands only, not statements! \ + | _ => .error f!"[transformToGoto] We can process Strata Core commands only, not statements! \ Statement encountered: {b}") if 1 < p.header.outputs.length then - .error f!"[transformToGoto] Translation for multi-return value Boogie procedures is unimplemented." + .error f!"[transformToGoto] Translation for multi-return value Strata Core procedures is unimplemented." let ret_tys ← p.header.outputs.values.mapM (fun ty => Lambda.LMonoTy.toGotoType ty) let ret_ty := if ret_tys.isEmpty then CProverGOTO.Ty.Empty else ret_tys[0]! @@ -193,9 +193,9 @@ def transformToGoto (boogie : Core.Program) : Except Format CProverGOTO.Context let locals_renamed := locals.zip new_locals let args_renamed := formals_renamed ++ locals_renamed - let cmds := Boogie.Cmds.renameVars args_renamed cmds + let cmds := Core.Cmds.renameVars args_renamed cmds - let ans ← @Imperative.Cmds.toGotoTransform Boogie.ExprStr + let ans ← @Imperative.Cmds.toGotoTransform Core.ExprStr CoreToGOTO.instToGotoExprStr _ Env pname cmds (loc := 0) let ending_insts : Array CProverGOTO.Instruction := #[ -- (FIXME): Add lifetime markers. @@ -213,7 +213,7 @@ def transformToGoto (boogie : Core.Program) : Except Format CProverGOTO.Context ret := ret_ty, locals := locals } else - .error f!"[transformToGoto] We can transform only a single Boogie procedure to \ + .error f!"[transformToGoto] We can transform only a single Strata Core procedure to \ GOTO at a time!" open Strata in diff --git a/StrataTest/Backends/CBMC/SimpleAdd/SimpleAdd.lean b/StrataTest/Backends/CBMC/SimpleAdd/SimpleAdd.lean index 22409e6cb..e1f9b5d76 100644 --- a/StrataTest/Backends/CBMC/SimpleAdd/SimpleAdd.lean +++ b/StrataTest/Backends/CBMC/SimpleAdd/SimpleAdd.lean @@ -4,7 +4,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT -/ -import StrataTest.Backends.CBMC.BoogieToCProverGOTO +import StrataTest.Backends.CBMC.CoreToCProverGOTO open Std (ToFormat Format format) ------------------------------------------------------------------------------- @@ -27,9 +27,9 @@ procedure simpleAdd (x : bv32, y : bv32) returns () { }; #end --- #eval BoogieToGOTO.getGotoJson "simpleAddU" Strata.simpleAddU +-- #eval CoreToGOTO.getGotoJson "simpleAddU" Strata.simpleAddU --- #eval BoogieToGOTO.writeToGotoJson (programName := "simpleAdd") +-- #eval CoreToGOTO.writeToGotoJson (programName := "simpleAdd") -- (symTabFileName := "StrataTest/Backends/CBMC/SimpleAdd/simpleAdd.symtab.json") -- (gotoFileName := "StrataTest/Backends/CBMC/SimpleAdd/simpleAdd.goto.json") -- Strata.simpleAdd diff --git a/StrataTest/Languages/Core/Examples/AssertionDefaultNames.lean b/StrataTest/Languages/Core/Examples/AssertionDefaultNames.lean index 94404cb6a..da96f9a01 100644 --- a/StrataTest/Languages/Core/Examples/AssertionDefaultNames.lean +++ b/StrataTest/Languages/Core/Examples/AssertionDefaultNames.lean @@ -21,7 +21,7 @@ spec { }; #end --- Translation from DDM AST to Boogie/Strata AST +-- Translation from DDM AST to Strata Core AST /-- info: true -/ #guard_msgs in diff --git a/StrataTest/Languages/Core/Examples/ProcedureCall.lean b/StrataTest/Languages/Core/Examples/ProcedureCall.lean index 8bcf696d0..f01ab7ff7 100644 --- a/StrataTest/Languages/Core/Examples/ProcedureCall.lean +++ b/StrataTest/Languages/Core/Examples/ProcedureCall.lean @@ -149,7 +149,7 @@ Result: ✅ pass -- DDM AST #eval globalCounterEnv.commands --- Translation from DDM AST to Boogie/Strata AST +-- Translation from DDM AST to Strata Core AST #eval TransM.run (translateProgram (globalCounterEnv.commands)) -/ diff --git a/StrataTest/Languages/Core/Examples/TypeVarImplicitlyQuantified.lean b/StrataTest/Languages/Core/Examples/TypeVarImplicitlyQuantified.lean index cbc304291..66bd8e18d 100644 --- a/StrataTest/Languages/Core/Examples/TypeVarImplicitlyQuantified.lean +++ b/StrataTest/Languages/Core/Examples/TypeVarImplicitlyQuantified.lean @@ -30,11 +30,11 @@ axiom [a2]: (forall l_0: bool, l_1: int, l_2: int, y: int :: ); #end -def boogie_pgm := TransM.run Inhabited.default (translateProgram pgm) +def core_pgm := TransM.run Inhabited.default (translateProgram pgm) /-- info: true -/ #guard_msgs in -#eval boogie_pgm.snd.isEmpty +#eval core_pgm.snd.isEmpty /-- info: [Strata.Core] Type checking succeeded. @@ -47,4 +47,4 @@ axiom a1: (∀ (∀ ((((~diff : (arrow (Map int bool) (arrow (Map int bool) (Map axiom a2: (∀ (∀ (∀ (∀ ((((~select : (arrow (Map int int) (arrow int int))) ((((~lambda_0 : (arrow bool (arrow int (arrow int (Map int int))))) %3) %2) %1)) %0) == (((~select : (arrow (Map int int) (arrow int int))) ((((~lambda_0 : (arrow bool (arrow int (arrow int (Map int int))))) %3) %1) %2)) %0)))))); -/ #guard_msgs in -#eval Core.typeCheck Options.default boogie_pgm.fst +#eval Core.typeCheck Options.default core_pgm.fst From 869e25631ed9d68f55e8b4937a3048b3be632cef Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 16:06:24 -0600 Subject: [PATCH 16/19] Final --- StrataTest/Backends/CBMC/CoreToCProverGOTO.lean | 8 ++++---- StrataTest/DDM/Integration/Java/TestGen.lean | 2 +- StrataTest/Languages/Core/DatatypeVerificationTests.lean | 2 +- .../Languages/Core/Examples/DDMAxiomsExtraction.lean | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/StrataTest/Backends/CBMC/CoreToCProverGOTO.lean b/StrataTest/Backends/CBMC/CoreToCProverGOTO.lean index 0c604fbe3..d5cfa0a46 100644 --- a/StrataTest/Backends/CBMC/CoreToCProverGOTO.lean +++ b/StrataTest/Backends/CBMC/CoreToCProverGOTO.lean @@ -155,13 +155,13 @@ def CProverGOTO.Context.toJson (programName : String) (ctx : CProverGOTO.Context { symtab := symbols, goto := goto_functions } open Lambda.LTy.Syntax in -def transformToGoto (boogie : Core.Program) : Except Format CProverGOTO.Context := do +def transformToGoto (cprog : Core.Program) : Except Format CProverGOTO.Context := do let Ctx := { Lambda.LContext.default with functions := Core.Factory, knownTypes := Core.KnownTypes } let Env := Lambda.TEnv.default - let (boogie, _Env) ← Core.Program.typeCheck Ctx Env boogie + let (cprog, _Env) ← Core.Program.typeCheck Ctx Env cprog dbg_trace f!"[Strata.Core] Type Checking Succeeded!" - if h : boogie.decls.length = 1 then - let decl := boogie.decls[0]'(by exact Nat.lt_of_sub_eq_succ h) + if h : cprog.decls.length = 1 then + let decl := cprog.decls[0]'(by exact Nat.lt_of_sub_eq_succ h) match decl.getProc? with | none => .error f!"[transformToGoto] We can process only Strata Core procedures at this time. \ Declaration encountered: {decl}" diff --git a/StrataTest/DDM/Integration/Java/TestGen.lean b/StrataTest/DDM/Integration/Java/TestGen.lean index 2711bae0e..439808ea3 100644 --- a/StrataTest/DDM/Integration/Java/TestGen.lean +++ b/StrataTest/DDM/Integration/Java/TestGen.lean @@ -7,7 +7,7 @@ import Strata.DDM.Integration.Java import Strata.DDM.Integration.Lean.Env -- For dialectExt import Strata.DDM.Integration.Lean.HashCommands -- For #load_dialect -import Strata.Languages.Core.DDMTransform.Parse -- Loads Boogie dialect into env +import Strata.Languages.Core.DDMTransform.Parse -- Loads Strata Core dialect into env namespace Strata.Java.Test diff --git a/StrataTest/Languages/Core/DatatypeVerificationTests.lean b/StrataTest/Languages/Core/DatatypeVerificationTests.lean index 320750f3c..4a8985de3 100644 --- a/StrataTest/Languages/Core/DatatypeVerificationTests.lean +++ b/StrataTest/Languages/Core/DatatypeVerificationTests.lean @@ -76,7 +76,7 @@ def containerDatatype : LDatatype Visibility := /-! ## Helper Functions -/ /-- -Create a Boogie program with datatypes and a procedure. +Create a STrata Core program with datatypes and a procedure. -/ def mkProgramWithDatatypes (datatypes : List (LDatatype Visibility)) diff --git a/StrataTest/Languages/Core/Examples/DDMAxiomsExtraction.lean b/StrataTest/Languages/Core/Examples/DDMAxiomsExtraction.lean index 539731c45..8ecb1b52a 100644 --- a/StrataTest/Languages/Core/Examples/DDMAxiomsExtraction.lean +++ b/StrataTest/Languages/Core/Examples/DDMAxiomsExtraction.lean @@ -74,7 +74,7 @@ def replaceTypesByFTV (expr: Core.Expression.Expr) (to_replace: List String): Co | .eq m e1 e2 => .eq m (replaceTypesByFTV e1 to_replace) (replaceTypesByFTV e2 to_replace) /-- - Extract all axioms from the given environment by first translating it into a Boogie Program. + Extract all axioms from the given environment by first translating it into a Strata Core Program. It then extracts LExpr body from the axioms, and replace all occurences of the typeArgs by a ftvar with the same name -/ def extractAxiomsWithFreeTypeVars (pgm: Program) (typeArgs: List String): (List Core.Expression.Expr) := From 3ae3d0a04f09b950b93b68d98ec448656acf5907 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 18:07:28 -0600 Subject: [PATCH 17/19] StrataTest/Internal/InternalCorePrelude.lean was not being added since .gitignore was listing StrataTest/Internal --- .gitignore | 4 +--- Strata/Languages/Core/CmdEval.lean | 1 - Strata/Languages/Python/CorePrelude.lean | 2 +- StrataTest/Internal/InternalCorePrelude.lean | 21 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 StrataTest/Internal/InternalCorePrelude.lean diff --git a/.gitignore b/.gitignore index 38c4713de..4d3d750d0 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,4 @@ # SMT files generated when running tests vcs/*.smt2 -Strata.code-workspace - -StrataTest/Internal \ No newline at end of file +Strata.code-workspace \ No newline at end of file diff --git a/Strata/Languages/Core/CmdEval.lean b/Strata/Languages/Core/CmdEval.lean index edf82f1e0..7a51883f1 100644 --- a/Strata/Languages/Core/CmdEval.lean +++ b/Strata/Languages/Core/CmdEval.lean @@ -114,7 +114,6 @@ instance : EvalContext Expression Env where getPathConditions := CmdEval.getPathConditions addPathCondition := CmdEval.addPathCondition deferObligation := CmdEval.deferObligation - -- lookupEval := Boogie.lookupEval instance : ToFormat (Cmds Expression × Env) where format arg := diff --git a/Strata/Languages/Python/CorePrelude.lean b/Strata/Languages/Python/CorePrelude.lean index c58fc0951..333078049 100644 --- a/Strata/Languages/Python/CorePrelude.lean +++ b/Strata/Languages/Python/CorePrelude.lean @@ -183,7 +183,7 @@ datatype Client () { // - -999999999 <= days <= 999999999 // "" -// In Boogie representation, an int type that corresponds to the full +// In the Strata Core representation, an int type that corresponds to the full // milliseconds is simply used. See Timedelta_mk. procedure timedelta(days: IntOrNone, hours: IntOrNone) returns (delta : int, maybe_except: ExceptOrNone) diff --git a/StrataTest/Internal/InternalCorePrelude.lean b/StrataTest/Internal/InternalCorePrelude.lean new file mode 100644 index 000000000..e55fcaa5b --- /dev/null +++ b/StrataTest/Internal/InternalCorePrelude.lean @@ -0,0 +1,21 @@ +/- + Copyright Strata Contributors + + SPDX-License-Identifier: Apache-2.0 OR MIT +-/ + +import Strata.DDM.Elab +import Strata.DDM.AST +import Strata.Languages.Core.DDMTransform.Parse +import Strata.Languages.Core.Verifier +import Strata.Languages.Python.CorePrelude + +namespace Strata +namespace Python +namespace Internal + +def Core.prelude : Core.Program := Strata.Core.prelude + +end Internal +end Python +end Strata From 4043a5709dc40701cf8ae41c51de177582357038 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 18:07:36 -0600 Subject: [PATCH 18/19] Resurrect the line --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 4d3d750d0..38c4713de 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ # SMT files generated when running tests vcs/*.smt2 -Strata.code-workspace \ No newline at end of file +Strata.code-workspace + +StrataTest/Internal \ No newline at end of file From 4bbb43a5bfdd177928bc932a4c8dcc06207174a4 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Thu, 15 Jan 2026 18:31:51 -0600 Subject: [PATCH 19/19] BoogieToStrataIntegrationTests.cs --- .../IntegrationTests/BoogieToStrataIntegrationTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/BoogieToStrata/IntegrationTests/BoogieToStrataIntegrationTests.cs b/Tools/BoogieToStrata/IntegrationTests/BoogieToStrataIntegrationTests.cs index 7629e0293..6c52e103e 100644 --- a/Tools/BoogieToStrata/IntegrationTests/BoogieToStrataIntegrationTests.cs +++ b/Tools/BoogieToStrata/IntegrationTests/BoogieToStrataIntegrationTests.cs @@ -113,7 +113,7 @@ public void VerifyTestFile(string fileName, string filePath) { Assert.Equal(0, exitCode); Assert.True(standardOutput.Length > 0, "Expected some output from BoogieToStrata"); Assert.True(errorOutput.Length == 0, "Expected no error output from BoogieToStrata"); - var strataFile = Path.ChangeExtension(filePath, "boogie.st"); + var strataFile = Path.ChangeExtension(filePath, "core.st"); File.WriteAllText(strataFile, standardOutput); var expectFile = Path.ChangeExtension(filePath, "expect"); string? expectString = null;