Skip to content

Commit

Permalink
Adding Base OVM interfaces defining the core components (#355)
Browse files Browse the repository at this point in the history
Adding Base OVM interfaces defining the core components
  • Loading branch information
willmeister committed Jul 23, 2019
1 parent 95e5ab9 commit bc4c0c6
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
51 changes: 51 additions & 0 deletions packages/core/src/types/ovm/decider.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
export interface ProofElement {
property: Property
witness: {}
}

export type Proof = ProofElement[]

export interface Property {
decider: Decider
input: {}
}

export type PropertyFactory = (input: any) => Property

export interface ImplicationProofElement {
implication: Property
implicationWitness: any
}

export interface Decision {
outcome: boolean
implicationProof: ImplicationProofElement[] // constructed such that claim[N] --> claim[N-1] --> claim[N-2]... Claim[0]
}

export const UNDECIDED = undefined
export type Undecided = undefined
export type DecisionStatus = boolean | Undecided

/**
* Defines the Decider interface that implementations capable of making decisions
* on the provided input according to the logic of the specific implementation.
*
* For example: A PreimageExistsDecider would be able to make decisions on whether
* or not the provided _witness, when hashed, results in the provided _input.
*/
export interface Decider {
/**
* Makes a Decision on the provided input
* @param _input
* @param _witness
*/
decide(_input: any, _witness: any): Decision

/**
* Checks whether or not a decision has been made for the provided Input
* Note: This should access a cache decisions that have been made
* @param _input
* @returns the DecisionStatus, indicating if one was made.
*/
checkDecision(_input: any): DecisionStatus
}
21 changes: 21 additions & 0 deletions packages/core/src/types/ovm/quantifier.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export interface QuantifierResult {
results: any[]
allResultsQuantified: boolean
}

/**
* Interface defining the contract for all Quantifiers. Quantifiers return a collection of
* results that pass their logic.
*
* For example: A LessThanQuantifier would return all numbers less than the provided input.
* PositiveIntegerLessThanQuantifier.getAllQuantified(5) => [1,2,3,4]
*/
export interface Quantifier {
/**
* Gets all of the results that meet the criteria of the quantifier logic and provided parameters.
*
* @param parameters the input indicating how the results will be quantified
* @returns the QuantifierResult with results and our level of knowledge of the results.
*/
getAllQuantified(parameters: any): QuantifierResult
}

0 comments on commit bc4c0c6

Please sign in to comment.