caes

package
v0.0.0-...-958f0fa Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MPL-2.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

View Source
const DEBUG = false
View Source
const MAXRULEAPPS = 100000

maximum number of rule (scheme) applications when deriving arguments

View Source
const PREFIX = "ß"

Variables

View Source
var BasicSchemes = map[string]*Scheme{
	"linked":     &Scheme{Id: "linked", Weight: LinkedWeighingFunction},
	"convergent": &Scheme{Id: "convergent", Weight: ConvergentWeighingFunction},
	"cumulative": &Scheme{Id: "cumulative", Weight: CumulativeWeighingFunction},
	"factorized": &Scheme{Id: "factorized", Weight: FactorizedWeighingFunction},
}

Note: the names of the basic schemes are the same as the corresponding basic weighing functions.

View Source
var BasicWeighingFunctions = map[string]WeighingFunction{
	"linked":     LinkedWeighingFunction,
	"convergent": ConvergentWeighingFunction,
	"cumulative": CumulativeWeighingFunction,
	"factorized": FactorizedWeighingFunction,
}

Functions

func ConvergentWeighingFunction

func ConvergentWeighingFunction(arg *Argument, l Labelling) float64

func CumulativeWeighingFunction

func CumulativeWeighingFunction(arg *Argument, l Labelling) float64

func DefaultValidityCheck

func DefaultValidityCheck(*Argument) bool

func FactorizedWeighingFunction

func FactorizedWeighingFunction(arg *Argument, l Labelling) float64

A factorized argument, like a linked argument, has no weight unless all of its premises are labelled In. If all the premises are in, the weight of the argument depends on the number of its premises, compared to other arguments about the same issue. The greater the number of premises, relative to the other arguments, the greater the weight of the argument. See the jogging example for an illustration of its use. Can be used to simulate HYPO-style case-based reasoning.

func IsBasicScheme

func IsBasicScheme(scheme *Scheme) bool

func LinkedWeighingFunction

func LinkedWeighingFunction(arg *Argument, l Labelling) float64

func MakeSWIPrologCmd

func MakeSWIPrologCmd(f *os.File) *exec.Cmd

func SliceToMap

func SliceToMap(s []string) map[string]bool

func TheoryToRuleStore

func TheoryToRuleStore(t *Theory) *chr.RuleStore

Translate a theory into a GoCHR rulestore

Types

type ArgDesc

type ArgDesc struct {
	Scheme string   // id of the scheme
	Values []string // values instantiating the variables of the scheme
}

ArgDesc: Structure describing an argument instantiating an argument scheme. Represented in Prolog as argument(Scheme,Values)

type ArgGraph

type ArgGraph struct {
	Metadata    Metadata
	Issues      map[string]*Issue // id to *Issue
	Statements  map[string]*Statement
	Arguments   map[string]*Argument
	References  map[string]Metadata // key -> metadata
	Theory      *Theory
	Assumptions []string // atomic formulas or statement keys

	ExpectedLabeling map[string]Label // for testing
	// contains filtered or unexported fields
}

func NewArgGraph

func NewArgGraph() *ArgGraph

func (*ArgGraph) AddAssumption

func (ag *ArgGraph) AddAssumption(stmt_id string)

Add a statement id to the assumptions of an argument graph. Assumes a statement with this id has already been declared in the graph

func (ArgGraph) ApplyLabelling

func (ag ArgGraph) ApplyLabelling(l Labelling)

Apply a labelling to an argument graph by setting the label property of each statement in the graph to its label in the labelling and by setting the weight of each argument in the graph to its evaluated weight in the labeling.

func (*ArgGraph) GroundedLabelling

func (ag *ArgGraph) GroundedLabelling() Labelling

Returns the grounded labelling of an argument graph. The argument graph is not modified.

func (*ArgGraph) Inconsistent

func (ag *ArgGraph) Inconsistent() bool

An argument graph is inconsistent if more than one position of some issue has been assumed true.

func (*ArgGraph) Infer

func (ag *ArgGraph) Infer() error

Infer: Translate a theory into CHR rules and use a CHR engine to construct arguments and add them to the argument graph. Does not compute or update labels. If the theory is syntactically incorrect and thus cannot be parsed by the CHR inference engine, an error is returned and argument graph is left unchanged. If all goes well, the argument graph is updated and nil is returned.

func (*ArgGraph) InstantiateScheme

func (ag *ArgGraph) InstantiateScheme(id string, parameters []string)

type Argument

type Argument struct {
	Id          string
	Metadata    Metadata
	Scheme      *Scheme
	Parameters  []string // the values of the scheme variables, in the same order
	Premises    []Premise
	Conclusion  *Statement
	Undercutter *Statement
	Weight      float64 // for storing the evaluated weight
}

func NewArgument

func NewArgument() *Argument

func (*Argument) Applicable

