Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Preloaded Examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Monterey Phoenix
MP Model Collection
Preloaded Examples
Commits
23cf1256
Commit
23cf1256
authored
4 years ago
by
Keane Reynolds
Browse files
Options
Downloads
Patches
Plain Diff
Uploaded Example 4 from the manual
parent
bb3bca14
No related branches found
No related tags found
4 merge requests
!6
Keane branch
,
!5
Keane branch
,
!4
Keane branch
,
!3
Keane branch
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Example04_StackBehavior_EnsureCondition.mp
+38
-0
38 additions, 0 deletions
Example04_StackBehavior_EnsureCondition.mp
with
38 additions
and
0 deletions
Example04_StackBehavior_EnsureCondition.mp
0 → 100644
+
38
−
0
View file @
23cf1256
/* Example04_StackBehavior_EnsureCondition.mp
The event trace is a set of events and the Boolean expressions
in MP can embrace the traditional predicate calculus notation. A set
of behaviors (event traces) may be defined by the event grammar rules,
composition operations, and some additional constraints – ENSURE
conditions.
Stack implements the “last in, first out” behavior for
storing/retrieving elements. It is assumed that initially Stack
is empty.
This rule specifies the behavior of a stack in terms of stack
operations push and pop. The BUILD block associated with a root or
composite event contains composition operations performed when event
trace segment representing the behavior of that root or composite is
generated. The ENSURE Boolean expression provides a condition that
each valid trace should satisfy. The domain of the universal quantifier
is the set of all pop events inside Stack. The FROM Stack part is
optional, by default it is assumed to be FROM THIS.
The function #pop BEFORE $x yields the number of pop events preceding
$x. The set of valid event traces specified by this schema contains
only traces that satisfy the constraint. This example presents a
filtering operation as yet another kind of behavior composition,
and demonstrates an example of combining imperative (event grammar)
and declarative (Boolean expressions) constructs for behavior
specification.
*/
SCHEMA Stack_behavior
ROOT Stack: (* ( push | pop ) *)
BUILD {
/* If an element is retrieved, it should have been stored before */
ENSURE FOREACH $x: pop FROM Stack
( #pop BEFORE $x < #push BEFORE $x );
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment