-
Notifications
You must be signed in to change notification settings - Fork 159
feat(Automata, LTS, TM): Introduce LTS.SMTr and LTS.mapLabel, generalise TM tapes to arbitrary universes, fix EpsilonNA, and introduce their single-accept transformation #625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
fmontesi
wants to merge
27
commits into
main
Choose a base branch
from
fmontesi/ena
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d127bd9
TM on NA
fmontesi 85c2b86
NTM v2
fmontesi ce3adec
NTM from NA
fmontesi ab47fad
NTM
fmontesi eba8935
OptionDA
fmontesi f7e8d84
OptionDA take 2
fmontesi 2ba81ef
some progress
fmontesi 7ab5224
merge main
fmontesi f9cef26
Progress on toOptionDA
fmontesi 1338139
Add NTM in parallel to SingleTapeTM
fmontesi 9721c91
fix header linter
fmontesi 9541268
isSome theorems for toSingleAccept
fmontesi 627900c
ToSingleAccept
fmontesi 3f810ee
toSingleAccept_tr_tr
fmontesi 7c75044
toSingleAccept_tr_antiDerivative_isSome
fmontesi 4d9e653
toSingleAccept_mTr_antiDerivative_isSome
fmontesi 554ffe8
toSingleAccept_mTr_mTr
fmontesi e099a2e
toSingleAccept_τSTr_antiDerivative_isSome
fmontesi 03c9894
toSingleAccept_τSTr_τSTr
fmontesi 34fdda4
toSingleAccept_sMTr_sMTr
fmontesi dadd7eb
toSingleAccept_language_eq
fmontesi ef45155
WIP
fmontesi 7ebee10
Remove NTM for now
fmontesi 255b816
merge main
fmontesi fb5166c
fix HasTau
fmontesi f7d11b7
fix Simulation
fmontesi a42d0a3
Fix grind tests
fmontesi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,32 +7,13 @@ Authors: Fabrizio Montesi | |
| module | ||
|
|
||
| public import Cslib.Computability.Automata.EpsilonNA.Basic | ||
| public import Cslib.Foundations.Semantics.LTS.Map | ||
|
|
||
| /-! # Translation of εNA into NA -/ | ||
|
|
||
| @[expose] public section | ||
|
|
||
| namespace Cslib | ||
|
|
||
| /-- Converts an `LTS` with Option labels into an `LTS` on the carried label type, by removing all | ||
| ε-transitions. -/ | ||
| @[local grind =] | ||
| def LTS.noε (lts : LTS State (Option Label)) : LTS State Label where | ||
| Tr s μ s' := lts.Tr s (some μ) s' | ||
|
|
||
| @[local grind .] | ||
| private lemma LTS.noε_saturate_tr | ||
| {lts : LTS State (Option Label)} {h : μ = some μ'} : | ||
| lts.saturate.Tr s μ s' ↔ lts.saturate.noε.Tr s μ' s' := by | ||
| grind | ||
|
|
||
| @[scoped grind =] | ||
| lemma LTS.noε_saturate_mTr {lts : LTS State (Option Label)} : | ||
| lts.saturate.MTr s (μs.map some) = lts.saturate.noε.MTr s μs := by | ||
| ext s' | ||
| induction μs generalizing s <;> grind [<= LTS.MTr.stepL] | ||
|
|
||
| namespace Automata.εNA.FinAcc | ||
| namespace Cslib.Automata.εNA.FinAcc | ||
|
|
||
| variable {State Symbol : Type*} | ||
|
|
||
|
|
@@ -41,21 +22,39 @@ variable {State Symbol : Type*} | |
| def toNAFinAcc (a : εNA.FinAcc State Symbol) : NA.FinAcc State Symbol where | ||
| start := a.εClosure a.start | ||
| accept := a.accept | ||
| Tr := a.saturate.noε.Tr | ||
| toLTS := a.saturate.mapLabel Option.some | ||
|
|
||
| open Acceptor in | ||
| open scoped NA.FinAcc in | ||
| open scoped NA.FinAcc LTS LTS.MTr LTS.STr LTS.SMTr in | ||
| /-- Correctness of `toNAFinAcc`. -/ | ||
| @[scoped grind _=_] | ||
| theorem toNAFinAcc_language_eq {ena : εNA.FinAcc State Symbol} : | ||
| language ena.toNAFinAcc = language ena := by | ||
| @[scoped grind =] | ||
| theorem toNAFinAcc_language_eq {a : εNA.FinAcc State Symbol} : | ||
| language a.toNAFinAcc = language a := by | ||
| ext xs | ||
| have : ∀ s s', ena.saturate.MTr s (xs.map some) s' = ena.saturate.noε.MTr s xs s' := by | ||
| simp [LTS.noε_saturate_mTr] | ||
| #adaptation_note | ||
| /-- A grind regression found moving to nightly-2026-03-31 (changes from lean#13166) -/ | ||
| grind [Accepts] | ||
|
|
||
| end Automata.εNA.FinAcc | ||
|
|
||
| end Cslib | ||
| apply Iff.intro <;> intro h <;> rcases h with ⟨s, hs, s', hs', h⟩ | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| case mp => | ||
| have h_start : ∃ sStart ∈ a.start, a.τSTr sStart s := by | ||
| simp only [toNAFinAcc, εClosure, LTS.τClosure, LTS.setImage, Set.mem_iUnion, | ||
| exists_prop] at hs | ||
| rcases hs with ⟨sStart, h_sStart, hs⟩ | ||
| exists sStart | ||
| apply And.intro h_sStart | ||
| simp only [LTS.image, LTS.saturate, Set.mem_setOf_eq] at hs | ||
| grind only [LTS.sTr_τSTr_iff] | ||
| rcases h_start with ⟨sStart, h_sStart, h_start⟩ | ||
| exists sStart | ||
| apply And.intro (by grind) | ||
| exists s' | ||
| apply And.intro (by grind) | ||
| apply LTS.SMTr.comp (μs₁ := []) (s₂ := s) <;> grind | ||
| case mpr => | ||
| cases xs with | ||
| | nil => | ||
| exists s' | ||
| simp only [toNAFinAcc, LTS.saturate, LTS.τClosure] | ||
| grind [cases LTS.SMTr] | ||
| | cons x xs => | ||
| exists s | ||
| grind | ||
|
|
||
| end Cslib.Automata.εNA.FinAcc | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the old indentation pattern is the correct one.