Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions AVM/Class/Translation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,14 @@ def Intent.logic
: Bool :=
-- Check that exactly one resource is created that corresponds to the intent
match Logic.filterOutDummy args.created with
| [intentRes] => BoolCheck.run do
let labelData ← BoolCheck.some <| Intent.LabelData.fromResource intentRes
BoolCheck.ret <|
-- NOTE: We should also check that the intent logic hashes of
-- `intentRes` and `intent` match.
labelData.label === ilab
&& intentRes.quantity == 1
&& intentRes.ephemeral
&& Logic.checkResourcesData labelData.data.provided args.consumed
| [intentRes] =>
let try labelData := Intent.LabelData.fromResource intentRes
-- NOTE: We should also check that the intent logic hashes of
-- `intentRes` and `intent` match.
labelData.label === ilab
&& intentRes.quantity == 1
&& intentRes.ephemeral
&& Logic.checkResourcesData labelData.data.provided args.consumed
| _ =>
false

Expand All @@ -207,21 +206,20 @@ def checkClassMemberLogic
(eco : Ecosystem lab)
(memberId : classId.label.MemberId)
(margs : memberId.Args.type)
: Bool := BoolCheck.run do
let selfObj : Object classId.label ← BoolCheck.some (Object.fromResource args.self)
: Bool :=
let try selfObj : Object classId.label := Object.fromResource args.self
let cls : Class classId := eco.classes classId
BoolCheck.ret <|
cls.invariant selfObj args &&
match memberId with
| .constructorId c =>
Constructor.logic (cls.constructors c) args
| .methodId m =>
Method.logic (cls.methods m) args
| .destructorId m =>
Destructor.logic (cls.destructors m) args
| .intentId l =>
if h : l ∈ classId.label.intentLabels then
let intent : Intent l := cls.intents l h
Intent.logic intent args
else
false
cls.invariant selfObj args &&
match memberId with
| .constructorId c =>
Constructor.logic (cls.constructors c) args
| .methodId m =>
Method.logic (cls.methods m) args
| .destructorId m =>
Destructor.logic (cls.destructors m) args
| .intentId l =>
if h : l ∈ classId.label.intentLabels then
let intent : Intent l := cls.intents l h
Intent.logic intent args
else
false
21 changes: 8 additions & 13 deletions AVM/Intent/Translation.lean
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,18 @@ open Ecosystem
intent logic checks the intent's condition. -/
def Intent.logic {ilab : Intent.Label} (intent : Intent ilab) (args : Anoma.Logic.Args Unit) : Bool :=
if args.isConsumed then
BoolCheck.run do
let data ← BoolCheck.some <| Intent.ResourceData.fromResource args.self
let receivedObjects ←
BoolCheck.some <|
List.mapSome SomeObject.fromResource <|
Logic.filterOutDummy args.created
let argsData ← BoolCheck.some <| tryCast data.args
BoolCheck.ret <|
intent.condition argsData data.provided receivedObjects
let try data := Intent.ResourceData.fromResource args.self
let try receivedObjects :=
List.mapSome SomeObject.fromResource <|
Logic.filterOutDummy args.created
let try argsData := tryCast data.args
intent.condition argsData data.provided receivedObjects
else
-- In the created case, we need to check that the list of provided objects
-- corresponds to the list consumed resources. See:
-- https://github.com/anoma/goose-lean/issues/32.
BoolCheck.run do
let data ← BoolCheck.some <| Intent.ResourceData.fromResource args.self
BoolCheck.ret <|
Logic.checkResourcesData data.provided args.consumed
let try data := Intent.ResourceData.fromResource args.self
Logic.checkResourcesData data.provided args.consumed

/-- An action which consumes the provided objects and creates the intent. This
is a helper function which handles the random number generator explicitly to
Expand Down
1 change: 0 additions & 1 deletion Prelude.lean
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Prelude.UUnit
import Prelude.BoolCheck
import Prelude.List
import Prelude.HashMap
import Prelude.TypeRep
Expand Down
25 changes: 0 additions & 25 deletions Prelude/BoolCheck.lean

This file was deleted.