libsynthetic

package module
v0.0.0-...-b53e30e Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const PC_CYCLE_LIMIT = 1
View Source
const PC_REC_LIMIT = 30
View Source
const SIMREQ_JIT_DSE_MAX_ITERS = 10
View Source
const TEST_ITERATIONS = 80
View Source
const VARIABLE_PREFIX = "var_"

Variables

This section is empty.

Functions

func EvaluateAlgorithm

func EvaluateAlgorithm(
	algorithm func(Microprogram, chan struct{}),
	uprgm Microprogram,
	n_samples int,
	timeout time.Duration,
	name string,
) (
	count int,
)

func FilterModelFromZ3

func FilterModelFromZ3(model string) (filtered string)

func GetStandardItemLists

func GetStandardItemLists() (ops []Op, vals []Val)

func GetStandardItems

func GetStandardItems() (ops map[Sort][]Op, vals map[Sort][]Val)

func IndexOps

func IndexOps(ops_list []Op) (ops map[Sort][]Op)

func IndexVals

func IndexVals(vals_list []Val) (vals map[Sort][]Val)

func InvertedConstraintForMicroprogram

func InvertedConstraintForMicroprogram(orig string) (inverted_form string)

func MicroprogramConstraintToIdLiteral

func MicroprogramConstraintToIdLiteral(
	constraint_raw string, idsrc *qse.IdSource,
) (
	id_literal qse.IdLiteral[string],
)

func Pto

func Pto[T any](x T) (p *T)

func RandomPruferSequenceElement

func RandomPruferSequenceElement(n int) (elem int)

func RunEvaluationMain

func RunEvaluationMain()

func SliceToPHashMapSet

func SliceToPHashMapSet[T qse.Hashable](slice []T) (set qse.PHashMap[T, struct{}])

func SliceToSet

func SliceToSet[T comparable](slice []T) (set map[T]struct{})

func UniformAssignmentOfSMTFreeFuns

func UniformAssignmentOfSMTFreeFuns(
	smt_free_funs []qse.SMTFreeFun[string, string],
	sort_values map[string]string,
) (
	model string,
)

Types

type ConnectedOrNot

type ConnectedOrNot int
const (
	Connected ConnectedOrNot = iota
	NotConnected
)

type ConstraintGenerator

type ConstraintGenerator struct {
	P_n_depth_mean   float64
	P_n_depth_stddev float64
	P_ops            map[Sort][]Op
	P_vals           map[Sort][]Val
	NextVarId        *int
}

func (ConstraintGenerator) AddVariable

func (g ConstraintGenerator) AddVariable(sort_distr DDistr[Sort], rep int)

func (ConstraintGenerator) AddVariables

func (g ConstraintGenerator) AddVariables(n int, sort_distr DDistr[Sort], p_var float64)

func (ConstraintGenerator) Generate

func (g ConstraintGenerator) Generate(sort Sort) (expr string)

func (ConstraintGenerator) GenerateAtDepth

func (g ConstraintGenerator) GenerateAtDepth(sort Sort, depth int) (expr string)

func (ConstraintGenerator) SMTFreeFuns

func (g ConstraintGenerator) SMTFreeFuns() (smt_free_funs []qse.SMTFreeFun[string, string])

func (ConstraintGenerator) Variables

func (g ConstraintGenerator) Variables() (vars []Val)

func (ConstraintGenerator) Verify

func (g ConstraintGenerator) Verify()

type DDistr

type DDistr[T any] struct {
	// contains filtered or unexported fields
}

func BakeDDistr

func BakeDDistr[T any](formulation DDistrFormulation[T]) (d DDistr[T])

func (DDistr[T]) Sample

func (d DDistr[T]) Sample() (outcome T)

func (DDistr[T]) SampleUsing

func (d DDistr[T]) SampleUsing(random_value float64) (outcome T)

type DDistrFormulation

type DDistrFormulation[T any] interface {
	GetOutcomes() (outcomes []T)
	ProbOfOutcome(outcome T) (p float64)
}

type Microprogram

type Microprogram struct {
	StateTop    MicroprogramState
	StateFail   MicroprogramState
	Transitions map[MicroprogramState][]MicroprogramTransition
	// contains filtered or unexported fields
}

