Script Definition #
Script here is a list of steps, stateful computations that may fail.
Eventually, we also need them to signal when they've ended, so the Computation Thread knows when to end.
@[reducible, inline]
Equations
- ScriptsDefinition.StepM α β = (α → β → ScriptsDefinition.Ended α)
Instances For
@[reducible, inline]
Equations
- ScriptsDefinition.CompM α β = List (ScriptsDefinition.StepM α β)
Instances For
- init : κ → α
- steps : CompM α β
Instances For
Equations
- ScriptsDefinition.cond_lift f st b = if f st b = true then ScriptsDefinition.Ended.Un st else ScriptsDefinition.Ended.Err
Instances For
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- ScriptsDefinition.runCompM st [] [] = ScriptsDefinition.Ended.Un (some st)
- ScriptsDefinition.runCompM st steps ins = ScriptsDefinition.Ended.Un none
Instances For
Equations
- ScriptsDefinition.Execution scr init ins = ScriptsDefinition.runCompM (scr.init init) scr.steps ins
Instances For
Equations
- ScriptsDefinition.SuccessfulEx scr init ins = match ScriptsDefinition.Execution scr init ins with | ScriptsDefinition.Ended.Ed => true | x => false
Instances For
List Operations #
Before implementing Merkle Trees, we can implement everthing using Lists.
The main difference is that when we search for elements, we need to provide a witness, i.e. a path, along with the corresponding element.
Equations
- ListWitness.listIndex ListSimulation.Path.Here (h :: tail) = some h
- ListWitness.listIndex p'.There (head :: l) = ListWitness.listIndex p' l
- ListWitness.listIndex p [] = none
Instances For
theorem
ListWitness.check_path_same_index
{α : Type}
[DecidableEq α]
{v : α}
{p : ListSimulation.Path}
{ls : List α}
:
theorem
ListWitness.check_path_same_index_other
{α : Type}
[DecidableEq α]
{v v' : α}
{p : ListSimulation.Path}
{ls : List α}
:
theorem
ListWitness.check_path_same_index'
{α : Type}
[DecidableEq α]
{v : α}
{p : ListSimulation.Path}
{ls : List α}
:
theorem
ListWitness.listIndex_path_minus
{α : Type}
{q : ListSimulation.Path}
{ls : List α}
{a : α}
{n : ℕ}
(h : α)
(H : listIndex (ListSimulation.path_minus (ListSimulation.Path.add n q.There) q.There) ls = some a)
:
def
ListWitness.findWitness?'
{α β : Type}
(f : α → Option β)
(as : List α)
(acc : ListSimulation.Path)
:
Equations
Instances For
theorem
ListWitness.findWitness_path_add
{α β : Type}
{b : β}
{f : α → Option β}
{as : List α}
{acc path : ListSimulation.Path}
(H : findWitness?' f as acc = some (b, path))
:
∃ (n : ℕ), ListSimulation.Path.add n acc = path
@[reducible, inline]
Equations
Instances For
Equations
- ListWitness.findWitnessB f = ListWitness.findWitness? fun (v : α) => if f v = true then some v else none
Instances For
theorem
ListWitness.correctWitId
{α : Type}
[DecidableEq α]
{path acc : ListSimulation.Path}
{a a' : α}
{as : List α}
(H : findWitness?' (fun (a' : α) => if (a' == a) = true then some a' else none) as acc = some (a', path))
:
theorem
ListWitness.correctWit
{α β : Type}
{b : β}
{path acc : ListSimulation.Path}
{f : α → Option β}
{as : List α}
(H : findWitness?' f as acc = some (b, path))
:
theorem
ListWitness.findWitness_none
{α β : Type}
{acc : ListSimulation.Path}
{f : α → Option β}
{as : List α}
(H : findWitness?' f as acc = none)
(a : α)
(aIn : a ∈ as)
:
theorem
ListWitness.witness_path_less_length
{α β : Type}
{b : β}
{path : ListSimulation.Path}
{f : α → Option β}
{as : List α}
(H : findWitness? f as = some (b, path))
:
theorem
ListWitness.witness_valid_path
{α : Type}
[DecidableEq α]
{b : α}
{path : ListSimulation.Path}
(v : α)
{as : List α}
(H : findWitness? (fun (v' : α) => if (v == v') = true then some v else none) as = some (b, path))
:
def
ListWitness.findNMWitness?'
{α : Type}
[LinearOrder α]
(v prev : α)
(acc : ListSimulation.Path)
(as : List α)
:
Equations
- One or more equations did not get rendered due to their size.
- ListWitness.findNMWitness?' v prev acc [] = some (ListSimulation.NonMemProof.NonMemLast prev acc)
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
theorem
ListWitness.findmem_none_nonmem
{α : Type}
[LinearOrder α]
{v hd : α}
{as : List α}
(asLT : List.Sorted (fun (x1 x2 : α) => x1 < x2) (hd :: as))
(H : findNMWitness? v hd as = none)
:
theorem
ListWitness.findnon_mem_none_find
{α : Type}
[LinearOrder α]
{v hd : α}
{as : List α}
(asLT : List.Sorted (fun (x1 x2 : α) => x1 < x2) (hd :: as))
(H : (findWitness? (fun (v' : α) => if (v == v') = true then some v else none) (hd :: as)).isSome = true)
:
theorem
ListWitness.nonmem_find'_notfirst
{α : Type}
[LinearOrder α]
{v hd t : α}
{patht acc : ListSimulation.Path}
{as : List α}
{res : ListSimulation.NonMemProof α}
(H : findNMWitness?' v hd acc as = some res)
(t✝ : α)
(path : ListSimulation.Path)
:
theorem
ListWitness.nonmem_find'_last_or_between
{α : Type}
[LinearOrder α]
{v hd : α}
{acc : ListSimulation.Path}
{as : List α}
{res : ListSimulation.NonMemProof α}
(H : findNMWitness?' v hd acc as = some res)
:
(∃ (t : α) (n : ℕ), res = ListSimulation.NonMemProof.NonMemLast t (ListSimulation.Path.add n acc)) ∨ ∃ (tl : α) (tr : α) (n : ℕ),
res = ListSimulation.NonMemProof.NonBetween tl (ListSimulation.Path.add n acc) tr (ListSimulation.Path.add n.succ acc)
theorem
ListWitness.findnon_mem_first
{α : Type}
[LinearOrder α]
{v hd t : α}
{patht : ListSimulation.Path}
{as : List α}
(H : findNMWitness? v hd as = some (ListSimulation.NonMemProof.NonMemFirst t patht))
:
theorem
ListWitness.findnon_mem_correct'
{α : Type}
[LinearOrder α]
{v hd : α}
{wit : ListSimulation.NonMemProof α}
{acc : ListSimulation.Path}
{as : List α}
(lt : hd < v)
(sort : List.Sorted (fun (x1 x2 : α) => x1 < x2) (hd :: as))
(H : findNMWitness?' v hd acc as = some wit)
:
ListSimulation.check_non_membership (ListSimulation.minus_path_non_mem acc wit) v (hd :: as) ⋯ = true
theorem
ListWitness.findnon_mem_correct
{α : Type}
[LinearOrder α]
{v hd : α}
{wit : ListSimulation.NonMemProof α}
{as : List α}
(sort : List.Sorted (fun (x1 x2 : α) => x1 < x2) (hd :: as))
(H : findNMWitness? v hd as = some wit)
:
theorem
ListWitness.non_mem_find
{α : Type}
[l : LinearOrder α]
{v : α}
{wit : ListSimulation.NonMemProof α}
{as : List α}
(ne : ¬as = [])
(sort : List.Sorted (fun (x1 x2 : α) => x1 < x2) as)
(H : ListSimulation.check_non_membership wit v as ne = true)
:
axiom
ListWitness.forall_not_witness_eq_none
{α : Type}
[l : LinearOrder α]
{ls : List α}
{e hd : α}
(lsSorted : List.Sorted (fun (x1 x2 : α) => x1 < x2) (hd :: ls))
(H : ∀ (wit : ListSimulation.NonMemProof α), ¬findNMWitness? e hd ls = some wit)
: