File tree Expand file tree Collapse file tree
DatapathVerification/BitHeap Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,4 +112,43 @@ theorem fullAdder_correct (column : Nat) (i j k : Circuit) (h : BitHeap)
112112 generalize hvk : k.eval env = vk
113113 rcases vi <;> rcases vj <;> rcases vk <;> grind
114114
115+ inductive Adder where
116+ | halfAdder (column : Nat) (a b : Circuit)
117+ | fullAdder (column : Nat) (a b c : Circuit)
118+
119+ def applyAdder (adder : Adder) (h : BitHeap) : BitHeap :=
120+ match adder with
121+ | .halfAdder column i j => (h.halfAdder column i j).heap
122+ | .fullAdder column i j k => (h.fullAdder column i j k).heap
123+
124+ theorem applyAdder_halfAdder_correct (column : Nat) (i j : Circuit) (h : BitHeap)
125+ (h1 : i ∈ h.get column) (h2 : j ∈ h.get column) (hne : i ≠ j) :
126+ ∀ (env : BitEnv), (applyAdder (.halfAdder column i j) h).eval env = h.eval env := by
127+ intros env
128+ simp [applyAdder]
129+ exact halfAdder_correct column i j h h1 h2 hne env
130+
131+ theorem applyAdder_fullAdder_correct (column : Nat) (i j k : Circuit) (h : BitHeap)
132+ (h1 : i ∈ h.get column) (h2 : j ∈ h.get column) (h3 : k ∈ h.get column) (hne : i ≠ j) (hne2 : i ≠ k) (hne3 : j ≠ k) :
133+ ∀ (env : BitEnv), (applyAdder (.fullAdder column i j k) h).eval env = h.eval env := by
134+ intros env
135+ simp [applyAdder]
136+ exact fullAdder_correct column i j k h h1 h2 h3 hne hne2 hne3 env
137+
138+ def applyChain (adders : List Adder) (h : BitHeap) : BitHeap :=
139+ match adders with
140+ | [] => h
141+ | s :: rest => applyChain rest (applyAdder s h)
142+
143+ theorem applyChain_correct (steps : List Adder) (h : BitHeap) (env : BitEnv) :
144+ (applyChain steps h).eval env = h.eval env := by
145+ induction steps generalizing h with
146+ | nil => rfl
147+ | cons s rest ih =>
148+ simp [applyChain]
149+ rw [ih]
150+ cases s with
151+ | halfAdder => sorry
152+ | fullAdder => sorry
153+
115154end BitHeap
You can’t perform that action at this time.
0 commit comments