func GenerateEvaluationMicroprogram

func GenerateEvaluationMicroprogram() (uprgm Microprogram)

func (Microprogram) ExecuteGetPathCondition

func (uprgm Microprogram) ExecuteGetPathCondition(
	model string, no_transition bool,
) (
	fails bool,
	pc []string,
)

func (Microprogram) ExecuteGetPathConditionFrom

func (uprgm Microprogram) ExecuteGetPathConditionFrom(
	model string,
	state MicroprogramState,
	no_transition bool,
	rec_budget int,
	seen map[MicroprogramState]int,
) (
	fails bool,
	pc []string,
)

func (Microprogram) ModelSatisfiesConstraints

func (uprgm Microprogram) ModelSatisfiesConstraints(model string, constraints []string) (does bool)

func (Microprogram) RunDSE

func (uprgm Microprogram) RunDSE() (n_bugs int)

func (Microprogram) RunDSEContinuously

func (uprgm Microprogram) RunDSEContinuously(
	bug_signal chan uint32,
	emit_pcs bool,
	out_pcs *chan PathConditionResult,
	no_transition bool,
	max_iters int,
	top_state MicroprogramState,
)

func (Microprogram) RunSiMReQ

func (uprgm Microprogram) RunSiMReQ(bug_signal chan struct{}, jit_dse bool)

func (Microprogram) SiMReQProcessPCs

func (uprgm Microprogram) SiMReQProcessPCs(
	in_pcs chan PathConditionResult,
	bug_signal chan uint32,
	jit_dse bool,
)

func (Microprogram) SolveForInputZ3

func (uprgm Microprogram) SolveForInputZ3(
	constraints []qse.IdLiteral[string],
	idsrc *qse.IdSource,
) (
	model_ptr *string,
)

func (Microprogram) UniformAssignmentOfSMTFreeFuns

func (uprgm Microprogram) UniformAssignmentOfSMTFreeFuns(
	sort_values map[string]string,
) (
	model string,
)

func (Microprogram) UnitializedAssignment

func (uprgm Microprogram) UnitializedAssignment() (model string)

type MicroprogramGenerator

type MicroprogramGenerator struct {
	P_n_states        int
	P_p_transition    float64
	P_n_merged_graphs int
	P_p_fallible      float64
	P_n_entry_samples int
	P_n_tree_nonleaf  int
	P_constraintgen   ConstraintGenerator
	// contains filtered or unexported fields
}

func BuildEvaluationMicroprogramGenerator

func BuildEvaluationMicroprogramGenerator() (uprgm_gen MicroprogramGenerator)

func BuildTestingMicroprogramGenerator

func BuildTestingMicroprogramGenerator() (uprgm_gen MicroprogramGenerator)

func (*MicroprogramGenerator) AllocateStateIds

func (gen *MicroprogramGenerator) AllocateStateIds(n int) (start_of_allocation MicroprogramState)

func (*MicroprogramGenerator) GetNextStateId

func (gen *MicroprogramGenerator) GetNextStateId() (state MicroprogramState)

func (*MicroprogramGenerator) RandomMicroprogram

func (gen *MicroprogramGenerator) RandomMicroprogram() (uprgm Microprogram)

type MicroprogramState

type MicroprogramState int

func ParseMicroprogramState

func ParseMicroprogramState(str string) (state MicroprogramState)

func (MicroprogramState) ShiftBy

func (state MicroprogramState) ShiftBy(n int) (shifted_state MicroprogramState)

type MicroprogramTransition

type MicroprogramTransition struct {
	StateDst    MicroprogramState
	Constraints []string
}

type Op

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

type PathConditionResult

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

type PruferSequence

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

func BakePruferSequence

func BakePruferSequence(sequence []int) (ps PruferSequence)

func RandomPruferSequence

func RandomPruferSequence(n int) (ps PruferSequence)

func (PruferSequence) ToTree

func (ps PruferSequence) ToTree() (tree SimpleTree)

type SiMReQConstrainedTransition

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

type SimpleDDistr

type SimpleDDistr[T comparable] struct {
	Outcomes map[T]float64
}

