Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/verify-proofs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ jobs:
failed=0
for f in *.idr; do
echo "── $f ─────────────────────────────────────────────"
if idris2 --check "$f"; then
if idris2 --check --total "$f"; then
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved
echo "✓ $f"
bash "$GITHUB_WORKSPACE/scripts/proof-ledger.sh" receipt idris2 pass "verification/proofs/idris2/$f"
else
Expand Down
6 changes: 4 additions & 2 deletions verification/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ Idris2, Lean 4, TLA+ and Agda proof sources for Hypatia's type-level guarantees.
== Building Proofs

The `proofs/` tree is not an Idris2 package; each file is type-checked
independently, exactly as `.github/workflows/verify-proofs.yml` does it:
independently, exactly as `.github/workflows/verify-proofs.yml` does it.
`--total` makes Idris refuse a partial definition even in a file that has
lost its `%default total`:

[source,bash]
----
cd verification/proofs/idris2
for f in *.idr; do idris2 --check "$f"; done
for f in *.idr; do idris2 --check --total "$f"; done
----

The Agda artefact is checked under the estate strict profile (capital
Expand Down
33 changes: 30 additions & 3 deletions verification/proofs/idris2/ParserTotality.idr
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,37 @@ parseFrom _ = Err ExpectedFromClaus
-- Section 3: totality as a structural property
------------------------------------------------------------------------

||| Property 1: parseFrom is a function: equal inputs give equal results.
||| The FROM-clause grammar as a relation, written apart from parseFrom: one
||| constructor per production. `Parses ts s rest` says the grammar reads
||| source s from the front of ts and leaves rest.
public export
data Parses : List Token -> Source -> List Token -> Type where
PStore : Parses (KwFrom :: KwStore :: Ident v :: rest) (Store v) rest
PStoreQuoted : Parses (KwFrom :: KwStore :: Quoted v :: rest) (Store v) rest
PFed : Parses (KwFrom :: KwFederation :: Ident v :: rest) (Federation v) rest
PFedQuoted : Parses (KwFrom :: KwFederation :: Quoted v :: rest) (Federation v) rest
PHexad : Parses (KwFrom :: KwHexad :: Ident v :: rest) (Hexad v) rest

||| Every parse the grammar allows is the one parseFrom returns. If two
||| productions could read the same tokens differently, parseFrom could
||| return only one of them, and this would not check.
export
parsesComplete : Parses ts s rest -> parseFrom ts = Ok s rest
parsesComplete PStore = Refl
parsesComplete PStoreQuoted = Refl
parsesComplete PFed = Refl
parsesComplete PFedQuoted = Refl
parsesComplete PHexad = Refl

||| Property 1: the grammar is deterministic. Two parses of the same tokens
||| give the same source and leave the same tokens. Derived from
||| parsesComplete: both parses are the one parseFrom returns.
export
parseFromDeterministic : (ts : List Token) -> parseFrom ts = parseFrom ts
parseFromDeterministic _ = Refl
parseFromDeterministic : Parses ts s rest -> Parses ts s' rest' -> (s = s', rest = rest')
parseFromDeterministic p q = okInjective (trans (sym (parsesComplete p)) (parsesComplete q))
where
okInjective : Ok a r = Ok a' r' -> (a = a', r = r')
okInjective Refl = (Refl, Refl)

||| Property 2: empty input gives the empty-input error.
export
Expand Down
Loading