-- nox/T2.ei โ bound monotonicity for nox formula patterns
-- Source: nox/proofs/lean/T2_bound_monotonicity.lean
-- โโ Types โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
inductive AtomKind : Type 1 where
| field : AtomKind
| register : AtomKind
inductive Formula : Type 1 where
| atom : Nat -> AtomKind -> Formula
| cell : Formula -> Formula -> Formula
-- bound : Formula -> Nat (simplified from bound : Formula -> Cost)
axiom bound : Formula -> Nat
-- โโ T2.1 โ atom bound is 0 โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
axiom bound_atom (n : Nat) (k : AtomKind) :
Eq Nat (bound (Formula.atom n k)) 0
-- โโ T2.2 โ binary structural patterns โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
axiom bound_cons (a : Formula) (b : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 3 AtomKind.field) (Formula.cell a b)))
(Nat.add 1 (Nat.add (bound a) (bound b)))
axiom bound_add (a : Formula) (b : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 5 AtomKind.field) (Formula.cell a b)))
(Nat.add 1 (Nat.add (bound a) (bound b)))
axiom bound_sub (a : Formula) (b : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 6 AtomKind.field) (Formula.cell a b)))
(Nat.add 1 (Nat.add (bound a) (bound b)))
axiom bound_mul (a : Formula) (b : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 7 AtomKind.field) (Formula.cell a b)))
(Nat.add 1 (Nat.add (bound a) (bound b)))
axiom bound_eq (a : Formula) (b : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 9 AtomKind.field) (Formula.cell a b)))
(Nat.add 1 (Nat.add (bound a) (bound b)))
axiom bound_lt (a : Formula) (b : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 10 AtomKind.field) (Formula.cell a b)))
(Nat.add 64 (Nat.add (bound a) (bound b)))
axiom bound_xor (a : Formula) (b : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 11 AtomKind.field) (Formula.cell a b)))
(Nat.add 32 (Nat.add (bound a) (bound b)))
axiom bound_and (a : Formula) (b : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 12 AtomKind.field) (Formula.cell a b)))
(Nat.add 32 (Nat.add (bound a) (bound b)))
axiom bound_shl (a : Formula) (n : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 14 AtomKind.field) (Formula.cell a n)))
(Nat.add 32 (Nat.add (bound a) (bound n)))
axiom bound_look (ns : Formula) (key : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 17 AtomKind.field) (Formula.cell ns key)))
(Nat.add 1 (Nat.add (bound ns) (bound key)))
-- โโ T2.3 โ unary patterns โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
axiom bound_inv (a : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 8 AtomKind.field) a))
(Nat.add 64 (bound a))
axiom bound_not (a : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 13 AtomKind.field) a))
(Nat.add 32 (bound a))
axiom bound_hash (a : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 15 AtomKind.field) a))
(Nat.add 25 (bound a))
-- โโ T2.4 โ branch โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
axiom bound_branch (test : Formula) (yes : Formula) (no : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 4 AtomKind.field)
(Formula.cell test (Formula.cell yes no))))
(Nat.add 1 (Nat.add (bound test) (Nat.max (bound yes) (bound no))))
-- โโ T2.5 โ no-sub patterns โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
axiom bound_axis (addr : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 0 AtomKind.field) addr)) 1
axiom bound_quote (c : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 1 AtomKind.field) c)) 1
-- โโ T2.6 โ compose: always dynamic โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
axiom bound_compose (x : Formula) (y : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 2 AtomKind.field) (Formula.cell x y)))
(Nat.add 1 (Nat.add (bound x) (bound y)))
-- โโ T2.7 โ call: always dynamic โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
axiom bound_call (tag : Formula) (check : Formula) :
Eq Nat (bound (Formula.cell (Formula.atom 16 AtomKind.field) (Formula.cell tag check)))
(Nat.add 1 (bound tag))
-- โโ T2 monotonicity โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
axiom bound_monotone_in_left (a : Formula) (a' : Formula) (b : Formula)
(hge : Le (bound a) (bound a')) :
Le (bound (Formula.cell (Formula.atom 5 AtomKind.field) (Formula.cell a b)))
(bound (Formula.cell (Formula.atom 5 AtomKind.field) (Formula.cell a' b)))
-- โโ T2.8 โ upper bound (vacuous โ reduce_seq is a stub) โโโโโโโโโโโโโโโโโโโโโ
axiom Noun : Type 1
axiom reduce_seq : Noun -> Formula -> Nat -> Nat
axiom bound_upper_bounds_actual_cost
(o : Noun) (t : Formula) (f : Nat) (r : Nat)
(h : Eq Nat (reduce_seq o t f) r) :
Le (Nat.sub f r) (bound t)