Documentation ¶
Index ¶
- Constants
- Variables
- func ConvergentWeighingFunction(arg *Argument, l Labelling) float64
- func CumulativeWeighingFunction(arg *Argument, l Labelling) float64
- func DefaultValidityCheck(*Argument) bool
- func FactorizedWeighingFunction(arg *Argument, l Labelling) float64
- func IsBasicScheme(scheme *Scheme) bool
- func LinkedWeighingFunction(arg *Argument, l Labelling) float64
- func MakeSWIPrologCmd(f *os.File) *exec.Cmd
- func SliceToMap(s []string) map[string]bool
- func TheoryToRuleStore(t *Theory) *chr.RuleStore
- type ArgDesc
- type ArgGraph
- type Argument
- type ByProperties
- type Criteria
- type Issue
- type IssueScheme
- type Label
- type Labelling
- type Language
- type Metadata
- type Order
- type Premise
- type PropertyOrder
- type Rulebase
- type SWIRulebase
- type Scheme
- type SoftConstraint
- type Standard
- type Statement
- type Theory
- type WeighingFunction
Constants ¶
const DEBUG = false
const MAXRULEAPPS = 100000
maximum number of rule (scheme) applications when deriving arguments
const PREFIX = "ß"
Variables ¶
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.
var BasicWeighingFunctions = map[string]WeighingFunction{ "linked": LinkedWeighingFunction, "convergent": ConvergentWeighingFunction, "cumulative": CumulativeWeighingFunction, "factorized": FactorizedWeighingFunction, }
Functions ¶
func DefaultValidityCheck ¶
func FactorizedWeighingFunction ¶
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 LinkedWeighingFunction ¶
func SliceToMap ¶
func TheoryToRuleStore ¶
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 ¶
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 ¶
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 ¶
Returns the grounded labelling of an argument graph. The argument graph is not modified.
func (*ArgGraph) Inconsistent ¶
An argument graph is inconsistent if more than one position of some issue has been assumed true.
func (*ArgGraph) Infer ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (*Issue) ReadyToBeResolved ¶
An issue is ready to be resolved if all the arguments of all its positions are undercut or applicable
func (*Issue) Resolve ¶
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 Labelling ¶
func NewLabelling ¶
func NewLabelling() Labelling
type Language ¶
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."}
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) Infer ¶
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 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 ¶
A statement is supported if it is the conclusion of at least one applicable argument with weight greater than 0.0.
func (*Statement) Unsupported ¶
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 (*Theory) InitSchemeIndex ¶
func (t *Theory) InitSchemeIndex()
type WeighingFunction ¶
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
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
encoding
|
|
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/) |