sov-kernel-monster / lean /HieroglyphFormalization.lean
SNAPKITTYWEST's picture
chore: push full sov-kernel-monster content from local build
9425aed verified
Raw
History Blame Contribute Delete
3.01 kB
import Mathlib.Data.List.Basic
import Mathlib.Data.Finset.Basic
namespace Hieroglyphs
/-- A deliberately bounded alphabet for the signs in the supplied stream. -/
inductive Glyph
| eye -- π“‚€
| bread -- 𓏏
| mouth -- π“‚‹
| flax -- π“Ž›
| stroke -- 𓏀
| god -- π“ŠΉ
| ankh -- π“‹Ή
| cobra -- 𓆣
| sun -- 𓇳
| unknownA -- π“‚»
| water -- π“ˆ–
| stool -- π“Šͺ
| owl -- π“…“
| basket -- π“ŽΌ
deriving DecidableEq, Repr
def transliterate : Glyph β†’ String
| .eye => "ir"
| .bread => "t"
| .mouth => "r"
| .flax => "h"
| .stroke => "Β·"
| .god => "nαΉ―r"
| .ankh => "κœ₯nαΈ«"
| .cobra => "?"
| .sun => "rκœ₯"
| .unknownA => "?"
| .water => "n"
| .stool => "p"
| .owl => "m"
| .basket => "g"
/-- A decoding is only certified relative to an explicit grammar and lexicon. -/
structure DecodeSpec where
lexical : List Glyph β†’ Option String
grammatical : List Glyph β†’ Prop
sound : βˆ€ xs meaning,
lexical xs = some meaning β†’ grammatical xs
/-- Concrete recognition is distinct from semantic translation. -/
def Recognized (xs : List Glyph) : Prop :=
βˆ€ g, g ∈ xs β†’
g = .eye ∨ g = .bread ∨ g = .mouth ∨ g = .flax ∨
g = .stroke ∨ g = .god ∨ g = .ankh ∨ g = .cobra ∨
g = .sun ∨ g = .unknownA ∨ g = .water ∨ g = .stool ∨
g = .owl ∨ g = .basket
/-- A formal definition of periodicity for a list. -/
def Periodic (period xs : List Glyph) : Prop :=
period β‰  [] ∧ βˆƒ k, xs = List.join (List.replicate k period)
/-- Example recurring motif β€” not asserted to be Egyptian grammar. -/
def Motif : List Glyph :=
[.eye, .ankh, .god, .sun, .cobra, .unknownA,
.water, .bread, .flax, .mouth, .stool, .owl]
example : Periodic Motif (Motif ++ Motif) := by
refine ⟨by decide, 2, ?_⟩
simp [Motif]
/-- A truthful result type: never manufacture a semantic translation. -/
inductive DecodeResult
| transliteration : List String β†’ DecodeResult
| grammatical : String β†’ DecodeResult
| insufficientEvidence : String β†’ DecodeResult
deriving Repr
def decode (spec : DecodeSpec) (xs : List Glyph) : DecodeResult :=
match spec.lexical xs with
| some meaning =>
if spec.grammatical xs then .grammatical meaning
else .insufficientEvidence "Lexicon returned a reading rejected by grammar."
| none =>
.insufficientEvidence
"No certified lexical-and-grammatical interpretation for this glyph sequence."
theorem no_semantic_claim_without_lexicon
(spec : DecodeSpec) (xs : List Glyph)
(h : spec.lexical xs = none) :
decode spec xs =
.insufficientEvidence
"No certified lexical-and-grammatical interpretation for this glyph sequence." := by
simp [decode, h]
end Hieroglyphs