func (SimpleDDistr[T]) GetOutcomes

func (d SimpleDDistr[T]) GetOutcomes() (outcomes []T)

func (SimpleDDistr[T]) ProbOfOutcome

func (d SimpleDDistr[T]) ProbOfOutcome(outcome T) (prob float64)

type SimpleEdgeDesc

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

type SimpleMicroprogramTransitionDesc

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

type SimpleQuiverAdjList

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

func ErdosRenyiGraph

func ErdosRenyiGraph(n int, p float64) (al SimpleQuiverAdjList)

Generates a G(n, p) Erdős-Rényi Graph.

func ErdosRenyiQuiver

func ErdosRenyiQuiver(n int, p float64, r int) (al SimpleQuiverAdjList)

Generates r G(n, p) Erdős-Rényi Graphs, and merges them to form a quiver.

func ErdosRenyiQuiverGivenEdges

func ErdosRenyiQuiverGivenEdges(n int, p float64, r int) (al SimpleQuiverAdjList)

See ErdosRenyiQuiver. Takes in n, p, and r

func (*SimpleQuiverAdjList) CoerceAcyclic

func (q *SimpleQuiverAdjList) CoerceAcyclic(
	src_whitelist map[int]struct{},
	dst_whitelist map[int]struct{},
)

func (SimpleQuiverAdjList) ExtractAdjListAsMap

func (sqal SimpleQuiverAdjList) ExtractAdjListAsMap(n int) (al map[int][]int)

func (*SimpleQuiverAdjList) InsertEdge

func (sqal *SimpleQuiverAdjList) InsertEdge(src int, dst int)

type SimpleTree

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

func PruferEvenFinalRandomTree

func PruferEvenFinalRandomTree(n_nonleaf int, n_leaves int) (tree SimpleTree)

func PruferRandomTree

func PruferRandomTree(n int) (tree SimpleTree)

Generate a random tree as defined by a random Prüfer Sequence

func SimpleTreeFromAdjList

func SimpleTreeFromAdjList(al map[int][]int, root int) (tree SimpleTree)

func (SimpleTree) AsMicroprogramTransitions

func (tree SimpleTree) AsMicroprogramTransitions(
	dst_states []MicroprogramState,
	constraintgen ConstraintGenerator,
) (
	transitions []MicroprogramTransition,
)

func (SimpleTree) AsMicroprogramTransitionsWithPrefix

func (tree SimpleTree) AsMicroprogramTransitionsWithPrefix(
	dst_states []MicroprogramState,
	constraintgen ConstraintGenerator,
	constraint_prefix []string,
	invertible_constraint_prefix []string,
) (
	transitions []MicroprogramTransition,
)

func (*SimpleTree) CleanUpNonNegativeSubtrees

func (tree *SimpleTree) CleanUpNonNegativeSubtrees() (destroy bool)

func (*SimpleTree) CoerceForbidDegreeOne

func (tree *SimpleTree) CoerceForbidDegreeOne()

func (*SimpleTree) CoerceToMaxDegree

func (tree *SimpleTree) CoerceToMaxDegree(n int)

func (SimpleTree) ComputeLeafCount

func (tree SimpleTree) ComputeLeafCount() (n_leaves int)

func (*SimpleTree) ComputeLeafReferences

func (tree *SimpleTree) ComputeLeafReferences() (leaf_refs []*SimpleTree)

func (SimpleTree) ComputeSize

func (tree SimpleTree) ComputeSize() (size int)

func (*SimpleTree) MaxDegree

func (tree *SimpleTree) MaxDegree() (md int)

func (*SimpleTree) RewriteLeafIds

func (tree *SimpleTree) RewriteLeafIds()

type Sort

type Sort uint8
const (
	RealSort Sort = iota
	BoolSort
)

func (Sort) String

func (sort Sort) String() (s string)

type StringSMTFreeFun

type StringSMTFreeFun struct {
	FreeFun qse.SMTFreeFun[string, string]
}

func (StringSMTFreeFun) DefinitionString

func (sff StringSMTFreeFun) DefinitionString(rhs string) (stmt string)

type Val

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

Jump to

Keyboard shortcuts

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