Skip to content

Commit 7342734

Browse files
ABI Layer 2: prove ISU short-program well-formedness — flagship Idris2 proof (#41)
## Summary Raises anvomidaviser's Idris2 ABI to **Layer 2** with its first flagship semantic proof. anvomidaviser's headline is converting ISU notation to formal figure-skating programs; the canonical structural rule is the short-program element-count limit. This proves `WellFormed` — at most 7 elements — as a decidable proposition, so a conforming program is provably valid and an over-length one is provably rejected. Mirrors the estate flagship-proof pattern: program model, decidable `WellFormed` (propositional `LTE`), sound+complete `Dec`, certifier proven sound, positive + negative controls. ## Changes - Adds `src/interface/abi/Anvomidaviser/ABI/Semantics.idr` — `SkateElement`/`Program`, `WellFormed`/`decWellFormed`, `certifyProgramSound`, positive control + negative control (`overRejected`). - Registers the module in `anvomidaviser-abi.ipkg`. ## RSR Quality Checklist ### Required - [x] Tests pass — ABI builds clean (see Testing) - [x] Linter clean — zero warnings - [x] No banned language patterns - [x] No banned functions — genuine proof - [x] SPDX headers present - [x] No secrets ### As Applicable - [x] ABI/FFI changes validated — additive proof; FFI untouched ## Testing Verified with **Idris2 0.7.0**: `idris2 --build anvomidaviser-abi.ipkg` → exit 0, zero warnings. **Adversarial check**: a deliberately-false proof (accepting an 8-element program) was rejected. `build/` removed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx --- _Generated by [Claude Code](https://claude.ai/code/session_01A6PSzJWpRxtzGDjUCEh7Mx)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 247f24c commit 7342734

2 files changed

Lines changed: 103 additions & 1 deletion

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
-- SPDX-License-Identifier: MPL-2.0
2+
-- Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath) <j.d.a.jewell@open.ac.uk>
3+
--
4+
||| Flagship semantic proof for Anvomidaviser (Idris2 ABI Layer 2).
5+
|||
6+
||| Anvomidaviser's headline is "convert ISU notation to formal figure skating
7+
||| programs". A formal program must satisfy ISU well-formedness rules; the
8+
||| canonical structural one is the element-count limit of a short program (at
9+
||| most seven elements). This module models a program as a sequence of skating
10+
||| elements and proves:
11+
|||
12+
||| 1. `WellFormed` — the ISU element-count rule — as a decidable proposition
13+
||| (LTE the limit), with a sound+complete `Dec`;
14+
||| 2. a certifier proven sound; and
15+
||| 3. positive + negative controls (an over-length program is provably
16+
||| rejected — the rule is non-vacuous).
17+
18+
module Anvomidaviser.ABI.Semantics
19+
20+
import Anvomidaviser.ABI.Types
21+
import Data.Nat
22+
23+
%default total
24+
25+
--------------------------------------------------------------------------------
26+
-- A minimal but faithful program model
27+
--------------------------------------------------------------------------------
28+
29+
public export
30+
data SkateElement = Jump | Spin | StepSequence
31+
32+
||| A program is an ordered sequence of elements (as parsed from ISU notation).
33+
public export
34+
Program : Type
35+
Program = List SkateElement
36+
37+
||| The ISU short-program element limit.
38+
public export
39+
maxElements : Nat
40+
maxElements = 7
41+
42+
--------------------------------------------------------------------------------
43+
-- ISU well-formedness as a decidable proposition
44+
--------------------------------------------------------------------------------
45+
46+
-- NB: the limit is written as the literal `7` (= `maxElements`) in this
47+
-- constructor's type, because a lowercase name in a constructor signature is
48+
-- auto-bound as a fresh implicit (which would shadow the global constant).
49+
public export
50+
data WellFormed : Program -> Type where
51+
WF : {0 p : Program} -> LTE (length p) 7 -> WellFormed p
52+
53+
public export
54+
decWellFormed : (p : Program) -> Dec (WellFormed p)
55+
decWellFormed p = case isLTE (length p) maxElements of
56+
Yes prf => Yes (WF prf)
57+
No no => No (\(WF q) => no q)
58+
59+
--------------------------------------------------------------------------------
60+
-- Certifier into the ABI Result, proven sound
61+
--------------------------------------------------------------------------------
62+
63+
public export
64+
certifyProgram : Program -> Result
65+
certifyProgram p = case decWellFormed p of
66+
Yes _ => Ok
67+
No _ => Error
68+
69+
export
70+
certifyProgramSound : (p : Program) -> certifyProgram p = Ok -> WellFormed p
71+
certifyProgramSound p prf with (decWellFormed p)
72+
certifyProgramSound p prf | Yes wf = wf
73+
certifyProgramSound p Refl | No _ impossible
74+
75+
--------------------------------------------------------------------------------
76+
-- Positive control
77+
--------------------------------------------------------------------------------
78+
79+
public export
80+
goodProgram : Program
81+
goodProgram = [Jump, Spin, StepSequence]
82+
83+
export
84+
goodAccepts : certifyProgram Semantics.goodProgram = Ok
85+
goodAccepts = Refl
86+
87+
export
88+
goodWellFormed : WellFormed Semantics.goodProgram
89+
goodWellFormed = certifyProgramSound Semantics.goodProgram goodAccepts
90+
91+
--------------------------------------------------------------------------------
92+
-- Negative control: an over-length program is rejected (non-vacuity)
93+
--------------------------------------------------------------------------------
94+
95+
||| Eight elements — one over the ISU short-program limit.
96+
public export
97+
overProgram : Program
98+
overProgram = [Jump, Jump, Jump, Jump, Spin, Spin, Spin, StepSequence]
99+
100+
export
101+
overRejected : certifyProgram Semantics.overProgram = Error
102+
overRejected = Refl
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-- SPDX-License-Identifier: MPL-2.0
22
package anvomidaviser-abi
33
sourcedir = "."
4-
modules = Anvomidaviser.ABI.Types, Anvomidaviser.ABI.Layout, Anvomidaviser.ABI.Foreign, Anvomidaviser.ABI.Proofs
4+
modules = Anvomidaviser.ABI.Types, Anvomidaviser.ABI.Layout, Anvomidaviser.ABI.Foreign, Anvomidaviser.ABI.Proofs, Anvomidaviser.ABI.Semantics

0 commit comments

Comments
 (0)