lean4-htt/tests/lean/run/string_simprocs.lean
Leonardo de Moura f3ccd6b023
feat: some string simprocs (#4233)
For the SSFT24 summer school.
2024-05-20 22:53:10 +00:00

60 lines
1.4 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

abbrev Value := BitVec 32
def Env := String → Value
namespace Env
def set (x : String) (v : Value) (ρ : Env) : Env :=
fun y => if x = y then v else ρ y
def get (x : String) (ρ : Env) : Value :=
ρ x
def init (i : Value) : Env := fun _ => i
end Env
@[simp] theorem Env.get_init : (Env.init v).get x = v := by rfl
@[simp] theorem Env.get_set_same {ρ : Env} : (ρ.set x v).get x = v := by
simp [get, set]
@[simp] theorem Env.get_set_different {ρ : Env} : x ≠ y → (ρ.set x v).get y = ρ.get y := by
intro; simp [get, set, *]
example : (((Env.init 0).set "x" 1).set "y" 2).get "y" = 2 := by
simp
example : (((Env.init 0).set "x" 1).set "y" 2).get "x" = 1 := by
simp
example : (((Env.init 0).set "x" 1).set "y" 2).get "z" = 0 := by
simp
example : "hello" ≠ "foo" := by
simp
example : "hello" != "foo" := by
simp
example : "hello" == "hello" := by
simp
example : "hello" == "foo" → False := by
simp
example : "hello" = "foo" → False := by
simp [-String.reduceEq]
guard_target =ₛ ¬ "hello" = "foo"
simp
example : "hello" ≤ "hellz" := by simp
example : "hello" < "hellz" := by simp
example : "hellz" > "hello" := by simp
example : "hellz" ≥ "hello" := by simp
example : "abcd" > "abc" := by simp
example : 'b' > 'a' := by simp
example : 'a' ≥ 'a' := by simp
example : 'a' < 'b' := by simp
example : 'a' ≤ 'a' := by simp