Documentation ¶
Overview ¶
Copyright 2023. Silvano DAL ZILIO (LAAS-CNRS). All rights reserved. Use of this source code is governed by the GNU Affero license that can be found in the LICENSE file.
Index ¶
- func AtomIsLess(ai, aj Atom) bool
- func ValueIsLess(vi, vj *Value) bool
- type Add
- type All
- type Arc
- type Atom
- type Constant
- type Declaration
- type Decoder
- type Dot
- type Env
- type Expression
- type FIRConstant
- type FIRangeConstant
- type Fec
- type Hue
- type IntRange
- type Marking
- type Net
- type NumberConstant
- type Numberof
- type OP
- type Operation
- type Page
- type Partition
- type PartitionDecl
- type Place
- type RawXML
- type Subtract
- type Successor
- type TYP
- type Transition
- type Tuple
- type Type
- type TypeDecl
- type VEnv
- type Value
- type Var
- type VarDecl
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtomIsLess ¶
AtomIsLess will sort all the Atom with multiplicity 0 first; otherwise the order is based on Value.
func ValueIsLess ¶
ValueIsLess reports if vi is before vj in comparaison order.
Types ¶
type All ¶
type All string
All is the type of all expressions.
func (All) Unify ¶
This is one of the rare cases where we need to match against several values and not just one. It is observed on transition Initialize of PhilosophersDyn and on model QuasiCertifProtocol. We could return a negative number in order to test for this particular case but the model has other problems.
type Arc ¶
type Arc struct { Source string `xml:"source,attr"` Target string `xml:"target,attr"` XML RawXML `xml:"hlinscription>structure"` Pattern Expression }
Arc is the type of edges element in a PNML net.
type Declaration ¶
type Declaration struct { Sorts []*TypeDecl `xml:"namedsort"` Vars []*VarDecl `xml:"variabledecl"` Partitions []*PartitionDecl `xml:"partition"` }
Declaration is the type of a PNML net declaration. It contains declarations for types and variables used in the net. We also added partitions (and partitionelement) from model VehicularWifi
type Decoder ¶
A Decoder represents an XML parser reading a particular input stream that should be a valid PNML file. It embeds an xml.Decoder for parsing a PNML stream passed as an io.Reader. Like with xml.Decoder, the parser assumes that its input is encoded in UTF-8.
func NewDecoder ¶
NewDecoder creates a new XML parser reading from r.
type Env ¶
type Env []string
Env is an environment, that is a sorted list of variable (names) occuring in an Expressions.
type Expression ¶
type Expression interface { String() string AddEnv(Env) Env Eval(*Net, VEnv) []Atom Unify(*Net, *Value, VEnv) (int, error) }
Expression is the interface that wraps the type of PNML expression (we only consider symmetric nets).
We assume that Add-expressions (like a + b) are always top-level and that <subtract> expressions cannot occur in the condition of an input arc.
AddEnv is used to accumulate the free variables in the Expression to an existing environment. It can be used to add the free variables of an expression to an alreay existing environment. It creates a (sorted) slice containing the names of all the variables.
Eval returns the set of constant values that match a ground Expression (an expression without free variables, such as the ones used to define the initial marking), together with their multiplicities.
Unify reports if a pattern expression matches a given *Value. For this we can use the VEnv to check that we respect previously unified variables. We can also update the VEnv by adding new associations. A return value of 0 means no match; otherwise it is the number of "copies" of the value that we need to match. Unify can change the values in the VEnv even if it fails. Unification can fail, for instance if there is an <All> expression in one of the input arc.
func SplitAdds ¶
func SplitAdds(e Expression) []Expression
SplitAdds takes an expression and splits the top-level Add operator, if any.
type FIRConstant ¶
type FIRConstant struct {
// contains filtered or unexported fields
}
FIRConstant is the type of finite int range constant expressions.
func (FIRConstant) AddEnv ¶
func (p FIRConstant) AddEnv(env Env) Env
func (FIRConstant) String ¶
func (p FIRConstant) String() string
type FIRangeConstant ¶
FIRangeConstant is used in PNML expressions.
type Fec ¶
type Fec struct {
ID string `xml:"id,attr"`
}
Fec is the type of PNML enumeration constants.
type Hue ¶
type Hue []Atom
Hue is a slice of Atoms meant to represent the possible value in a colored place
type Net ¶
type Net struct { Name string `xml:"name>text"` Page Page `xml:"page"` Declaration Declaration `xml:"declaration>structure>declarations"` // TypeEnvt is an association between a variable name and its type name, found in declaration TypeEnvt map[string]string // Unique associates a Unique representant for each Value Unique map[Value]*Value // World associates a type (name) with a list of all its possible values World map[string][]*Value // contains filtered or unexported fields }
Net is the type of the net element in a PNML file.
func (*Net) Next ¶
Next gives the ith successor (i can be negative) of the constant with id name. We assume that the type of val is circular and do not check the particular case where we should report overflows.
func (*Net) PrintValue ¶
PrintValue returns a readable description of a Value
type NumberConstant ¶
type NumberConstant struct {
Value int `xml:"value,attr"`
}
NumberConstant is used in PNML expressions.
type Numberof ¶
type Numberof struct { Expression Mult int }
Numberof is the type of numberof expressions in PNML. This is used to add a multiplicity Mult to an Expression in a multiset.
type Operation ¶
type Operation struct { Op OP Elem []Expression }
Operation is the type of expressions that apply an operation to a slice of expressions.
type Page ¶
type Page struct { Places []*Place `xml:"place"` Trans []*Transition `xml:"transition"` Arcs []*Arc `xml:"arc"` }
Page is the type of the page element in a PNML file.
type PartitionDecl ¶
type PartitionDecl struct { ID string `xml:"id,attr"` Type `xml:"usersort,omitempty"` Partitions []Partition `xml:"partitionelement,omitempty"` }
PartitionDecl is the type of PNML partition declarations.
type Place ¶
type Place struct { ID string `xml:"id,attr"` Type Type `xml:"type>structure>usersort"` XML RawXML `xml:"hlinitialMarking>structure"` InitialMarking Expression }
Place is the type of a PNML place. It can contain a type and an (optional) initial marking.
type RawXML ¶
type RawXML struct {
InnerXML []byte `xml:",innerxml"`
}
RawXML is the type of PNML initial marking expressions, patterns and conditions.
type Subtract ¶
type Subtract []Expression
Subtract is the type of subtract expressions. It is an array of two expressions denoting the left and right elements of a subtract operation.
type Transition ¶
type Transition struct { ID string `xml:"id,attr"` XML RawXML `xml:"condition>structure"` Condition Operation }
Transition is the type of a PNML transition. It can contain a type and an (optional) initial marking.
type Type ¶
type Type struct {
ID string `xml:"declaration,attr"`
}
Type is the type of a type declaration.
type TypeDecl ¶
type TypeDecl struct { Sort TYP Elem []string ID string `xml:"id,attr"` CEnum []Fec `xml:"cyclicenumeration>feconstant,omitempty"` FEnum []Fec `xml:"finiteenumeration>feconstant,omitempty"` FIntRan *IntRange `xml:"finiteintrange,omitempty"` Product []Type `xml:"productsort>usersort,omitempty"` Dot *struct{} `xml:"dot,omitempty"` }
TypeDecl is the type of PNML type declarations. We use a pointer field for Dot in order to discriminate to differentiate between default value and field initialized. Same with finite int range.
type Value ¶
Value provides a more efficient representation for values
{0 nil} is a Dot {i nil} is Constant(name) where i uniquely identifies name {i {j {...}}} is for tuples we encode a range value, x, using a constant named _intx