@e4779/pi-fabric 0.92.41-fork.6 → 0.96.4-fork.10
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/LAWS.bend +502 -0
- package/PROOF.bend +452 -0
- package/README.md +5 -1
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/dist/agents/handoff.d.ts +2 -1
- package/dist/agents/handoff.d.ts.map +1 -1
- package/dist/agents/manager.d.ts +2 -0
- package/dist/agents/manager.d.ts.map +1 -1
- package/dist/agents.js +6 -5
- package/dist/agents.js.map +1 -1
- package/dist/chunks/{chunk-3TXOQ5MG.js → chunk-3CJETB4S.js} +828 -204
- package/dist/chunks/chunk-3CJETB4S.js.map +7 -0
- package/dist/chunks/{chunk-IUCVOZRX.js → chunk-3SIXBW6A.js} +2 -2
- package/dist/chunks/chunk-4E63LJDD.js +468 -0
- package/dist/chunks/chunk-4E63LJDD.js.map +7 -0
- package/dist/chunks/{chunk-AAHHYDTO.js → chunk-4NF3S3NM.js} +1 -1
- package/dist/chunks/{chunk-AAHHYDTO.js.map → chunk-4NF3S3NM.js.map} +2 -2
- package/dist/chunks/{chunk-2SWRVIYJ.js → chunk-754HA6KO.js} +2 -2
- package/dist/chunks/{chunk-K6DHXXF5.js → chunk-B2IVWASP.js} +2 -2
- package/dist/chunks/{chunk-ZDNGXLEC.js → chunk-B4HECUJI.js} +2 -2
- package/dist/chunks/{chunk-H6DDV6E2.js → chunk-CSJSHBAT.js} +5 -5
- package/dist/chunks/{chunk-MW5VI7IW.js → chunk-D4B4CCTA.js} +2 -2
- package/dist/chunks/{chunk-EDL4JDW7.js → chunk-EBWMC3OO.js} +2 -2
- package/dist/chunks/{chunk-4NUTVNS2.js → chunk-F72MAIQY.js} +31 -368
- package/dist/chunks/chunk-F72MAIQY.js.map +7 -0
- package/dist/chunks/{chunk-W3FRE4VI.js → chunk-FDIEQEXS.js} +2 -2
- package/dist/chunks/{chunk-7A6NVHB5.js → chunk-FJSHRHOR.js} +7 -4
- package/dist/chunks/chunk-FJSHRHOR.js.map +7 -0
- package/dist/chunks/{chunk-PSNXUZMY.js → chunk-G2F2RDZI.js} +5 -47
- package/dist/chunks/chunk-G2F2RDZI.js.map +7 -0
- package/dist/chunks/{chunk-3WIGAX56.js → chunk-JCV54SSP.js} +2 -2
- package/dist/chunks/chunk-KS44WKJJ.js +51 -0
- package/dist/chunks/chunk-KS44WKJJ.js.map +7 -0
- package/dist/chunks/{chunk-3H7SDWZI.js → chunk-LNLQ2LX3.js} +22 -1
- package/dist/chunks/chunk-LNLQ2LX3.js.map +7 -0
- package/dist/chunks/{chunk-G4LADAYY.js → chunk-OINADFEF.js} +8 -3
- package/dist/chunks/chunk-OINADFEF.js.map +7 -0
- package/dist/chunks/{chunk-UQ4LTUH4.js → chunk-OUAC6O5C.js} +36 -9
- package/dist/chunks/chunk-OUAC6O5C.js.map +7 -0
- package/dist/chunks/{chunk-MQG5QKGI.js → chunk-Q5BMTL6A.js} +217 -95
- package/dist/chunks/chunk-Q5BMTL6A.js.map +7 -0
- package/dist/chunks/{chunk-IK6PPFWG.js → chunk-QFKHAAZA.js} +11 -11
- package/dist/chunks/chunk-QFKHAAZA.js.map +7 -0
- package/dist/chunks/{chunk-RTXZHKMS.js → chunk-QNMQJNXE.js} +7 -3
- package/dist/chunks/chunk-QNMQJNXE.js.map +7 -0
- package/dist/chunks/{chunk-U5FYOMG5.js → chunk-UBPFGMDQ.js} +6 -2
- package/dist/chunks/chunk-UBPFGMDQ.js.map +7 -0
- package/dist/chunks/{chunk-FLKGJPCN.js → chunk-ULQFHZJE.js} +4 -1
- package/dist/chunks/chunk-ULQFHZJE.js.map +7 -0
- package/dist/chunks/{chunk-7VAZ4N43.js → chunk-V3PIO7QL.js} +2 -2
- package/dist/chunks/{chunk-MGDLRV2R.js → chunk-VQGO4P7C.js} +2 -2
- package/dist/chunks/{chunk-XT4346N7.js → chunk-WXSELMFV.js} +9 -3
- package/dist/chunks/chunk-WXSELMFV.js.map +7 -0
- package/dist/chunks/{chunk-D5WKZONW.js → chunk-X3IRR7CV.js} +2 -2
- package/dist/chunks/{chunk-IJL3QK3J.js → chunk-Y57UHPIK.js} +1 -1
- package/dist/chunks/{chunk-IJL3QK3J.js.map → chunk-Y57UHPIK.js.map} +1 -1
- package/dist/chunks/{chunk-RKRVOBVO.js → chunk-YC3QQDZ3.js} +2 -2
- package/dist/chunks/{chunk-Q4XJ4PYL.js → chunk-ZRI433JP.js} +299 -83
- package/dist/chunks/chunk-ZRI433JP.js.map +7 -0
- package/dist/chunks/{chunk-36B4AIRT.js → chunk-ZTXZ6JDO.js} +2 -2
- package/dist/commands/fabric.d.ts.map +1 -1
- package/dist/compaction/bounds.d.ts +4 -0
- package/dist/compaction/bounds.d.ts.map +1 -1
- package/dist/compaction/branch-summary.d.ts.map +1 -1
- package/dist/compaction/dialogue.d.ts +24 -0
- package/dist/compaction/dialogue.d.ts.map +1 -0
- package/dist/compaction/hook.d.ts +6 -2
- package/dist/compaction/hook.d.ts.map +1 -1
- package/dist/compaction/hook.js +6 -5
- package/dist/compaction/instructions.d.ts +1 -0
- package/dist/compaction/instructions.d.ts.map +1 -1
- package/dist/compaction/projections.d.ts +3 -3
- package/dist/compaction/projections.d.ts.map +1 -1
- package/dist/compaction/qa.d.ts.map +1 -1
- package/dist/compaction/render.d.ts +11 -0
- package/dist/compaction/render.d.ts.map +1 -1
- package/dist/components/configuration.js +2 -3
- package/dist/components/effect-policy.d.ts +2 -0
- package/dist/components/effect-policy.d.ts.map +1 -1
- package/dist/components/effect-scope.d.ts.map +1 -1
- package/dist/components/supervisor.d.ts +1 -1
- package/dist/components/supervisor.d.ts.map +1 -1
- package/dist/core/action-registry.d.ts +14 -2
- package/dist/core/action-registry.d.ts.map +1 -1
- package/dist/core/action-registry.js +7 -5
- package/dist/core/provider-bindings.d.ts +8 -2
- package/dist/core/provider-bindings.d.ts.map +1 -1
- package/dist/core/provider-operations.d.ts +28 -0
- package/dist/core/provider-operations.d.ts.map +1 -0
- package/dist/core/provider-operations.js +201 -0
- package/dist/core/provider-operations.js.map +7 -0
- package/dist/core/shell-inbox.d.ts +13 -0
- package/dist/core/shell-inbox.d.ts.map +1 -0
- package/dist/core/shell-jobs.d.ts +51 -7
- package/dist/core/shell-jobs.d.ts.map +1 -1
- package/dist/core/shell-limits.d.ts +3 -0
- package/dist/core/shell-limits.d.ts.map +1 -0
- package/dist/core/shell-monitor.d.ts +51 -0
- package/dist/core/shell-monitor.d.ts.map +1 -0
- package/dist/entropy/index.js +8 -7
- package/dist/entropy/normal-form.d.ts.map +1 -1
- package/dist/execution-service.d.ts +1 -1
- package/dist/execution-service.d.ts.map +1 -1
- package/dist/fabric-runtime-state.d.ts +1 -1
- package/dist/fabric-runtime-state.d.ts.map +1 -1
- package/dist/fabric-runtime-state.js +1124 -325
- package/dist/fabric-runtime-state.js.map +4 -4
- package/dist/index.js +155 -44
- package/dist/index.js.map +3 -3
- package/dist/jev/observation.js +5 -3
- package/dist/jev.d.ts +0 -1
- package/dist/jev.d.ts.map +1 -1
- package/dist/jev.js +9 -13
- package/dist/memory/digest.d.ts.map +1 -1
- package/dist/memory/digest.js +2 -1
- package/dist/memory/discovery.js +6 -5
- package/dist/memory/expand-service.d.ts.map +1 -1
- package/dist/memory/file-worker.js +9 -8
- package/dist/memory/file-worker.js.map +1 -1
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/normalize.d.ts.map +1 -1
- package/dist/memory/normalize.js +5 -4
- package/dist/memory/search.js +7 -6
- package/dist/memory/worker-provider.js +10 -9
- package/dist/memory.js +9 -8
- package/dist/memory.js.map +1 -1
- package/dist/mesh/store.d.ts.map +1 -1
- package/dist/prewalk/handoff.d.ts +1 -1
- package/dist/prewalk/handoff.d.ts.map +1 -1
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +1 -1
- package/dist/providers/jev-provider.d.ts +1 -1
- package/dist/providers/jev-provider.d.ts.map +1 -1
- package/dist/providers/jev-provider.js +9 -7
- package/dist/providers/memory-provider.js +9 -8
- package/dist/providers/pi-tools-provider.d.ts.map +1 -1
- package/dist/providers/tasks-provider.d.ts +12 -0
- package/dist/providers/tasks-provider.d.ts.map +1 -0
- package/dist/residency/host.js +10 -9
- package/dist/residency/pi-entry.js +10 -9
- package/dist/residency/pi-entry.js.map +1 -1
- package/dist/runtime/core-override-guest-types.js +2 -2
- package/dist/runtime/guest-types.d.ts +1 -1
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/dist/runtime/monty-runtime.js +1 -2
- package/dist/runtime/monty-runtime.js.map +1 -1
- package/dist/runtime/typescript-kernel.js +2 -2
- package/dist/runtime-state-builtins.d.ts +1 -1
- package/dist/runtime-state-builtins.d.ts.map +1 -1
- package/dist/schema/controller.d.ts.map +1 -1
- package/dist/state/store.d.ts.map +1 -1
- package/dist/ui/controller.d.ts +1 -0
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/conversation-targets.js +2 -2
- package/dist/ui/conversation.js +7 -7
- package/dist/ui/dashboard.js +9 -9
- package/dist/ui/highlight.d.ts.map +1 -1
- package/dist/ui/languages/bend.d.ts +4 -0
- package/dist/ui/languages/bend.d.ts.map +1 -0
- package/dist/ui/languages/bend.js +73 -0
- package/dist/ui/languages/bend.js.map +7 -0
- package/dist/ui/settings.js +1 -2
- package/dist/ui/settings.js.map +1 -1
- package/dist/ui/shell-hang-keys.d.ts.map +1 -1
- package/dist/ui/shell-tasks.d.ts +22 -0
- package/dist/ui/shell-tasks.d.ts.map +1 -0
- package/dist/ui/shell-tasks.js +161 -0
- package/dist/ui/shell-tasks.js.map +7 -0
- package/dist/ui/shiki-catalog.d.ts +2 -1
- package/dist/ui/shiki-catalog.d.ts.map +1 -1
- package/dist/ui/snapshot.d.ts.map +1 -1
- package/dist/ui/types.d.ts +1 -0
- package/dist/ui/types.d.ts.map +1 -1
- package/dist/ui/widget.d.ts.map +1 -1
- package/dist/verified/authority.d.ts +17 -0
- package/dist/verified/authority.d.ts.map +1 -0
- package/dist/verified/generated/authority-kernel.d.ts +10 -0
- package/dist/verified/generated/authority-kernel.js +116 -0
- package/dist/verified/generated/kernel.d.ts +31 -0
- package/dist/verified/generated/kernel.js +351 -0
- package/dist/verified/generated/lifecycle-kernel.d.ts +7 -0
- package/dist/verified/generated/lifecycle-kernel.js +155 -0
- package/dist/verified/generated/manifest.json +54 -0
- package/dist/verified/generated/provider-kernel.d.ts +9 -0
- package/dist/verified/generated/provider-kernel.js +80 -0
- package/dist/verified/generated/storage-kernel.d.ts +11 -0
- package/dist/verified/generated/storage-kernel.js +98 -0
- package/dist/verified/memory.d.ts +11 -0
- package/dist/verified/memory.d.ts.map +1 -0
- package/dist/verified/nat.d.ts +2 -0
- package/dist/verified/nat.d.ts.map +1 -0
- package/dist/verified/policy.d.ts +37 -0
- package/dist/verified/policy.d.ts.map +1 -0
- package/dist/verified/resources.d.ts +14 -0
- package/dist/verified/resources.d.ts.map +1 -0
- package/dist/verified/storage.d.ts +32 -0
- package/dist/verified/storage.d.ts.map +1 -0
- package/dist/worker/event-projection.d.ts +6 -0
- package/dist/worker/event-projection.d.ts.map +1 -0
- package/dist/worker/event-projection.js +99 -0
- package/dist/worker/event-projection.js.map +7 -0
- package/dist/worker/recovery-watchdog.d.ts +12 -0
- package/dist/worker/recovery-watchdog.d.ts.map +1 -0
- package/dist/worker/recovery-watchdog.js +41 -0
- package/dist/worker/recovery-watchdog.js.map +7 -0
- package/dist/worker.js +80 -22
- package/dist/worker.js.map +2 -2
- package/docs/agents.md +26 -14
- package/docs/architecture.md +1 -1
- package/docs/background-tasks.md +140 -0
- package/docs/compaction.md +91 -28
- package/docs/components.md +5 -1
- package/docs/configuration.md +6 -6
- package/docs/foreman.md +4 -4
- package/docs/harnesses.md +95 -0
- package/docs/interface.md +7 -0
- package/docs/jev.md +59 -52
- package/docs/kernels.md +2 -2
- package/docs/licenses/bend-apache-2.0.txt +202 -0
- package/docs/memory-recall.md +1 -1
- package/docs/programmatic-compaction.md +13 -2
- package/docs/provider-capabilities.md +197 -0
- package/docs/shell-middleware.md +3 -3
- package/docs/skills.md +1 -1
- package/docs/verified-kernels.md +278 -0
- package/package.json +14 -4
- package/proofs/abi.json +308 -0
- package/proofs/authority-abi.json +7 -0
- package/proofs/authority-kernel.bend +23 -0
- package/proofs/authority-proof.bend +74 -0
- package/proofs/authority-spec.bend +30 -0
- package/proofs/authority-state.bend +43 -0
- package/proofs/authority-types.d.ts +3 -0
- package/proofs/kernel.bend +139 -0
- package/proofs/lifecycle-abi.json +3 -0
- package/proofs/lifecycle-kernel.bend +11 -0
- package/proofs/lifecycle-proof.bend +249 -0
- package/proofs/lifecycle-spec.bend +261 -0
- package/proofs/lifecycle-types.d.ts +4 -0
- package/proofs/lifecycle.bend +119 -0
- package/proofs/provider-abi.json +4 -0
- package/proofs/provider-kernel.bend +14 -0
- package/proofs/provider-plans.bend +28 -0
- package/proofs/provider-spec.bend +14 -0
- package/proofs/provider-types.d.ts +5 -0
- package/proofs/resource-proof.bend +633 -0
- package/proofs/resource-spec.bend +133 -0
- package/proofs/resources.bend +160 -0
- package/proofs/state-kernel.bend +17 -0
- package/proofs/state-plans.bend +40 -0
- package/proofs/state-proof.bend +42 -0
- package/proofs/state-spec.bend +26 -0
- package/proofs/storage-abi.json +3 -0
- package/proofs/storage-kernel.bend +11 -0
- package/proofs/storage-plans.bend +100 -0
- package/proofs/storage-proof.bend +176 -0
- package/proofs/storage-spec.bend +70 -0
- package/proofs/storage-types.d.ts +8 -0
- package/proofs/types.d.ts +7 -0
- package/scripts/test-verified-kernels.mjs +107 -0
- package/scripts/verified-kernels.mjs +136 -0
- package/skillsets/python/fabric-jev/SKILL.md +13 -9
- package/skillsets/typescript/fabric-exec/SKILL.md +4 -2
- package/skillsets/typescript/fabric-jev/SKILL.md +13 -9
- package/dist/chunks/chunk-3H7SDWZI.js.map +0 -7
- package/dist/chunks/chunk-3TXOQ5MG.js.map +0 -7
- package/dist/chunks/chunk-4NUTVNS2.js.map +0 -7
- package/dist/chunks/chunk-77PDIBK2.js +0 -129
- package/dist/chunks/chunk-77PDIBK2.js.map +0 -7
- package/dist/chunks/chunk-7A6NVHB5.js.map +0 -7
- package/dist/chunks/chunk-FLKGJPCN.js.map +0 -7
- package/dist/chunks/chunk-G4LADAYY.js.map +0 -7
- package/dist/chunks/chunk-IK6PPFWG.js.map +0 -7
- package/dist/chunks/chunk-MQG5QKGI.js.map +0 -7
- package/dist/chunks/chunk-PSNXUZMY.js.map +0 -7
- package/dist/chunks/chunk-Q4XJ4PYL.js.map +0 -7
- package/dist/chunks/chunk-RTXZHKMS.js.map +0 -7
- package/dist/chunks/chunk-U5FYOMG5.js.map +0 -7
- package/dist/chunks/chunk-UQ4LTUH4.js.map +0 -7
- package/dist/chunks/chunk-XT4346N7.js.map +0 -7
- package/dist/jev/browser.d.ts +0 -37
- package/dist/jev/browser.d.ts.map +0 -1
- package/dist/jev/browser.js +0 -13
- package/dist/jev/browser.js.map +0 -7
- /package/dist/chunks/{chunk-IUCVOZRX.js.map → chunk-3SIXBW6A.js.map} +0 -0
- /package/dist/chunks/{chunk-2SWRVIYJ.js.map → chunk-754HA6KO.js.map} +0 -0
- /package/dist/chunks/{chunk-K6DHXXF5.js.map → chunk-B2IVWASP.js.map} +0 -0
- /package/dist/chunks/{chunk-ZDNGXLEC.js.map → chunk-B4HECUJI.js.map} +0 -0
- /package/dist/chunks/{chunk-H6DDV6E2.js.map → chunk-CSJSHBAT.js.map} +0 -0
- /package/dist/chunks/{chunk-MW5VI7IW.js.map → chunk-D4B4CCTA.js.map} +0 -0
- /package/dist/chunks/{chunk-EDL4JDW7.js.map → chunk-EBWMC3OO.js.map} +0 -0
- /package/dist/chunks/{chunk-W3FRE4VI.js.map → chunk-FDIEQEXS.js.map} +0 -0
- /package/dist/chunks/{chunk-3WIGAX56.js.map → chunk-JCV54SSP.js.map} +0 -0
- /package/dist/chunks/{chunk-7VAZ4N43.js.map → chunk-V3PIO7QL.js.map} +0 -0
- /package/dist/chunks/{chunk-MGDLRV2R.js.map → chunk-VQGO4P7C.js.map} +0 -0
- /package/dist/chunks/{chunk-D5WKZONW.js.map → chunk-X3IRR7CV.js.map} +0 -0
- /package/dist/chunks/{chunk-RKRVOBVO.js.map → chunk-YC3QQDZ3.js.map} +0 -0
- /package/dist/chunks/{chunk-36B4AIRT.js.map → chunk-ZTXZ6JDO.js.map} +0 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type StateText = { $: "Nil" } | { $: "Con"; head: bigint; tail: StateText };
|
|
2
|
+
export interface StateGrant { $: "Grant"; active: boolean; key: StateText }
|
|
3
|
+
export type StatePlan = { $: "Denied" } | { $: "Read"; key: StateText } | { $: "Write"; key: StateText; expected: StateText; value: StateText };
|
|
4
|
+
export interface ProviderTicket { $: "Ticket"; grant: StateGrant; expected: StateText; payload: StateText }
|
|
5
|
+
export interface ProviderOutcome { $: "Outcome"; next: ProviderTicket; plan: StatePlan }
|
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
import Base
|
|
2
|
+
import ./resources.bend as R
|
|
3
|
+
import ./resource-spec.bend as S
|
|
4
|
+
|
|
5
|
+
# Helpers are proof-only; none are linked into the executable artifact.
|
|
6
|
+
def discriminate(b: Bool) -> Type:
|
|
7
|
+
match b:
|
|
8
|
+
case False{}:
|
|
9
|
+
Unit
|
|
10
|
+
case True{}:
|
|
11
|
+
Empty
|
|
12
|
+
|
|
13
|
+
def falseTrue(p: {False{} == True{} : Bool}) -> Empty:
|
|
14
|
+
%p : discriminate(_)
|
|
15
|
+
Unit{}
|
|
16
|
+
|
|
17
|
+
def orLeft(+a: Bool, +b: Bool, p: {a == True{} : Bool}) -> {a || b == True{} : Bool}:
|
|
18
|
+
match a:
|
|
19
|
+
case False{}:
|
|
20
|
+
Empty.absurd({False{} || b == True{} : Bool}, falseTrue(p))
|
|
21
|
+
case True{}:
|
|
22
|
+
{==}
|
|
23
|
+
|
|
24
|
+
def orRight(+a: Bool, +b: Bool, p: {b == True{} : Bool}) -> {a || b == True{} : Bool}:
|
|
25
|
+
match a:
|
|
26
|
+
case False{}:
|
|
27
|
+
p
|
|
28
|
+
case True{}:
|
|
29
|
+
{==}
|
|
30
|
+
|
|
31
|
+
def orCases(+a: Bool, +b: Bool, p: {a || b == True{} : Bool}) -> {a == True{} : Bool} | {b == True{} : Bool}:
|
|
32
|
+
match a:
|
|
33
|
+
case False{}:
|
|
34
|
+
Inr{p}
|
|
35
|
+
case True{}:
|
|
36
|
+
Inl{{==}}
|
|
37
|
+
|
|
38
|
+
def andCases(+a: Bool, +b: Bool, p: {a && b == True{} : Bool}) -> {a == True{} : Bool} & {b == True{} : Bool}:
|
|
39
|
+
match a:
|
|
40
|
+
case False{}:
|
|
41
|
+
Empty.absurd({False{} == True{} : Bool} & {b == True{} : Bool}, falseTrue(p))
|
|
42
|
+
case True{}:
|
|
43
|
+
({==}, p)
|
|
44
|
+
|
|
45
|
+
def andMake(+a: Bool, +b: Bool, ap: {a == True{} : Bool}, bp: {b == True{} : Bool}) -> {a && b == True{} : Bool}:
|
|
46
|
+
match a:
|
|
47
|
+
case False{}:
|
|
48
|
+
Empty.absurd({False{} && b == True{} : Bool}, falseTrue(ap))
|
|
49
|
+
case True{}:
|
|
50
|
+
bp
|
|
51
|
+
|
|
52
|
+
def natRefl(+n: Nat) -> {Nat.is_eq(n, n) == True{} : Bool}:
|
|
53
|
+
match n:
|
|
54
|
+
case 0n:
|
|
55
|
+
{==}
|
|
56
|
+
case 1n+p:
|
|
57
|
+
natRefl(p)
|
|
58
|
+
|
|
59
|
+
def natExact(+a: Nat, +b: Nat, p: {Nat.is_eq(a, b) == True{} : Bool}) -> {a == b : Nat}:
|
|
60
|
+
match a b:
|
|
61
|
+
case 0n 0n:
|
|
62
|
+
{==}
|
|
63
|
+
case 0n 1n+bp:
|
|
64
|
+
Empty.absurd({0n == 1n+bp : Nat}, falseTrue(p))
|
|
65
|
+
case 1n+ap 0n:
|
|
66
|
+
Empty.absurd({1n+ap == 0n : Nat}, falseTrue(p))
|
|
67
|
+
case 1n+ap 1n+bp:
|
|
68
|
+
%natExact(ap, bp, p) : {1n+ap == 1n+_ : Nat}
|
|
69
|
+
{==}
|
|
70
|
+
|
|
71
|
+
def second(-A: Type, -B: Type, p: A & B) -> B:
|
|
72
|
+
(a, b) = p
|
|
73
|
+
b
|
|
74
|
+
|
|
75
|
+
def andUse(-T: Type, +a: Bool, +b: Bool, p: {a && b == True{} : Bool}, k: {a == True{} : Bool} -> {b == True{} : Bool} -> T) -> T:
|
|
76
|
+
match a:
|
|
77
|
+
case False{}:
|
|
78
|
+
Empty.absurd(T, falseTrue(p))
|
|
79
|
+
case True{}:
|
|
80
|
+
k({==}, p)
|
|
81
|
+
|
|
82
|
+
def consEqual(+a: Nat, +at: +List<Nat>, +b: Nat, +bt: +List<Nat>, head: {a == b : Nat}, tail: {at == bt : +List<Nat>}) -> {a <> at == b <> bt : +List<Nat>}:
|
|
83
|
+
%tail : {a <> at == b <> _ : +List<Nat>}
|
|
84
|
+
%head : {a <> at == _ <> at : +List<Nat>}
|
|
85
|
+
{==}
|
|
86
|
+
|
|
87
|
+
def nameReflWith(+xs: +List<Nat>, +equal: Bool, p: {equal == True{} : Bool}) -> {R.nameEqual(xs, xs, equal) == True{} : Bool}:
|
|
88
|
+
match xs:
|
|
89
|
+
case Nil{}:
|
|
90
|
+
p
|
|
91
|
+
case Con{h, t}:
|
|
92
|
+
nameReflWith(t, equal && Nat.is_eq(h, h), andMake(equal, Nat.is_eq(h, h), p, natRefl(h)))
|
|
93
|
+
|
|
94
|
+
def nameRefl(+xs: +List<Nat>) -> {R.nameEqual(xs, xs, True{}) == True{} : Bool}:
|
|
95
|
+
nameReflWith(xs, True{}, {==})
|
|
96
|
+
|
|
97
|
+
def nameSoundStep(+a: Nat, +at: +List<Nat>, +b: Nat, +bt: +List<Nat>, +equal: Bool, p: {equal && Nat.is_eq(a, b) == True{} : Bool} & {at == bt : +List<Nat>}) -> {equal == True{} : Bool} & {a <> at == b <> bt : +List<Nat>}:
|
|
98
|
+
(qp, tp) = p
|
|
99
|
+
andUse({equal == True{} : Bool} & {a <> at == b <> bt : +List<Nat>}, equal, Nat.is_eq(a, b), qp, ep => hp => (ep, consEqual(a, at, b, bt, natExact(a, b, hp), tp)))
|
|
100
|
+
|
|
101
|
+
def nameSound(+xs: +List<Nat>, +ys: +List<Nat>, +equal: Bool, p: {R.nameEqual(xs, ys, equal) == True{} : Bool}) -> {equal == True{} : Bool} & {xs == ys : +List<Nat>}:
|
|
102
|
+
match xs ys:
|
|
103
|
+
case Nil{} Nil{}:
|
|
104
|
+
(p, {==})
|
|
105
|
+
case Nil{} Con{h, t}:
|
|
106
|
+
Empty.absurd({equal == True{} : Bool} & {Nil{} == h <> t : +List<Nat>}, falseTrue(p))
|
|
107
|
+
case Con{h, t} Nil{}:
|
|
108
|
+
Empty.absurd({equal == True{} : Bool} & {h <> t == Nil{} : +List<Nat>}, falseTrue(p))
|
|
109
|
+
case Con{a, at} Con{b, bt}:
|
|
110
|
+
nameSoundStep(a, at, b, bt, equal, nameSound(at, bt, equal && Nat.is_eq(a, b), p))
|
|
111
|
+
|
|
112
|
+
def nameExact(+xs: +List<Nat>, +ys: +List<Nat>, p: {R.nameEqual(xs, ys, True{}) == True{} : Bool}) -> {xs == ys : +List<Nat>}:
|
|
113
|
+
second({True{} == True{} : Bool}, {xs == ys : +List<Nat>}, nameSound(xs, ys, True{}, p))
|
|
114
|
+
|
|
115
|
+
def nameFromEq(+xs: +List<Nat>, +ys: +List<Nat>, p: {xs == ys : +List<Nat>}) -> {R.nameEqual(xs, ys, True{}) == True{} : Bool}:
|
|
116
|
+
%p : {R.nameEqual(xs, _, True{}) == True{} : Bool}
|
|
117
|
+
nameRefl(xs)
|
|
118
|
+
|
|
119
|
+
def notBoth(+b: Bool, np: {Bool.not(b) == True{} : Bool}, p: {b == True{} : Bool}) -> Empty:
|
|
120
|
+
match b:
|
|
121
|
+
case False{}:
|
|
122
|
+
falseTrue(p)
|
|
123
|
+
case True{}:
|
|
124
|
+
falseTrue(np)
|
|
125
|
+
|
|
126
|
+
def nameDifferent(+xs: +List<Nat>, +ys: +List<Nat>, p: {Bool.not(R.nameEqual(xs, ys, True{})) == True{} : Bool}) -> {xs != ys : +List<Nat>}:
|
|
127
|
+
e => notBoth(R.nameEqual(xs, ys, True{}), p, nameFromEq(xs, ys, e))
|
|
128
|
+
|
|
129
|
+
def nameInequality(+xs: +List<Nat>, +ys: +List<Nat>, +same: Bool, p: {R.nameEqual(xs, ys, True{}) == same : Bool}, neq: {xs != ys : +List<Nat>}) -> {Bool.not(same) == True{} : Bool}:
|
|
130
|
+
match same:
|
|
131
|
+
case False{}:
|
|
132
|
+
{==}
|
|
133
|
+
case True{}:
|
|
134
|
+
Empty.absurd({False{} == True{} : Bool}, neq(nameExact(xs, ys, p)))
|
|
135
|
+
|
|
136
|
+
def nameBoundSound(+xs: +List<Nat>, +limit: Nat, p: {R.nameBounded(xs, limit) == True{} : Bool}) -> S.NameAtMost(xs, limit):
|
|
137
|
+
match xs limit:
|
|
138
|
+
case Nil{} _:
|
|
139
|
+
Unit{}
|
|
140
|
+
case Con{h, t} 0n:
|
|
141
|
+
falseTrue(p)
|
|
142
|
+
case Con{h, t} 1n+l:
|
|
143
|
+
nameBoundSound(t, l, p)
|
|
144
|
+
|
|
145
|
+
def nameBoundComplete(+xs: +List<Nat>, +limit: Nat, p: S.NameAtMost(xs, limit)) -> {R.nameBounded(xs, limit) == True{} : Bool}:
|
|
146
|
+
match xs limit:
|
|
147
|
+
case Nil{} _:
|
|
148
|
+
{==}
|
|
149
|
+
case Con{h, t} 0n:
|
|
150
|
+
Empty.absurd({False{} == True{} : Bool}, p)
|
|
151
|
+
case Con{h, t} 1n+l:
|
|
152
|
+
nameBoundComplete(t, l, p)
|
|
153
|
+
|
|
154
|
+
def nameNonemptySound(+xs: +List<Nat>, p: {R.nameNonempty(xs) == True{} : Bool}) -> S.NameNonempty(xs):
|
|
155
|
+
match xs:
|
|
156
|
+
case Nil{}:
|
|
157
|
+
falseTrue(p)
|
|
158
|
+
case Con{h, t}:
|
|
159
|
+
Unit{}
|
|
160
|
+
|
|
161
|
+
def nameNonemptyComplete(+xs: +List<Nat>, p: S.NameNonempty(xs)) -> {R.nameNonempty(xs) == True{} : Bool}:
|
|
162
|
+
match xs:
|
|
163
|
+
case Nil{}:
|
|
164
|
+
Empty.absurd({False{} == True{} : Bool}, p)
|
|
165
|
+
case Con{h, t}:
|
|
166
|
+
{==}
|
|
167
|
+
|
|
168
|
+
def nameValidSound(+name: +List<Nat>, p: {R.nameValid(name) == True{} : Bool}) -> S.NameValid(name):
|
|
169
|
+
andUse(S.NameValid(name), R.nameNonempty(name), R.nameBounded(name, 256n) && Bool.not(R.nameEqual(name, [42n], True{})), p, np => rest =>
|
|
170
|
+
andUse(S.NameValid(name), R.nameBounded(name, 256n), Bool.not(R.nameEqual(name, [42n], True{})), rest, bp => sp =>
|
|
171
|
+
(nameNonemptySound(name, np), (nameBoundSound(name, 256n, bp), nameDifferent(name, [42n], sp)))))
|
|
172
|
+
|
|
173
|
+
def nameValidComplete(+name: +List<Nat>, p: S.NameValid(name)) -> {R.nameValid(name) == True{} : Bool}:
|
|
174
|
+
(np, rest) = p
|
|
175
|
+
(bp, neq) = rest
|
|
176
|
+
andMake(R.nameNonempty(name), R.nameBounded(name, 256n) && Bool.not(R.nameEqual(name, [42n], True{})), nameNonemptyComplete(name, np),
|
|
177
|
+
andMake(R.nameBounded(name, 256n), Bool.not(R.nameEqual(name, [42n], True{})), nameBoundComplete(name, 256n, bp), nameInequality(name, [42n], R.nameEqual(name, [42n], True{}), {==}, neq)))
|
|
178
|
+
|
|
179
|
+
def memberTrue(+xs: +List<+List<Nat>>, +name: +List<Nat>) -> {R.member(xs, name, True{}) == True{} : Bool}:
|
|
180
|
+
match xs:
|
|
181
|
+
case Nil{}:
|
|
182
|
+
{==}
|
|
183
|
+
case Con{h, t}:
|
|
184
|
+
memberTrue(t, name)
|
|
185
|
+
|
|
186
|
+
def memberFound(+xs: +List<+List<Nat>>, +name: +List<Nat>, +found: Bool, p: {found == True{} : Bool}) -> {R.member(xs, name, found) == True{} : Bool}:
|
|
187
|
+
match found:
|
|
188
|
+
case False{}:
|
|
189
|
+
Empty.absurd({R.member(xs, name, False{}) == True{} : Bool}, falseTrue(p))
|
|
190
|
+
case True{}:
|
|
191
|
+
memberTrue(xs, name)
|
|
192
|
+
|
|
193
|
+
def memberComplete(+xs: +List<+List<Nat>>, +name: +List<Nat>, +found: Bool, p: S.Member(name, xs)) -> {R.member(xs, name, found) == True{} : Bool}:
|
|
194
|
+
match xs:
|
|
195
|
+
case Nil{}:
|
|
196
|
+
Empty.absurd({found == True{} : Bool}, p)
|
|
197
|
+
case Con{h, t}:
|
|
198
|
+
match p:
|
|
199
|
+
case Inl{hp}:
|
|
200
|
+
%hp : {R.member(t, name, found || R.nameEqual(name, _, True{})) == True{} : Bool}
|
|
201
|
+
memberFound(t, name, found || R.nameEqual(name, name, True{}), orRight(found, R.nameEqual(name, name, True{}), nameRefl(name)))
|
|
202
|
+
case Inr{tp}:
|
|
203
|
+
memberComplete(t, name, found || R.nameEqual(name, h, True{}), tp)
|
|
204
|
+
|
|
205
|
+
def memberHeadCases(+name: +List<Nat>, +h: +List<Nat>, +t: +List<+List<Nat>>, +found: Bool, p: {found == True{} : Bool} | {R.nameEqual(name, h, True{}) == True{} : Bool}) -> {found == True{} : Bool} | S.Member(name, h <> t):
|
|
206
|
+
match p:
|
|
207
|
+
case Inl{fp}:
|
|
208
|
+
Inl{fp}
|
|
209
|
+
case Inr{hp}:
|
|
210
|
+
Inr{Inl{nameExact(name, h, hp)}}
|
|
211
|
+
|
|
212
|
+
def memberLift(+name: +List<Nat>, +h: +List<Nat>, +t: +List<+List<Nat>>, +found: Bool, p: {found || R.nameEqual(name, h, True{}) == True{} : Bool} | S.Member(name, t)) -> {found == True{} : Bool} | S.Member(name, h <> t):
|
|
213
|
+
match p:
|
|
214
|
+
case Inl{hp}:
|
|
215
|
+
memberHeadCases(name, h, t, found, orCases(found, R.nameEqual(name, h, True{}), hp))
|
|
216
|
+
case Inr{tp}:
|
|
217
|
+
Inr{Inr{tp}}
|
|
218
|
+
|
|
219
|
+
def memberSound(+xs: +List<+List<Nat>>, +name: +List<Nat>, +found: Bool, p: {R.member(xs, name, found) == True{} : Bool}) -> {found == True{} : Bool} | S.Member(name, xs):
|
|
220
|
+
match xs:
|
|
221
|
+
case Nil{}:
|
|
222
|
+
Inl{p}
|
|
223
|
+
case Con{h, t}:
|
|
224
|
+
memberLift(name, h, t, found, memberSound(t, name, found || R.nameEqual(name, h, True{}), p))
|
|
225
|
+
|
|
226
|
+
def memberNotFound(+name: +List<Nat>, +xs: +List<+List<Nat>>, p: {False{} == True{} : Bool} | S.Member(name, xs)) -> S.Member(name, xs):
|
|
227
|
+
match p:
|
|
228
|
+
case Inl{fp}:
|
|
229
|
+
Empty.absurd(S.Member(name, xs), falseTrue(fp))
|
|
230
|
+
case Inr{mp}:
|
|
231
|
+
mp
|
|
232
|
+
|
|
233
|
+
def memberEvidence(+name: +List<Nat>, +xs: +List<+List<Nat>>, p: {R.member(xs, name, False{}) == True{} : Bool}) -> S.Member(name, xs):
|
|
234
|
+
memberNotFound(name, xs, memberSound(xs, name, False{}, p))
|
|
235
|
+
|
|
236
|
+
def coveredStep(+h: +List<Nat>, +t: +List<+List<Nat>>, +ys: +List<+List<Nat>>, +good: Bool, p: {good && R.member(ys, h, False{}) == True{} : Bool} & S.Subset(t, ys)) -> {good == True{} : Bool} & S.Subset(h <> t, ys):
|
|
237
|
+
(gp, tp) = p
|
|
238
|
+
andUse({good == True{} : Bool} & S.Subset(h <> t, ys), good, R.member(ys, h, False{}), gp, gp => hp => (gp, (memberEvidence(h, ys, hp), tp)))
|
|
239
|
+
|
|
240
|
+
def coveredSound(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, +good: Bool, p: {R.covered(xs, ys, good) == True{} : Bool}) -> {good == True{} : Bool} & S.Subset(xs, ys):
|
|
241
|
+
match xs:
|
|
242
|
+
case Nil{}:
|
|
243
|
+
(p, Unit{})
|
|
244
|
+
case Con{h, t}:
|
|
245
|
+
coveredStep(h, t, ys, good, coveredSound(t, ys, good && R.member(ys, h, False{}), p))
|
|
246
|
+
|
|
247
|
+
def coverage(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, p: {R.covered(xs, ys, True{}) == True{} : Bool}) -> S.Subset(xs, ys):
|
|
248
|
+
second({True{} == True{} : Bool}, S.Subset(xs, ys), coveredSound(xs, ys, True{}, p))
|
|
249
|
+
|
|
250
|
+
def coveredComplete(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, +good: Bool, gp: {good == True{} : Bool}, p: S.Subset(xs, ys)) -> {R.covered(xs, ys, good) == True{} : Bool}:
|
|
251
|
+
match xs:
|
|
252
|
+
case Nil{}:
|
|
253
|
+
gp
|
|
254
|
+
case Con{h, t}:
|
|
255
|
+
(hp, tp) = p
|
|
256
|
+
coveredComplete(t, ys, good && R.member(ys, h, False{}), andMake(good, R.member(ys, h, False{}), gp, memberComplete(ys, h, False{}, hp)), tp)
|
|
257
|
+
|
|
258
|
+
def subsetMember(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, +name: +List<Nat>, member: S.Member(name, xs), subset: S.Subset(xs, ys)) -> S.Member(name, ys):
|
|
259
|
+
match xs:
|
|
260
|
+
case Nil{}:
|
|
261
|
+
Empty.absurd(S.Member(name, ys), member)
|
|
262
|
+
case Con{h, t}:
|
|
263
|
+
match member:
|
|
264
|
+
case Inl{e}:
|
|
265
|
+
(hp, tp) = subset
|
|
266
|
+
%Equal.sym(+List<Nat>, name, h, e) : S.Member(_, ys)
|
|
267
|
+
hp
|
|
268
|
+
case Inr{mp}:
|
|
269
|
+
(hp, tp) = subset
|
|
270
|
+
subsetMember(t, ys, name, mp, tp)
|
|
271
|
+
|
|
272
|
+
def subsetCons(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, +h: +List<Nat>, p: S.Subset(xs, ys)) -> S.Subset(xs, h <> ys):
|
|
273
|
+
match xs:
|
|
274
|
+
case Nil{}:
|
|
275
|
+
Unit{}
|
|
276
|
+
case Con{x, t}:
|
|
277
|
+
(xp, tp) = p
|
|
278
|
+
(Inr{xp}, subsetCons(t, ys, h, tp))
|
|
279
|
+
|
|
280
|
+
def subsetRefl(+xs: +List<+List<Nat>>) -> S.Subset(xs, xs):
|
|
281
|
+
match xs:
|
|
282
|
+
case Nil{}:
|
|
283
|
+
Unit{}
|
|
284
|
+
case Con{h, t}:
|
|
285
|
+
(Inl{{==}}, subsetCons(t, t, h, subsetRefl(t)))
|
|
286
|
+
|
|
287
|
+
def boundedSound(+xs: +List<+List<Nat>>, +limit: Nat, p: {R.bounded(xs, limit) == True{} : Bool}) -> S.AtMost(xs, limit):
|
|
288
|
+
match xs limit:
|
|
289
|
+
case Nil{} _:
|
|
290
|
+
Unit{}
|
|
291
|
+
case Con{h, t} 0n:
|
|
292
|
+
falseTrue(p)
|
|
293
|
+
case Con{h, t} 1n+l:
|
|
294
|
+
boundedSound(t, l, p)
|
|
295
|
+
|
|
296
|
+
def boundedComplete(+xs: +List<+List<Nat>>, +limit: Nat, p: S.AtMost(xs, limit)) -> {R.bounded(xs, limit) == True{} : Bool}:
|
|
297
|
+
match xs limit:
|
|
298
|
+
case Nil{} _:
|
|
299
|
+
{==}
|
|
300
|
+
case Con{h, t} 0n:
|
|
301
|
+
Empty.absurd({False{} == True{} : Bool}, p)
|
|
302
|
+
case Con{h, t} 1n+l:
|
|
303
|
+
boundedComplete(t, l, p)
|
|
304
|
+
|
|
305
|
+
def nonemptySound(+xs: +List<+List<Nat>>, p: {R.nonempty(xs) == True{} : Bool}) -> S.Nonempty(xs):
|
|
306
|
+
match xs:
|
|
307
|
+
case Nil{}:
|
|
308
|
+
falseTrue(p)
|
|
309
|
+
case Con{h, t}:
|
|
310
|
+
Unit{}
|
|
311
|
+
|
|
312
|
+
def nonemptyComplete(+xs: +List<+List<Nat>>, p: S.Nonempty(xs)) -> {R.nonempty(xs) == True{} : Bool}:
|
|
313
|
+
match xs:
|
|
314
|
+
case Nil{}:
|
|
315
|
+
Empty.absurd({False{} == True{} : Bool}, p)
|
|
316
|
+
case Con{h, t}:
|
|
317
|
+
{==}
|
|
318
|
+
|
|
319
|
+
def namesStep(+h: +List<Nat>, +t: +List<+List<Nat>>, +good: Bool, p: {good && R.nameValid(h) == True{} : Bool} & S.NamesValid(t)) -> {good == True{} : Bool} & S.NamesValid(h <> t):
|
|
320
|
+
(gp, tp) = p
|
|
321
|
+
andUse({good == True{} : Bool} & S.NamesValid(h <> t), good, R.nameValid(h), gp, gp => hp => (gp, (nameValidSound(h, hp), tp)))
|
|
322
|
+
|
|
323
|
+
def namesSound(+xs: +List<+List<Nat>>, +good: Bool, p: {R.namesValid(xs, good) == True{} : Bool}) -> {good == True{} : Bool} & S.NamesValid(xs):
|
|
324
|
+
match xs:
|
|
325
|
+
case Nil{}:
|
|
326
|
+
(p, Unit{})
|
|
327
|
+
case Con{h, t}:
|
|
328
|
+
namesStep(h, t, good, namesSound(t, good && R.nameValid(h), p))
|
|
329
|
+
|
|
330
|
+
def namesComplete(+xs: +List<+List<Nat>>, +good: Bool, gp: {good == True{} : Bool}, p: S.NamesValid(xs)) -> {R.namesValid(xs, good) == True{} : Bool}:
|
|
331
|
+
match xs:
|
|
332
|
+
case Nil{}:
|
|
333
|
+
gp
|
|
334
|
+
case Con{h, t}:
|
|
335
|
+
(hp, tp) = p
|
|
336
|
+
namesComplete(t, good && R.nameValid(h), andMake(good, R.nameValid(h), gp, nameValidComplete(h, hp)), tp)
|
|
337
|
+
|
|
338
|
+
def qualitySound(+xs: +List<+List<Nat>>, p: {R.quality(xs) == True{} : Bool}) -> S.Quality(xs):
|
|
339
|
+
andUse(S.Quality(xs), R.nonempty(xs), R.bounded(xs, 64n) && R.namesValid(xs, True{}), p, np => rest =>
|
|
340
|
+
andUse(S.Quality(xs), R.bounded(xs, 64n), R.namesValid(xs, True{}), rest, bp => vp =>
|
|
341
|
+
(nonemptySound(xs, np), (boundedSound(xs, 64n, bp), second({True{} == True{} : Bool}, S.NamesValid(xs), namesSound(xs, True{}, vp))))))
|
|
342
|
+
|
|
343
|
+
def qualityComplete(+xs: +List<+List<Nat>>, p: S.Quality(xs)) -> {R.quality(xs) == True{} : Bool}:
|
|
344
|
+
(np, rest) = p
|
|
345
|
+
(bp, vp) = rest
|
|
346
|
+
andMake(R.nonempty(xs), R.bounded(xs, 64n) && R.namesValid(xs, True{}), nonemptyComplete(xs, np), andMake(R.bounded(xs, 64n), R.namesValid(xs, True{}), boundedComplete(xs, 64n, bp), namesComplete(xs, True{}, {==}, vp)))
|
|
347
|
+
|
|
348
|
+
def whenQualityExact(+ok: Bool, +xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>) -> {R.whenQuality(ok, xs, ys) == ok && (R.covered(xs, ys, True{}) && R.covered(ys, xs, True{})) : Bool}:
|
|
349
|
+
match ok:
|
|
350
|
+
case False{}:
|
|
351
|
+
{==}
|
|
352
|
+
case True{}:
|
|
353
|
+
{==}
|
|
354
|
+
|
|
355
|
+
def acceptedView(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, p: {R.accepted(xs, ys) == True{} : Bool}) -> {R.quality(ys) && (R.covered(xs, ys, True{}) && R.covered(ys, xs, True{})) == True{} : Bool}:
|
|
356
|
+
%whenQualityExact(R.quality(ys), xs, ys) : {_ == True{} : Bool}
|
|
357
|
+
p
|
|
358
|
+
|
|
359
|
+
def acceptedSound(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, p: {R.accepted(xs, ys) == True{} : Bool}) -> S.Quality(ys) & (S.Subset(xs, ys) & S.Subset(ys, xs)):
|
|
360
|
+
andUse(S.Quality(ys) & (S.Subset(xs, ys) & S.Subset(ys, xs)), R.quality(ys), R.covered(xs, ys, True{}) && R.covered(ys, xs, True{}), acceptedView(xs, ys, p), qp => cp =>
|
|
361
|
+
andUse(S.Quality(ys) & (S.Subset(xs, ys) & S.Subset(ys, xs)), R.covered(xs, ys, True{}), R.covered(ys, xs, True{}), cp, fp => bp =>
|
|
362
|
+
(qualitySound(ys, qp), (coverage(xs, ys, fp), coverage(ys, xs, bp)))))
|
|
363
|
+
|
|
364
|
+
def acceptedComplete(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, quality: S.Quality(ys), forward: S.Subset(xs, ys), backward: S.Subset(ys, xs)) -> {R.accepted(xs, ys) == True{} : Bool}:
|
|
365
|
+
%Equal.sym(Bool, R.accepted(xs, ys), R.quality(ys) && (R.covered(xs, ys, True{}) && R.covered(ys, xs, True{})), whenQualityExact(R.quality(ys), xs, ys)) : {_ == True{} : Bool}
|
|
366
|
+
andMake(R.quality(ys), R.covered(xs, ys, True{}) && R.covered(ys, xs, True{}), qualityComplete(ys, quality), andMake(R.covered(xs, ys, True{}), R.covered(ys, xs, True{}), coveredComplete(xs, ys, True{}, {==}, forward), coveredComplete(ys, xs, True{}, {==}, backward)))
|
|
367
|
+
|
|
368
|
+
def sharedTail(+h: +List<Nat>, +t: +List<+List<Nat>>, +ys: +List<+List<Nat>>, p: S.Shared(t, ys)) -> S.Shared(h <> t, ys):
|
|
369
|
+
(name, both) = p
|
|
370
|
+
(lp, rp) = both
|
|
371
|
+
(name, (Inr{lp}, rp))
|
|
372
|
+
|
|
373
|
+
def overlapHead(+h: +List<Nat>, +t: +List<+List<Nat>>, +ys: +List<+List<Nat>>, +found: Bool, p: {found == True{} : Bool} | {R.member(ys, h, False{}) == True{} : Bool}) -> {found == True{} : Bool} | S.Shared(h <> t, ys):
|
|
374
|
+
match p:
|
|
375
|
+
case Inl{fp}:
|
|
376
|
+
Inl{fp}
|
|
377
|
+
case Inr{hp}:
|
|
378
|
+
Inr{(h, (Inl{{==}}, memberEvidence(h, ys, hp)))}
|
|
379
|
+
|
|
380
|
+
def overlapLift(+h: +List<Nat>, +t: +List<+List<Nat>>, +ys: +List<+List<Nat>>, +found: Bool, p: {found || R.member(ys, h, False{}) == True{} : Bool} | S.Shared(t, ys)) -> {found == True{} : Bool} | S.Shared(h <> t, ys):
|
|
381
|
+
match p:
|
|
382
|
+
case Inl{hp}:
|
|
383
|
+
overlapHead(h, t, ys, found, orCases(found, R.member(ys, h, False{}), hp))
|
|
384
|
+
case Inr{tp}:
|
|
385
|
+
Inr{sharedTail(h, t, ys, tp)}
|
|
386
|
+
|
|
387
|
+
def overlapSound(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, +found: Bool, p: {R.overlapNames(xs, ys, found) == True{} : Bool}) -> {found == True{} : Bool} | S.Shared(xs, ys):
|
|
388
|
+
match xs:
|
|
389
|
+
case Nil{}:
|
|
390
|
+
Inl{p}
|
|
391
|
+
case Con{h, t}:
|
|
392
|
+
overlapLift(h, t, ys, found, overlapSound(t, ys, found || R.member(ys, h, False{}), p))
|
|
393
|
+
|
|
394
|
+
def overlapNotFound(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, p: {False{} == True{} : Bool} | S.Shared(xs, ys)) -> S.Shared(xs, ys):
|
|
395
|
+
match p:
|
|
396
|
+
case Inl{fp}:
|
|
397
|
+
Empty.absurd(S.Shared(xs, ys), falseTrue(fp))
|
|
398
|
+
case Inr{sp}:
|
|
399
|
+
sp
|
|
400
|
+
|
|
401
|
+
def overlapTrue(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>) -> {R.overlapNames(xs, ys, True{}) == True{} : Bool}:
|
|
402
|
+
match xs:
|
|
403
|
+
case Nil{}:
|
|
404
|
+
{==}
|
|
405
|
+
case Con{h, t}:
|
|
406
|
+
overlapTrue(t, ys)
|
|
407
|
+
|
|
408
|
+
def overlapFound(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, +found: Bool, p: {found == True{} : Bool}) -> {R.overlapNames(xs, ys, found) == True{} : Bool}:
|
|
409
|
+
match found:
|
|
410
|
+
case False{}:
|
|
411
|
+
Empty.absurd({R.overlapNames(xs, ys, found) == True{} : Bool}, falseTrue(p))
|
|
412
|
+
case True{}:
|
|
413
|
+
overlapTrue(xs, ys)
|
|
414
|
+
|
|
415
|
+
def overlapMember(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, +name: +List<Nat>, +found: Bool, lp: S.Member(name, xs), rp: S.Member(name, ys)) -> {R.overlapNames(xs, ys, found) == True{} : Bool}:
|
|
416
|
+
match xs:
|
|
417
|
+
case Nil{}:
|
|
418
|
+
Empty.absurd({found == True{} : Bool}, lp)
|
|
419
|
+
case Con{h, t}:
|
|
420
|
+
match lp:
|
|
421
|
+
case Inl{e}:
|
|
422
|
+
%e : {R.overlapNames(t, ys, found || R.member(ys, _, False{})) == True{} : Bool}
|
|
423
|
+
overlapFound(t, ys, found || R.member(ys, name, False{}), orRight(found, R.member(ys, name, False{}), memberComplete(ys, name, False{}, rp)))
|
|
424
|
+
case Inr{tp}:
|
|
425
|
+
overlapMember(t, ys, name, found || R.member(ys, h, False{}), tp, rp)
|
|
426
|
+
|
|
427
|
+
def overlapComplete(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, p: S.Shared(xs, ys)) -> {R.overlapNames(xs, ys, False{}) == True{} : Bool}:
|
|
428
|
+
(name, both) = p
|
|
429
|
+
(lp, rp) = both
|
|
430
|
+
overlapMember(xs, ys, name, False{}, lp, rp)
|
|
431
|
+
|
|
432
|
+
def overlapAllSound(+left: R.Scope, +right: R.Scope, p: {R.overlap(left, right) == True{} : Bool}) -> S.Overlap(left, right):
|
|
433
|
+
match left right:
|
|
434
|
+
case R.Unknown{} _:
|
|
435
|
+
Unit{}
|
|
436
|
+
case R.Exact{xs} R.Unknown{}:
|
|
437
|
+
Unit{}
|
|
438
|
+
case R.Exact{xs} R.Exact{ys}:
|
|
439
|
+
overlapNotFound(xs, ys, overlapSound(xs, ys, False{}, p))
|
|
440
|
+
|
|
441
|
+
def overlapAllComplete(+left: R.Scope, +right: R.Scope, p: S.Overlap(left, right)) -> {R.overlap(left, right) == True{} : Bool}:
|
|
442
|
+
match left right:
|
|
443
|
+
case R.Unknown{} _:
|
|
444
|
+
{==}
|
|
445
|
+
case R.Exact{xs} R.Unknown{}:
|
|
446
|
+
{==}
|
|
447
|
+
case R.Exact{xs} R.Exact{ys}:
|
|
448
|
+
overlapComplete(xs, ys, p)
|
|
449
|
+
|
|
450
|
+
def conflictSound(+left: R.Scope, +right: R.Scope, +lo: Bool, +ro: Bool, p: {R.conflict(left, right, lo, ro) == True{} : Bool}) -> S.Conflicts(left, right, lo, ro):
|
|
451
|
+
andUse(S.Conflicts(left, right, lo, ro), lo || ro, R.overlap(left, right), p, op => sp => (orCases(lo, ro, op), overlapAllSound(left, right, sp)))
|
|
452
|
+
|
|
453
|
+
def orEvidence(+a: Bool, +b: Bool, p: {a == True{} : Bool} | {b == True{} : Bool}) -> {a || b == True{} : Bool}:
|
|
454
|
+
match p:
|
|
455
|
+
case Inl{ap}:
|
|
456
|
+
orLeft(a, b, ap)
|
|
457
|
+
case Inr{bp}:
|
|
458
|
+
orRight(a, b, bp)
|
|
459
|
+
|
|
460
|
+
def conflictComplete(+left: R.Scope, +right: R.Scope, +lo: Bool, +ro: Bool, p: S.Conflicts(left, right, lo, ro)) -> {R.conflict(left, right, lo, ro) == True{} : Bool}:
|
|
461
|
+
(op, sp) = p
|
|
462
|
+
andMake(lo || ro, R.overlap(left, right), orEvidence(lo, ro, op), overlapAllComplete(left, right, sp))
|
|
463
|
+
|
|
464
|
+
def selectedRefines(+decision: Bool, +original: +List<+List<Nat>>, +candidate: +List<+List<Nat>>, p: {R.accepted(original, candidate) == decision : Bool}) -> S.Refines(R.Exact{original}, R.select(decision, candidate)):
|
|
465
|
+
match decision:
|
|
466
|
+
case False{}:
|
|
467
|
+
Unit{}
|
|
468
|
+
case True{}:
|
|
469
|
+
second(S.Quality(candidate), S.Subset(original, candidate) & S.Subset(candidate, original), acceptedSound(original, candidate, p))
|
|
470
|
+
|
|
471
|
+
def first(-A: Type, -B: Type, p: A & B) -> A:
|
|
472
|
+
(a, b) = p
|
|
473
|
+
a
|
|
474
|
+
|
|
475
|
+
def selectedValid(+decision: Bool, +original: +List<+List<Nat>>, +candidate: +List<+List<Nat>>, p: {R.accepted(original, candidate) == decision : Bool}) -> S.OutputValid(R.select(decision, candidate)):
|
|
476
|
+
match decision:
|
|
477
|
+
case False{}:
|
|
478
|
+
Unit{}
|
|
479
|
+
case True{}:
|
|
480
|
+
first(S.Quality(candidate), S.Subset(original, candidate) & S.Subset(candidate, original), acceptedSound(original, candidate, p))
|
|
481
|
+
|
|
482
|
+
def normalizationRefinement(+original: R.Scope, +candidate: +List<+List<Nat>>) -> S.Refines(original, R.normalize(original, candidate)):
|
|
483
|
+
match original:
|
|
484
|
+
case R.Unknown{}:
|
|
485
|
+
Unit{}
|
|
486
|
+
case R.Exact{xs}:
|
|
487
|
+
selectedRefines(R.accepted(xs, candidate), xs, candidate, {==})
|
|
488
|
+
|
|
489
|
+
def normalizationValid(+original: R.Scope, +candidate: +List<+List<Nat>>) -> S.OutputValid(R.normalize(original, candidate)):
|
|
490
|
+
match original:
|
|
491
|
+
case R.Unknown{}:
|
|
492
|
+
Unit{}
|
|
493
|
+
case R.Exact{xs}:
|
|
494
|
+
selectedValid(R.accepted(xs, candidate), xs, candidate, {==})
|
|
495
|
+
|
|
496
|
+
def sharedRefines(+xs: +List<+List<Nat>>, +nx: +List<+List<Nat>>, +ys: +List<+List<Nat>>, +ny: +List<+List<Nat>>, left: S.Subset(xs, nx) & S.Subset(nx, xs), right: S.Subset(ys, ny) & S.Subset(ny, ys), p: S.Shared(xs, ys)) -> S.Shared(nx, ny):
|
|
497
|
+
(lf, lb) = left
|
|
498
|
+
(rf, rb) = right
|
|
499
|
+
(+name, both) = p
|
|
500
|
+
(lp, rp) = both
|
|
501
|
+
(name, (subsetMember(xs, nx, name, lp, lf), subsetMember(ys, ny, name, rp, rf)))
|
|
502
|
+
|
|
503
|
+
def overlapRefines(+left: R.Scope, +nl: R.Scope, +right: R.Scope, +nr: R.Scope, lp: S.Refines(left, nl), rp: S.Refines(right, nr), p: S.Overlap(left, right)) -> S.Overlap(nl, nr):
|
|
504
|
+
match left nl right nr:
|
|
505
|
+
case _ R.Unknown{} _ _:
|
|
506
|
+
Unit{}
|
|
507
|
+
case _ R.Exact{nx} _ R.Unknown{}:
|
|
508
|
+
Unit{}
|
|
509
|
+
case R.Unknown{} R.Exact{xs} _ R.Exact{ys}:
|
|
510
|
+
Empty.absurd(S.Shared(xs, ys), lp)
|
|
511
|
+
case R.Exact{xs} R.Exact{nx} R.Unknown{} R.Exact{ny}:
|
|
512
|
+
Empty.absurd(S.Shared(nx, ny), rp)
|
|
513
|
+
case R.Exact{xs} R.Exact{nx} R.Exact{ys} R.Exact{ny}:
|
|
514
|
+
sharedRefines(xs, nx, ys, ny, lp, rp, p)
|
|
515
|
+
|
|
516
|
+
def preserveEvidence(+left: R.Scope, +right: R.Scope, +lp: +List<+List<Nat>>, +rp: +List<+List<Nat>>, +lo: Bool, +ro: Bool, p: S.Conflicts(left, right, lo, ro)) -> S.Conflicts(R.normalize(left, lp), R.normalize(right, rp), lo, ro):
|
|
517
|
+
(op, sp) = p
|
|
518
|
+
(op, overlapRefines(left, R.normalize(left, lp), right, R.normalize(right, rp), normalizationRefinement(left, lp), normalizationRefinement(right, rp), sp))
|
|
519
|
+
|
|
520
|
+
def normalizePrecise(+xs: +List<+List<Nat>>, +ys: +List<+List<Nat>>, quality: S.Quality(ys), forward: S.Subset(xs, ys), backward: S.Subset(ys, xs)) -> {R.normalize(R.Exact{xs}, ys) == R.Exact{ys} : R.Scope}:
|
|
521
|
+
%Equal.sym(Bool, R.accepted(xs, ys), True{}, acceptedComplete(xs, ys, quality, forward, backward)) : {R.select(_, ys) == R.Exact{ys} : R.Scope}
|
|
522
|
+
{==}
|
|
523
|
+
|
|
524
|
+
def normalizeIdentity(+xs: +List<+List<Nat>>, quality: S.Quality(xs)) -> {R.normalize(R.Exact{xs}, xs) == R.Exact{xs} : R.Scope}:
|
|
525
|
+
normalizePrecise(xs, xs, quality, subsetRefl(xs), subsetRefl(xs))
|
|
526
|
+
|
|
527
|
+
def recheckSelected(+decision: Bool, +original: +List<+List<Nat>>, +candidate: +List<+List<Nat>>, p: {R.accepted(original, candidate) == decision : Bool}) -> {R.normalize(R.select(decision, candidate), candidate) == R.select(decision, candidate) : R.Scope}:
|
|
528
|
+
match decision:
|
|
529
|
+
case False{}:
|
|
530
|
+
{==}
|
|
531
|
+
case True{}:
|
|
532
|
+
normalizeIdentity(candidate, first(S.Quality(candidate), S.Subset(original, candidate) & S.Subset(candidate, original), acceptedSound(original, candidate, p)))
|
|
533
|
+
|
|
534
|
+
def normalizeRecheck(+original: R.Scope, +candidate: +List<+List<Nat>>) -> {R.normalize(R.normalize(original, candidate), candidate) == R.normalize(original, candidate) : R.Scope}:
|
|
535
|
+
match original:
|
|
536
|
+
case R.Unknown{}:
|
|
537
|
+
{==}
|
|
538
|
+
case R.Exact{xs}:
|
|
539
|
+
recheckSelected(R.accepted(xs, candidate), xs, candidate, {==})
|
|
540
|
+
|
|
541
|
+
def orFalse(+a: Bool) -> {a || False{} == a : Bool}:
|
|
542
|
+
match a:
|
|
543
|
+
case False{}:
|
|
544
|
+
{==}
|
|
545
|
+
case True{}:
|
|
546
|
+
{==}
|
|
547
|
+
|
|
548
|
+
def orAssoc(+a: Bool, +b: Bool, +c: Bool) -> {(a || b) || c == a || (b || c) : Bool}:
|
|
549
|
+
match a:
|
|
550
|
+
case False{}:
|
|
551
|
+
{==}
|
|
552
|
+
case True{}:
|
|
553
|
+
{==}
|
|
554
|
+
|
|
555
|
+
def againstExact(+ys: +List<R.Effect>, +left: R.Effect, +found: Bool) -> {R.against(ys, left, found) == found || S.Against(ys, left) : Bool}:
|
|
556
|
+
match ys:
|
|
557
|
+
case Nil{}:
|
|
558
|
+
Equal.sym(Bool, found || False{}, found, orFalse(found))
|
|
559
|
+
case Con{h, t}:
|
|
560
|
+
%orAssoc(found, R.pairConflict(left, h), S.Against(t, left)) : {R.against(t, left, found || R.pairConflict(left, h)) == _ : Bool}
|
|
561
|
+
againstExact(t, left, found || R.pairConflict(left, h))
|
|
562
|
+
|
|
563
|
+
def groupsExact(+xs: +List<R.Effect>, +ys: +List<R.Effect>, +found: Bool) -> {R.groups(xs, ys, found) == found || S.Groups(xs, ys) : Bool}:
|
|
564
|
+
match xs:
|
|
565
|
+
case Nil{}:
|
|
566
|
+
Equal.sym(Bool, found || False{}, found, orFalse(found))
|
|
567
|
+
case Con{h, t}:
|
|
568
|
+
%againstExact(ys, h, False{}) : {R.groups(t, ys, found || R.against(ys, h, False{})) == found || (_ || S.Groups(t, ys)) : Bool}
|
|
569
|
+
%orAssoc(found, R.against(ys, h, False{}), S.Groups(t, ys)) : {R.groups(t, ys, found || R.against(ys, h, False{})) == _ : Bool}
|
|
570
|
+
groupsExact(t, ys, found || R.against(ys, h, False{}))
|
|
571
|
+
|
|
572
|
+
def identitySound(+name: +List<Nat>, p: {R.identityValid(name) == True{} : Bool}) -> S.IdentityValid(name):
|
|
573
|
+
andUse(S.IdentityValid(name), R.nameNonempty(name), Bool.not(R.nameEqual(name, [42n], True{})), p, np => sp => (nameNonemptySound(name, np), nameDifferent(name, [42n], sp)))
|
|
574
|
+
|
|
575
|
+
def identitiesStep(+h: +List<Nat>, +t: +List<+List<Nat>>, +good: Bool, p: {good && R.identityValid(h) == True{} : Bool} & S.IdentitiesValid(t)) -> {good == True{} : Bool} & S.IdentitiesValid(h <> t):
|
|
576
|
+
(gp, tp) = p
|
|
577
|
+
andUse({good == True{} : Bool} & S.IdentitiesValid(h <> t), good, R.identityValid(h), gp, gp => hp => (gp, (identitySound(h, hp), tp)))
|
|
578
|
+
|
|
579
|
+
def identitiesSound(+xs: +List<+List<Nat>>, +good: Bool, p: {R.identitiesValid(xs, good) == True{} : Bool}) -> {good == True{} : Bool} & S.IdentitiesValid(xs):
|
|
580
|
+
match xs:
|
|
581
|
+
case Nil{}:
|
|
582
|
+
(p, Unit{})
|
|
583
|
+
case Con{h, t}:
|
|
584
|
+
identitiesStep(h, t, good, identitiesSound(t, good && R.identityValid(h), p))
|
|
585
|
+
|
|
586
|
+
def sourceValidSelected(+decision: Bool, +names: +List<+List<Nat>>, p: {R.nonempty(names) && R.identitiesValid(names, True{}) == decision : Bool}) -> S.SourceValid(R.select(decision, names)):
|
|
587
|
+
match decision:
|
|
588
|
+
case False{}:
|
|
589
|
+
Unit{}
|
|
590
|
+
case True{}:
|
|
591
|
+
andUse(S.SourceValid(R.Exact{names}), R.nonempty(names), R.identitiesValid(names, True{}), p, np => vp => (nonemptySound(names, np), second({True{} == True{} : Bool}, S.IdentitiesValid(names), identitiesSound(names, True{}, vp))))
|
|
592
|
+
|
|
593
|
+
def sourceRefinesSelected(+decision: Bool, +names: +List<+List<Nat>>) -> S.Refines(R.Exact{names}, R.select(decision, names)):
|
|
594
|
+
match decision:
|
|
595
|
+
case False{}:
|
|
596
|
+
Unit{}
|
|
597
|
+
case True{}:
|
|
598
|
+
(subsetRefl(names), subsetRefl(names))
|
|
599
|
+
|
|
600
|
+
def pairSound(+left: R.Effect, +right: R.Effect, p: {R.pairConflict(left, right) == True{} : Bool}) -> S.EffectConflicts(left, right):
|
|
601
|
+
match left right:
|
|
602
|
+
case R.Quiet{} _:
|
|
603
|
+
falseTrue(p)
|
|
604
|
+
case R.Effect{lo, ls} R.Quiet{}:
|
|
605
|
+
falseTrue(p)
|
|
606
|
+
case R.Effect{lo, ls} R.Effect{ro, rs}:
|
|
607
|
+
conflictSound(ls, rs, lo, ro, p)
|
|
608
|
+
|
|
609
|
+
def pairComplete(+left: R.Effect, +right: R.Effect, p: S.EffectConflicts(left, right)) -> {R.pairConflict(left, right) == True{} : Bool}:
|
|
610
|
+
match left right:
|
|
611
|
+
case R.Quiet{} _:
|
|
612
|
+
Empty.absurd({False{} == True{} : Bool}, p)
|
|
613
|
+
case R.Effect{lo, ls} R.Quiet{}:
|
|
614
|
+
Empty.absurd({False{} == True{} : Bool}, p)
|
|
615
|
+
case R.Effect{lo, ls} R.Effect{ro, rs}:
|
|
616
|
+
conflictComplete(ls, rs, lo, ro, p)
|
|
617
|
+
|
|
618
|
+
def identityComplete(+name: +List<Nat>, p: S.IdentityValid(name)) -> {R.identityValid(name) == True{} : Bool}:
|
|
619
|
+
(np, neq) = p
|
|
620
|
+
andMake(R.nameNonempty(name), Bool.not(R.nameEqual(name, [42n], True{})), nameNonemptyComplete(name, np), nameInequality(name, [42n], R.nameEqual(name, [42n], True{}), {==}, neq))
|
|
621
|
+
|
|
622
|
+
def identitiesComplete(+xs: +List<+List<Nat>>, +good: Bool, gp: {good == True{} : Bool}, p: S.IdentitiesValid(xs)) -> {R.identitiesValid(xs, good) == True{} : Bool}:
|
|
623
|
+
match xs:
|
|
624
|
+
case Nil{}:
|
|
625
|
+
gp
|
|
626
|
+
case Con{h, t}:
|
|
627
|
+
(hp, tp) = p
|
|
628
|
+
identitiesComplete(t, good && R.identityValid(h), andMake(good, R.identityValid(h), gp, identityComplete(h, hp)), tp)
|
|
629
|
+
|
|
630
|
+
def sourceComplete(+names: +List<+List<Nat>>, p: S.SourceValid(R.Exact{names})) -> {R.source(names) == R.Exact{names} : R.Scope}:
|
|
631
|
+
(np, vp) = p
|
|
632
|
+
%Equal.sym(Bool, R.nonempty(names) && R.identitiesValid(names, True{}), True{}, andMake(R.nonempty(names), R.identitiesValid(names, True{}), nonemptyComplete(names, np), identitiesComplete(names, True{}, {==}, vp))) : {R.select(_, names) == R.Exact{names} : R.Scope}
|
|
633
|
+
{==}
|