func (arg *Argument) Applicable(l Labelling) bool

An argument is applicable if its Undercut property is In, or the undercutter is Out and none of the premises are Undecided. Because arguments can be cumulative, arguments with Out premises can be applicable. Out premises or In undercutters affect the weight of an argument, not its applicability. The labels of the premises are irrelevant for applicability if the undercutter is In.

func (*Argument) GetWeight

func (arg *Argument) GetWeight(l Labelling) float64

A argument has 0.0 weight if it is undercut or inapplicable. Otherwise, if a scheme has been applied, it is the weight assigned by the evaluator of the scheme. Otherwise it is the weight assigned by the default evaluator, LinkedArgument.

func (*Argument) PropertyValue

func (arg *Argument) PropertyValue(p string, l Labelling) (result terms.Term, ok bool)

func (*Argument) Undercut

func (arg *Argument) Undercut(l Labelling) Label

Returns In if the argument has been undercut, Out if the argument has no undercutter, the undercutter has no arguments, or attempts to undercut the argument it have failed, and Undecided otherwise

type ByProperties

type ByProperties struct {
	// contains filtered or unexported fields
}

for sorting arguments by property order

func (ByProperties) Len

func (s ByProperties) Len() int

Define the methods needed to make ByProperties match the sort.Interface interface.

func (ByProperties) Less

func (s ByProperties) Less(i, j int) bool

func (ByProperties) Swap

func (s ByProperties) Swap(i, j int)

type Criteria

type Criteria struct {
	HardConstraints []int                     // premise indices of hard constraints
	SoftConstraints map[string]SoftConstraint // role name to soft constraint
}

type Issue

type Issue struct {
	Id        string
	Metadata  Metadata
	Positions []*Statement
	Standard  Standard
}

func NewIssue

func NewIssue() *Issue

func (*Issue) ReadyToBeResolved

func (issue *Issue) ReadyToBeResolved(l Labelling) bool

An issue is ready to be resolved if all the arguments of all its positions are undercut or applicable

func (*Issue) Resolve

func (issue *Issue) Resolve(l Labelling)

Apply the proof standard of an issue to each of its positions and update the labelling accordingly. After resolving the issue, at most one of its positions will be In and all the others will be Out. (No position will remain Undecided.) The issue is assumed to be ready to be resolved before this method is called.

type IssueScheme

type IssueScheme []string

And IssueScheme is list atomic formulas, which may contain schema variables. Schema variables are denoted using Prolog's syntax for variables. Use "..." to indicate a variable number of positions, as in this example: {"buy(O1)", "...", "buy(On)"}

type Label

type Label int
const (
	Undecided Label = iota
	In
	Out
)

func (Label) String

func (l Label) String() string

type Labelling

type Labelling map[*Statement]Label

func NewLabelling

func NewLabelling() Labelling

type Language

type Language map[string]string

The keys of a Language map denote the predicate and its arity, using Prolog lexical conventions. The values are Go formatting strings, for displaying logical formulas in natural language. example: {"price/2": "The price of a %v is %v."}

func (Language) Apply

func (l Language) Apply(term1 terms.Term) string

Apply a language to a term to construct a string, usually to represent the term in natural language.

type Metadata

type Metadata map[string]interface{}

func NewMetadata

func NewMetadata() Metadata

type Order

type Order int
const (
	Descending Order = iota
	Ascending
)

type Premise

type Premise struct {
	Stmt *Statement
	Role string // e.g. major, minor
}

type PropertyOrder

type PropertyOrder struct {
	Property string
	Order    Order    // implicit ordering (ascending or descending)
	Values   []string // explicit ordering, highest ranked values first
}

PropertyOrder: orders the values of a property so that the highest-ranked values appear first when a sequence of values is sorted according to the order The Order field is ignored, if the order is specified explicitly, by providing an ordered slice of values

type Rulebase

type Rulebase interface {
	// Infer returns true if the goals succeed and false if they fail.
	// The list of strings returned represents the constraint store
	Infer(goals []string, max int) (bool, []string, error)
	// AddRule adds a constraint handling rule to the rulebase
	AddRule(name string, keep []string, delete []string, guard []string, body []string) error
}

A Rulebase is a set of constraint handling rules. https://en.wikipedia.org/wiki/Constraint_Handling_Rules The strings in the methods of the Rulebase interface denote terms, represented using Prolog syntax.

type SWIRulebase

type SWIRulebase struct {
	// contains filtered or unexported fields
}

func MakeSWIRulebase

func MakeSWIRulebase(l Language) *SWIRulebase

func TheoryToSWIRulebase

func TheoryToSWIRulebase(t *Theory) *SWIRulebase

Translate a theory into a SWIRulebase

func (*SWIRulebase) AddRule

func (rb *SWIRulebase) AddRule(name string, keeps []string, deletes []string, guards []string, body []string) error

