formula

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolCompatible

func BoolCompatible(b1, b2 Bool) bool

BoolCompatible checks that b1 and b2 are equal when they are both defined (not UNDEF)

func PrintQueries

func PrintQueries(queries []Query) string

Types

type Bool

type Bool int

Bool is the type of ternary Boolean values (True, False, Undef). By construction, the zero value of a Bool is UNDEF.

const (
	UNDEF Bool = 0
	FALSE Bool = 1
	TRUE  Bool = 2
)

func BoolAnd

func BoolAnd(b1, b2 Bool) Bool

func BoolIff

func BoolIff(b1, b2 Bool) Bool

func BoolNot

func BoolNot(b Bool) Bool

Negation

func BoolOr

func BoolOr(b1, b2 Bool) Bool

func FoldAnd

func FoldAnd[T any](f func(T) Bool, bs []T) Bool

FoldAnd returns the conjunction of all the values computed from bs

func FoldOr

func FoldOr[T any](f func(T) Bool, bs []T) Bool

FoldOr returns the disjunction of all the values computed from bs

func NewBool

func NewBool(b bool) Bool

func (Bool) EqualTo

func (b Bool) EqualTo(b2 bool) bool

func (Bool) If

func (b Bool) If(f func(bool))

If calls the function f with the value if the value is present.

func (Bool) IsFalse

func (b Bool) IsFalse() bool

func (Bool) IsTrue

func (b Bool) IsTrue() bool

func (Bool) PrintShort

func (b Bool) PrintShort() string

func (Bool) String

func (b Bool) String() string

func (Bool) Value

func (b Bool) Value() (bool, bool)

Value returns the Booolean value and sets ok to true if b is not UNDEF.

type BooleanConstant

type BooleanConstant bool

BooleanConstant defines a constant True or False.

func (BooleanConstant) String

func (f BooleanConstant) String() string

type Conjunction

type Conjunction []Formula

Conjunction is the conjunction of two or more formulas.

func (Conjunction) String

func (f Conjunction) String() string

type Constant

type Constant struct {
	Value []byte `xml:",innerxml"`
}

type Decoder

type Decoder struct {
	*xml.Decoder
}

A Decoder represents an XML parser reading a particular input stream that should be a valid formula file. It embeds an xml.Decoder for parsing a XML stream passed as an io.Reader. Like with xml.Decoder, the parser assumes that its input is encoded in UTF-8.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder creates a new XML parser reading from r.

func (*Decoder) Build

func (d *Decoder) Build() ([]Query, error)

type Disjunction

type Disjunction []Formula

Disjunction is the disjunction of two or more formulas.

func (Disjunction) String

func (f Disjunction) String() string

type Formula

type Formula interface {
	String() string
}

Formula is the interface that wraps the type of XML Formula.

Includes reports if one of the constant in the formula is part of the set of names

func Simplify

func Simplify(f Formula) Formula

Simplify performs basic simplifications on formulas.

type IntegerConstant

type IntegerConstant int

IntegerConstant defines an integer constant. It is an atomic integer expression.

func (IntegerConstant) String

func (f IntegerConstant) String() string

type IntegerLe

type IntegerLe struct {
	Left  Formula
	Right Formula
}

IntegerLe returns true if the value of the Left integer expression is less than or equal to the value of the Right one.

func (IntegerLe) String

func (f IntegerLe) String() string

type IsFireable

type IsFireable []string

IsFireable evaluates to true if one of the declared transition is fireable.

func (IsFireable) String

func (f IsFireable) String() string

type Negation

type Negation struct {
	Formula
}

Negation is the type of all expressions.

func (Negation) String

func (f Negation) String() string

type Places

type Places struct {
	PlList []string `xml:"place"`
}

type Property

type Property struct {
	Id string `xml:"id"`
	EF RawXML `xml:"formula>exists-path>finally,omitempty"`
	AG RawXML `xml:"formula>all-paths>globally,omitempty"`
}

Property is one of EF phi or AG phi, with phi a state formula

type PropertySet

type PropertySet struct {
	XMLName xml.Name   `xml:"property-set"`
	List    []Property `xml:"property"`
}

PropertySet is the type of set of formulas defined in a MCC XML property file. We should have a list of 16 properties included inside a `property-set` XML element.

type Query

type Query struct {
	ID             string
	IsEF           bool
	IsReachability bool
	Skip           bool    // whether we should skip evaluating this formula
	Original       Formula // formula before simplification. For debugging purpose
	Formula
}

Query is the type of reachability queries we need to check. When IsEF is true the query is (EF phi), meaning we report true if we can reach a state where phi is true. Conversely, when IsEF is false, the query is (AG phi), meaning we report false if (not phi) is reachable.

func (Query) IsTrivial

func (q Query) IsTrivial() bool

IsTrivial returns true if the query is a Boolean constant.

func (Query) String

func (p Query) String() string

type RawXML

type RawXML struct {
	InnerXML []byte `xml:",innerxml"`
}

StateFormula is a Boolean combination of atomic properties and integer expressions that we should parse explicitly.

type TokensCount

type TokensCount []string

TokensCount returns the exact number of tokens in a set of places. It is an atomic integer expression.

func (TokensCount) String

func (f TokensCount) String() string

type Transitions

type Transitions struct {
	TrList []string `xml:"transition"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL