@informalsystems/quint
Version:
Core tool for the Quint specification language
90 lines (89 loc) • 2.57 kB
TypeScript
import { Either } from '@sweet-monads/either';
import { Substitutions } from './substitutions';
import { ErrorTree } from '../errorTree';
export type ComponentKind = 'read' | 'update' | 'temporal';
export interface EffectComponent {
kind: ComponentKind;
entity: Entity;
}
export interface ConcreteEffect {
kind: 'concrete';
components: EffectComponent[];
}
export interface ArrowEffect {
kind: 'arrow';
params: Effect[];
result: Effect;
}
export interface EffectVariable {
kind: 'variable';
name: string;
}
export type Effect = ConcreteEffect | ArrowEffect | EffectVariable;
export type EffectScheme = {
effect: Effect;
effectVariables: Set<string>;
entityVariables: Set<string>;
};
export interface StateVariable {
name: string;
reference: bigint;
}
export type Entity = {
kind: 'concrete';
stateVariables: StateVariable[];
} | {
kind: 'variable';
name: string;
reference?: bigint;
} | {
kind: 'union';
entities: Entity[];
};
export type Signature = (_arity: number) => EffectScheme;
/**
* Unifies two effects by matching effect types and unifying their entities.
*
* @param ea an effect to be unified
* @param eb the effect to be unified with
*
* @returns an array of substitutions that unifies both effects, when possible.
* Otherwise, an error tree with an error message and its trace.
*/
export declare function unify(ea: Effect, eb: Effect): Either<ErrorTree, Substitutions>;
/**
* Finds all names that occur in an effect
*
* @param effect the Effect to have its names found
*
* @returns the set of effect variables and the set of entity variables
*/
export declare function effectNames(effect: Effect): {
effectVariables: Set<string>;
entityVariables: Set<string>;
};
/**
* Converts an effect to an effect scheme without any quantification
*
* @param effect the effect to be converted
*
* @returns an effect scheme with that effect and no quantification
*/
export declare function toScheme(effect: Effect): EffectScheme;
/**
* Finds all entity names referred to by an entity
*
* @param entity the entity to be searched
*
* @returns a list of names
*/
export declare function entityNames(entity: Entity): string[];
/**
* Finds all state variables referred to by an entity
*
* @param entity the entity to be searched
*
* @returns a list of state entities
*/
export declare function stateVariables(entity: Entity): StateVariable[];
export declare function unifyEntities(va: Entity, vb: Entity): Either<ErrorTree, Substitutions>;