-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathTrait.ts
More file actions
33 lines (29 loc) · 796 Bytes
/
Trait.ts
File metadata and controls
33 lines (29 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { z } from 'zod'
import { Id as BaseId } from './Id.js'
import { type TruthValue } from './Formula.js'
import { Record, recordSchema } from './Record.js'
export const proofSchema = <Id>(id: z.ZodSchema<Id>): z.ZodSchema<Proof<Id>> =>
z.object({
theorems: z.array(id),
properties: z.array(id),
})
export type Proof<Id = BaseId> = {
theorems: Id[]
properties: Id[]
}
export const traitSchema = <Id>(id: z.ZodSchema<Id>): z.ZodSchema<Trait<Id>> =>
z.intersection(
z.object({
space: id,
property: id,
value: z.union([z.boolean(), z.literal('undecidable')]),
proof: proofSchema(id).optional(),
}),
recordSchema,
) as any
export type Trait<Id = BaseId> = Record & {
space: Id
property: Id
value: TruthValue
proof?: Proof<Id>
}