import Imports.AllImports

-- start_def problem_details
/--
function_signature: "def same_chars(s0: string, s1: string) -> Bool"
docstring: Check if two words have the same characters.
test_cases:
  - input: ['eabcdzzzz', 'dddzzzzzzzddeddabc']
    expected_output: True
  - input: ['eabcd', 'dddddddabc']
    expected_output: False
-/
-- end_def problem_details

-- start_def problem_spec
def problem_spec
-- function signature
(impl: String → String → Bool)
-- inputs
(s0 s1: String) :=
-- spec
let spec (res: Bool) :=
  res ↔ (∀ c : Char, c ∈ s0.toList ↔ c ∈ s1.toList)
-- program terminates
∃ result, impl s0 s1 = result ∧
-- return value satisfies spec
spec result
-- if result then spec else ¬spec
-- end_def problem_spec

-- start_def generated_spec
def generated_spec
-- function signature
(impl: String → String → Bool)
-- inputs
(s0 s1: String) : Prop :=
--end_def generated_spec
--start_def generated_spec_body
sorry
--end_def generated_spec_body


-- start_def spec_isomorphism
theorem spec_isomorphism:
∀ impl,
(∀ s0 s1, problem_spec impl s0 s1) ↔
(∀ s0 s1, generated_spec impl s0 s1) :=
-- end_def spec_isomorphism
-- start_def spec_isomorphism_proof
sorry
--end_def spec_isomorphism_proof

-- start_def implementation_signature
def implementation (s0 s1: String) : Bool :=
-- end_def implementation_signature
-- start_def implementation
sorry
-- end_def implementation

-- Uncomment the following test cases after implementing the function
-- start_def test_cases
-- #test implementation 'eabcdzzzz' 'dddzzzzzzzddeddabc' = true
-- #test implementation 'abcd' 'dddddddabc' = true
-- #test implementation 'dddddddabc' 'abcd' = true
-- #test implementation 'eabcd' 'dddddddabc' = false
-- #test implementation 'abcd' 'dddddddabce' = false
-- #test implementation 'eabcdzzzz' 'dddzzzzzzzddddabc' = false
-- end_def test_cases


-- start_def correctness_definition
theorem correctness
(s0 s1: String)
: problem_spec implementation s0 s1  :=
-- end_def correctness_definition
-- start_def correctness_proof
by
unfold problem_spec
let result := implementation s0 s1
use result
simp [result]
sorry
-- end_def correctness_proof
