pud.dev 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +143 -2
- package/THIRD-PARTY-NOTICES +112 -0
- package/chunk-224av1ab.js +10 -0
- package/chunk-fstxscck.js +3 -0
- package/chunk-h90k6v7w.js +3 -0
- package/chunk-k7a83qqm.js +3 -0
- package/cli.js +37 -0
- package/index.js +2 -0
- package/lean/index.js +880 -0
- package/package.json +32 -3
- package/project-runner.js +2 -0
- package/types/assistant.d.ts +200 -0
- package/types/check.d.ts +55 -0
- package/types/expressions.d.ts +47 -0
- package/types/index.d.ts +4 -0
- package/types/input-scope.d.ts +4 -0
- package/types/lean/command.d.ts +14 -0
- package/types/lean/index.d.ts +5 -0
- package/types/lean/number.d.ts +4 -0
- package/types/lean/program.d.ts +26 -0
- package/types/lean/replay-predicate.d.ts +5 -0
- package/types/lean/replay.d.ts +6 -0
- package/types/lean/scalar.d.ts +23 -0
- package/types/lean/subject.d.ts +25 -0
- package/types/lean/syntax.d.ts +42 -0
- package/types/module.d.ts +9 -0
- package/types/prover-process.d.ts +7 -0
- package/types/run.d.ts +30 -0
- package/types/source.d.ts +5 -0
- package/types/suite-authoring.d.ts +117 -0
- package/types/suite-check.d.ts +10 -0
- package/types/suite.d.ts +44 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { ProofAssistant, ProofErrorKind } from "./assistant.ts";
|
|
2
|
+
type Value = bigint | number | boolean | string | readonly unknown[];
|
|
3
|
+
type Subject = (...args: never[]) => Value;
|
|
4
|
+
declare const valueType: unique symbol;
|
|
5
|
+
declare const assistantType: unique symbol;
|
|
6
|
+
declare const nativeType: unique symbol;
|
|
7
|
+
declare const propositionType: unique symbol;
|
|
8
|
+
export interface Proposition {
|
|
9
|
+
readonly [propositionType]: true;
|
|
10
|
+
}
|
|
11
|
+
type Predicate = boolean | Proposition;
|
|
12
|
+
export interface Schema<T, Id extends string = never> {
|
|
13
|
+
readonly [valueType]: T;
|
|
14
|
+
readonly [assistantType]: Id;
|
|
15
|
+
refine(predicate: (value: T) => Predicate): this;
|
|
16
|
+
}
|
|
17
|
+
export interface NativeTerm<Id extends string> {
|
|
18
|
+
readonly [nativeType]: {
|
|
19
|
+
kind: "term";
|
|
20
|
+
id: (id: Id) => Id;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface NativeModule<Id extends string> {
|
|
24
|
+
readonly [nativeType]: {
|
|
25
|
+
kind: "module";
|
|
26
|
+
id: (id: Id) => Id;
|
|
27
|
+
};
|
|
28
|
+
readonly path: string;
|
|
29
|
+
}
|
|
30
|
+
export interface NativeSyntax<Id extends string> {
|
|
31
|
+
(parts: TemplateStringsArray, ...args: Value[]): NativeTerm<Id>;
|
|
32
|
+
ref(name: string, ...args: Value[]): NativeTerm<Id>;
|
|
33
|
+
module(path: string): NativeModule<Id>;
|
|
34
|
+
}
|
|
35
|
+
interface NumericSchema<T extends bigint | number, Id extends string> extends Schema<T, Id> {
|
|
36
|
+
eq(value: T): this;
|
|
37
|
+
gt(value: T): this;
|
|
38
|
+
gte(value: T): this;
|
|
39
|
+
lt(value: T): this;
|
|
40
|
+
lte(value: T): this;
|
|
41
|
+
satisfies(term: NativeTerm<Id>): this;
|
|
42
|
+
}
|
|
43
|
+
interface NumberSchema<Id extends string> extends NumericSchema<number, Id> {
|
|
44
|
+
/** ECMAScript SameValue, including NaN and the sign of zero. */
|
|
45
|
+
sameValue(value: number): this;
|
|
46
|
+
/** Nearest whole number, with explicit half ties. Preserve NaN, infinities and the sign of a zero result. */
|
|
47
|
+
nearestIntegerTo(value: number, options: {
|
|
48
|
+
ties: "up" | "down";
|
|
49
|
+
}): this;
|
|
50
|
+
}
|
|
51
|
+
interface BooleanSchema<Id extends string> extends Schema<boolean, Id> {
|
|
52
|
+
eq(value: boolean): BooleanSchema<Id>;
|
|
53
|
+
satisfies(term: NativeTerm<Id>): BooleanSchema<Id>;
|
|
54
|
+
}
|
|
55
|
+
interface ArraySchema<T, Id extends string> extends Schema<readonly T[], Id> {
|
|
56
|
+
satisfies(term: NativeTerm<Id>): ArraySchema<T, Id>;
|
|
57
|
+
}
|
|
58
|
+
interface SchemaBuilders<Id extends string> {
|
|
59
|
+
bigint(): NumericSchema<bigint, Id>;
|
|
60
|
+
number(): NumberSchema<Id>;
|
|
61
|
+
boolean(): BooleanSchema<Id>;
|
|
62
|
+
int(): NumericSchema<bigint, Id>;
|
|
63
|
+
bool(): BooleanSchema<Id>;
|
|
64
|
+
opaque<T>(): Schema<T, Id>;
|
|
65
|
+
array<T>(items: Schema<T, Id>): ArraySchema<T, Id>;
|
|
66
|
+
textOrArray<T>(items: Schema<T, Id>): Schema<string | readonly T[], Id>;
|
|
67
|
+
forall<T extends bigint | number | boolean>(domain: Schema<T, Id> | readonly T[], predicate: (value: T) => Predicate): Proposition;
|
|
68
|
+
exists<T extends bigint | number | boolean>(domain: Schema<T, Id> | readonly T[], predicate: (value: T) => Predicate): Proposition;
|
|
69
|
+
and(left: Predicate, right: Predicate): Proposition;
|
|
70
|
+
or(left: Predicate, right: Predicate): Proposition;
|
|
71
|
+
not(operand: Predicate): Proposition;
|
|
72
|
+
implies(assumption: Predicate, conclusion: Predicate): Proposition;
|
|
73
|
+
iff(left: Predicate, right: Predicate): Proposition;
|
|
74
|
+
length(items: readonly unknown[]): bigint;
|
|
75
|
+
sum(items: readonly bigint[]): bigint;
|
|
76
|
+
modulo(value: bigint, divisor: bigint): bigint;
|
|
77
|
+
quotient(value: bigint, divisor: bigint): bigint;
|
|
78
|
+
}
|
|
79
|
+
interface SuiteAuthoring<Id extends string> {
|
|
80
|
+
pud: SchemaBuilders<Id>;
|
|
81
|
+
it: {
|
|
82
|
+
<D extends Record<string, Schema<Value, Id>>>(name: string, inputs: D, property: (args: {
|
|
83
|
+
[K in keyof D]: D[K][typeof valueType];
|
|
84
|
+
}) => void): {
|
|
85
|
+
by(proof: NativeTerm<Id>): void;
|
|
86
|
+
};
|
|
87
|
+
todo(name: string): void;
|
|
88
|
+
};
|
|
89
|
+
given(condition: Predicate): void;
|
|
90
|
+
expect: {
|
|
91
|
+
<T extends Value>(value: T): {
|
|
92
|
+
to(schema: Schema<NoInfer<T>, Id>): void;
|
|
93
|
+
/** Prove that the schema accepts precisely the observed scalar result for each admitted input. */
|
|
94
|
+
toExactly(schema: [T] extends [number | bigint | boolean] ? Schema<NoInfer<T>, Id> : never): void;
|
|
95
|
+
toEqual(reference: NoInfer<T> & (bigint | number | boolean)): void;
|
|
96
|
+
};
|
|
97
|
+
(call: () => Value): {
|
|
98
|
+
toThrow(error: ProofErrorKind): void;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
use(module: NativeModule<Id>): void;
|
|
102
|
+
}
|
|
103
|
+
export interface PudConfig<Id extends string = string> extends SchemaBuilders<Id> {
|
|
104
|
+
adapter: ProofAssistant<Id>;
|
|
105
|
+
describe(subject: Subject, suite: (helpers: SuiteAuthoring<Id>) => void): void;
|
|
106
|
+
}
|
|
107
|
+
export declare const pud: SchemaBuilders<never>;
|
|
108
|
+
export declare const it: SuiteAuthoring<never>["it"];
|
|
109
|
+
export declare const given: SuiteAuthoring<never>["given"];
|
|
110
|
+
export declare const expect: SuiteAuthoring<never>["expect"];
|
|
111
|
+
export declare const describe: (subject: Subject, suite: () => void) => void;
|
|
112
|
+
/** A static tag for an adapter's native proof text. */
|
|
113
|
+
export declare function native<const Id extends string>(_id: Id): NativeSyntax<Id>;
|
|
114
|
+
export declare function defineConfig<const Id extends string>(config: {
|
|
115
|
+
adapter: ProofAssistant<Id>;
|
|
116
|
+
}): PudConfig<Id>;
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CheckOptions, CheckResult, EmitOptions, ItemProgress } from "./check.ts";
|
|
2
|
+
import { type Suite } from "./suite.ts";
|
|
3
|
+
type Read = (file: string) => {
|
|
4
|
+
canonical: string;
|
|
5
|
+
source: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function findConfig(file: string): string | undefined;
|
|
8
|
+
export declare function checkSuite(suite: Suite, config: string | undefined, options: CheckOptions, read: Read, report?: ItemProgress): Promise<CheckResult[]>;
|
|
9
|
+
export declare function emitSuite(suite: Suite, config: string | undefined, options: EmitOptions, read: Read): Promise<string>;
|
|
10
|
+
export {};
|
package/types/suite.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CallExpression, Node, Program } from "@babel/types";
|
|
2
|
+
import type { PreparedProofAssistant, ProofClaim } from "./assistant.ts";
|
|
3
|
+
type SuiteProperty = {
|
|
4
|
+
name: string;
|
|
5
|
+
line: number;
|
|
6
|
+
} & ({
|
|
7
|
+
kind: "todo";
|
|
8
|
+
} | {
|
|
9
|
+
kind: "claim";
|
|
10
|
+
call: CallExpression;
|
|
11
|
+
proof?: Node;
|
|
12
|
+
});
|
|
13
|
+
export interface Suite {
|
|
14
|
+
file: string;
|
|
15
|
+
source: string;
|
|
16
|
+
subject: {
|
|
17
|
+
file: string;
|
|
18
|
+
name: string;
|
|
19
|
+
};
|
|
20
|
+
subjects: ReadonlyMap<string, {
|
|
21
|
+
file: string;
|
|
22
|
+
name: string;
|
|
23
|
+
}>;
|
|
24
|
+
binding: string;
|
|
25
|
+
properties: SuiteProperty[];
|
|
26
|
+
modules: {
|
|
27
|
+
assistant: string;
|
|
28
|
+
file: string;
|
|
29
|
+
}[];
|
|
30
|
+
helpers: ReadonlyMap<string, string>;
|
|
31
|
+
schemaBindings: ReadonlySet<string>;
|
|
32
|
+
native: ReadonlyMap<string, string>;
|
|
33
|
+
configured: boolean;
|
|
34
|
+
numberGlobal: boolean;
|
|
35
|
+
imports: {
|
|
36
|
+
path: string;
|
|
37
|
+
resolveAgain: () => string;
|
|
38
|
+
}[];
|
|
39
|
+
}
|
|
40
|
+
export declare function readSuite(file: string, origin: string, source: string, program: Program, config?: string): Suite;
|
|
41
|
+
export declare function bindClaim(suite: Suite, property: Extract<SuiteProperty, {
|
|
42
|
+
kind: "claim";
|
|
43
|
+
}>, subject: PreparedProofAssistant): ProofClaim;
|
|
44
|
+
export {};
|