Skip to content

Commit

Permalink
first try defining NDPA
Browse files Browse the repository at this point in the history
  • Loading branch information
zbrachinara committed Nov 23, 2024
1 parent da22932 commit bf9c7f7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions NpTetris/Proofs/S3_2_TwoColumn/NDPA.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Mathlib.Data.Set.Defs
import Mathlib.Data.Fintype.Powerset

/-- Non-deterministic Pushdown Automaton. Not (yet) translatable to or from mathlib's NFA. For that
we need to encode that the stack will always have an element to step with -/
structure NDPA (Stack_α String_α State: Type) where
initial : Set State
initial_stack : Stack_α
accept : Set State
step : State → Stack_α → String_α → Set (State × List Stack_α)

namespace NDPA

variable {Stack_α String_α State} {M : NDPA Stack_α String_α State}

inductive accepts' : State → List Stack_α → List String_α → Prop
where
| term stack state : state ∈ M.accept → accepts' state stack []
| step stack_a string_a stack string state state' stack' :
accepts' state' (stack' ++ stack) string →
(state', stack') ∈ M.step state stack_a string_a →
accepts' state (stack_a :: stack) (string_a :: string)

def accepts (string : List String_α) := ∃ s ∈ M.initial, M.accepts' s [M.initial_stack] string

end NDPA

0 comments on commit bf9c7f7

Please sign in to comment.