func (*SWIRulebase) Infer

func (rb *SWIRulebase) Infer(goals []string, max int) (bool, []string, error)

Infer: Apply an SWIRulebase to a list of goals. The maximum amount of time alloted the SWI Prolog process depends on the maximum number of rules (schemes) which may be applied, max. Return true if the goals are successfully solved, and false if the goals fail. Return a list of the terms in the constraint store, if the goals succeeded. Returns an error if the rulebase could not be applied to the goals.

type Scheme

type Scheme struct {
	Id       string
	Metadata Metadata
	// Each parameter is a schema variable, using
	// Prolog syntax for variables, i.e. identifiers starting
	// a capital letter
	Variables   []string // declaration of schema variables
	Weight      WeighingFunction
	Roles       []string // Roles[i] is the role name of Premises[i]
	Premises    []string // list of atomic formulas
	Assumptions []string // list of atomic formulas
	Exceptions  []string // list of atomic formulas
	// Deletions and Guards are extensions for implementing
	// schemes using Constrating Handling Rules (CHR)
	Deletions []string // list of atomic formulas
	Guards    []string // list of atomic formulas
	// Note that multiple conclusions are allowed, as in CHR
	Conclusions []string // list of atomic formulas or schema variables
}

type SoftConstraint

type SoftConstraint struct {
	// Factor: relative weight of the constraint, in range of 0.00 to 1.00
	Factor float64
	// NormalizedValues: string to value in range of 0.0 to 1.0
	NormalizedValues map[string]float64
}

type Standard

type Standard int

Proof Standards

const (
	PE  Standard = iota // preponderance of the evidence
	CCE                 // clear and convincing evidence
	BRD                 // beyond reasonable doubt
)

type Statement

type Statement struct {
	Id            string // a ground atomic formula, using Prolog syntax
	Metadata      Metadata
	Text          string      // natural language
	Issue         *Issue      // nil if not at issue
	Args          []*Argument // concluding with this statement
	Label         Label       // for storing the evaluated label
	IsUndercutter bool        // true if the statement is an undercutter
}

func NewStatement

func NewStatement() *Statement

func (*Statement) Supported

func (stmt *Statement) Supported(l Labelling) bool

A statement is supported if it is the conclusion of at least one applicable argument with weight greater than 0.0.

func (*Statement) Unsupported

func (stmt *Statement) Unsupported(l Labelling) bool

A statement is unsupported if it has no arguments or all of its arguments are applicable and weigh 0.0 or less

type Theory

type Theory struct {
	Language          Language
	WeighingFunctions map[string]WeighingFunction
	ArgSchemes        []*Scheme
	IssueSchemes      map[string]*IssueScheme
	// contains filtered or unexported fields
}

func NewTheory

func NewTheory() *Theory

func (*Theory) InitSchemeIndex

func (t *Theory) InitSchemeIndex()

type WeighingFunction

type WeighingFunction func(*Argument, Labelling) float64 // [0.0,1.0]

func ConstantWeighingFunction

func ConstantWeighingFunction(w float64) WeighingFunction

The constant weight function is derived from and generalizes the linked weighing function. Like the linked weighing function, if any of the premises is Out, the weight is 0.0. If all of the premises are In, the weight of the argument is the constant weight assigned by to the scheme. Whereas the linked weighing function always assigns the weight 1.0 if all the premises are In, the constant weighing function is more flexible and allows some other weight to be assigned when all the premises are In.

func CriteriaWeighingFunction

func CriteriaWeighingFunction(cs *Criteria) WeighingFunction

func PreferenceWeighingFunction

func PreferenceWeighingFunction(o []PropertyOrder) WeighingFunction

PreferenceWeighingFunction: Orders arguments by the metadata properties of the schemes instantiated by the arguments. Can be used to model, e.g., Lex Superior and Lex Posterior. Can also be used to simulate value-based argumentation frameworks, using value properties and an ordering of values. If any premise of the argument is Out, the argument weights 0.0. If no premise is Out but the conclusion of the argument is not at issue, the argument weights 1.0. Otherwise all the arguments are the issue are ordered according to given PropertyOrder and assigned weights which respect this order. To do: Considering caching weights to improve efficiency, since currently the arguments are sorted multiple times, once for each argument being weighed. Problem: avoiding a memory leak when used the cache in a long running service

Directories

Path Synopsis
encoding
aif
caf
dot
Visualizing CAES AG using [Dot](http://www.graphviz.org/Documentation.php)
Visualizing CAES AG using [Dot](http://www.graphviz.org/Documentation.php)
graphml
Visualizing CAES AG using [GraphML](http://graphml.graphdrawing.org/)
Visualizing CAES AG using [GraphML](http://graphml.graphdrawing.org/)

Jump to

Keyboard shortcuts

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