String constraints: syntax and semantics

InductiveString term over variables#✓fully proved

A string term over variables V: a constant word, a variable, the concatenation of two terms, or a letter-to-word morphism applied to a term.

inductive Term (α : Type*) (V : Type*) where
  | const : List α → Term α V
  | var : V → Term α V
  | append : Term α V → Term α V → Term α V
  | hom : (α → List α) → Term α V → Term α V
Used by 30

DefinitionEvaluation of a string term under an assignment#✓fully proved

Evaluation of a term under an assignment.

def eval (σ : V → List α) : Term α V → List α
  | .const w => w
  | .var i => σ i
  | .append t₁ t₂ => eval σ t₁ ++ eval σ t₂
  | .hom f t => (eval σ t).flatMap f
Uses 1 · Used by 18

DefinitionVariables occurring in a string term#✓fully proved

The variables occurring in a term, as a list (duplicates allowed).

def varsOf : Term α V → List V
  | .const _ => []
  | .var i => [i]
  | .append t₁ t₂ => varsOf t₁ ++ varsOf t₂
  | .hom _ t => varsOf t
Uses 1 · Used by 8

TheoremString term evaluation depends only on its variables#✓fully proved

Evaluation depends only on the values of the variables in the term.

theorem eval_eq_of_agree_on_vars {σ τ : V → List α} {t : Term α V}
    (h : ∀ i ∈ varsOf t, σ i = τ i) : eval σ t = eval τ t
Uses 3 · Used by 3

InductiveString constraint atom#✓fully proved

A string atom: a word equation, a regular-membership test, or a length bound. Regular languages are represented by the existing Cslib.Language.EncodedRegex.

inductive Atom (α : Type*) (V : Type*) where
  | eq : Term α V → Term α V → Atom α V
  | mem : Term α V → EncodedRegex α → Atom α V
  | lenLe : Term α V → ℕ → Atom α V
  | lenGe : Term α V → ℕ → Atom α V
Uses 2 · Used by 18

DefinitionVariables occurring in a string atom#✓fully proved

The variables occurring in an atom.

def varsOfAtom : Atom α V → List V
  | .eq t₁ t₂ => varsOf t₁ ++ varsOf t₂
  | .mem t _ => varsOf t
  | .lenLe t _ => varsOf t
  | .lenGe t _ => varsOf t
Uses 4 · Used by 2

InductiveString formulas#✓fully proved

Positive Boolean combinations of atoms (conjunction, disjunction, true, false; no negation), as in the positive fragment of SMT-LIB assertions.

inductive Formula (α : Type*) (V : Type*) where
  | atom : Atom α V → Formula α V
  | and : Formula α V → Formula α V → Formula α V
  | or : Formula α V → Formula α V → Formula α V
  | true : Formula α V
  | false : Formula α V
Uses 1 · Used by 25

DefinitionConjunction of a list of string formulas#✓fully proved

Conjunction of a list of formulas.

def andChain : List (Formula α V) → Formula α V
  | [] => .true
  | f :: fs => .and f (andChain fs)
Uses 1 · Used by 4

DefinitionDisjunction of a list of string formulas#✓fully proved

Disjunction of a list of formulas.

def orChain : List (Formula α V) → Formula α V
  | [] => .false
  | f :: fs => .or f (orChain fs)
Uses 1 · Used by 3

DefinitionVariables occurring in a string formula#✓fully proved

The variables occurring in a formula.

def varsOfFormula : Formula α V → List V
  | .atom a => varsOfAtom a
  | .and f g => varsOfFormula f ++ varsOfFormula g
  | .or f g => varsOfFormula f ++ varsOfFormula g
  | .true => []
  | .false => []
Uses 3 · Used by 7

DefinitionSatisfaction of a string atom#✓fully proved

Satisfaction of an atom under an assignment.

def SatAtom (σ : V → List α) : Atom α V → Prop
  | .eq t₁ t₂ => eval σ t₁ = eval σ t₂
  | .mem t e => eval σ t ∈ e.toRegex.matches'
  | .lenLe t k => (eval σ t).length ≤ k
  | .lenGe t k => k ≤ (eval σ t).length
Uses 5 · Used by 7

DefinitionSatisfaction of a string formula#✓fully proved

Satisfaction of a formula under an assignment.

def Sat (σ : V → List α) : Formula α V → Prop
  | .atom a => SatAtom σ a
  | .and f g => Sat σ f ∧ Sat σ g
  | .or f g => Sat σ f ∨ Sat σ g
  | .true => True
  | .false => False
Uses 3 · Used by 14

TheoremSatisfaction of a conjunction chain#✓fully proved

Satisfaction of a conjunction chain: every member is satisfied.

theorem sat_andChain {σ : V → List α} {fs : List (Formula α V)} :
    Sat σ (andChain fs) ↔ ∀ f ∈ fs, Sat σ f
Uses 3 · Used by 2

TheoremSatisfaction of a disjunction chain#✓fully proved

Satisfaction of a disjunction chain: one member is satisfied.

theorem sat_orChain {σ : V → List α} {fs : List (Formula α V)} :
    Sat σ (orChain fs) ↔ ∃ f ∈ fs, Sat σ f
Uses 3 · Used by 1

TheoremAtom satisfaction depends only on its variables#✓fully proved

Satisfaction of an atom depends only on the values of its variables.

theorem satAtom_congr {σ τ : V → List α} {a : Atom α V}
    (h : ∀ i ∈ varsOfAtom a, σ i = τ i) : SatAtom σ a ↔ SatAtom τ a
Uses 9 · Used by 1

TheoremFormula satisfaction depends only on its variables#✓fully proved

Satisfaction depends only on the values of the variables in the formula.

theorem sat_congr {σ τ : V → List α} {φ : Formula α V}
    (h : ∀ i ∈ varsOfFormula φ, σ i = τ i) : Sat σ φ ↔ Sat τ φ
Uses 5 · Used by 3

DefinitionBoolean checker for atom satisfaction#✓fully proved

Boolean checker for atom satisfaction. Regular membership uses EncodedRegex.memB.

def satAtomB (σ : V → List α) : Atom α V → Bool
  | .eq t₁ t₂ => decide (eval σ t₁ = eval σ t₂)
  | .mem t e => e.memB (eval σ t)
  | .lenLe t k => decide ((eval σ t).length ≤ k)
  | .lenGe t k => decide (k ≤ (eval σ t).length)
Uses 5 · Used by 3

TheoremCorrectness of the Boolean atom checker#✓fully proved

The Boolean checker is correct.

theorem satAtomB_iff {σ : V → List α} {a : Atom α V} :
    satAtomB σ a = true ↔ SatAtom σ a
Uses 13 · Used by 1

DefinitionBoolean checker for formula satisfaction#✓fully proved

Boolean checker for formula satisfaction.

def satB (σ : V → List α) : Formula α V → Bool
  | .atom a => satAtomB σ a
  | .and f g => satB σ f && satB σ g
  | .or f g => satB σ f || satB σ g
  | .true => true
  | .false => false
Uses 3 · Used by 4

TheoremCorrectness of the Boolean formula checker#✓fully proved

The Boolean checker is correct.

theorem satB_iff {σ : V → List α} {φ : Formula α V} :
    satB σ φ = true ↔ Sat σ φ
Uses 7 · Used by 2
20 fully proved

The dependency explorer needs JavaScript and its graph data.

Download the complete graph data.