Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasgrosser committed Oct 17, 2024
1 parent 6a1c9c0 commit ea7e0f9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
14 changes: 7 additions & 7 deletions SSA/Experimental/Bits/AutoStructs/FiniteStateMachine.lean
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ variable {α β α' β' : Type} {γ : β → Type}
where `n` is the number of `BitStream` arguments,
as a finite state machine.
-/
structure FSM (arity : Type) : Type 1 :=
structure FSM (arity : Type) : Type 1 where
/--
The arity of the (finite) type `α` determines how many bits the internal carry state of this
FSM has -/
Expand Down Expand Up @@ -307,7 +307,7 @@ def sub : FSM Bool :=
theorem carry_sub (x : Bool → BitStream) : ∀ (n : ℕ), sub.carry x (n+1) =
fun _ => (BitStream.subAux (x true) (x false) n).2
| 0 => by
simp [carry, nextBit, Function.funext_iff, BitStream.subAux, sub]
simp [carry, nextBit, BitStream.subAux, sub]
| n+1 => by
rw [carry, carry_sub _ n]
simp [nextBit, eval, sub, BitStream.sub, BitStream.subAux, Bool.xor_not_left']
Expand All @@ -333,7 +333,7 @@ def neg : FSM Unit :=
theorem carry_neg (x : Unit → BitStream) : ∀ (n : ℕ), neg.carry x (n+1) =
fun _ => (BitStream.negAux (x ()) n).2
| 0 => by
simp [carry, nextBit, Function.funext_iff, BitStream.negAux, neg]
simp [carry, nextBit, BitStream.negAux, neg]
| n+1 => by
rw [carry, carry_neg _ n]
simp [nextBit, eval, neg, BitStream.neg, BitStream.negAux, Bool.xor_not_left']
Expand Down Expand Up @@ -401,7 +401,7 @@ def ls (b : Bool) : FSM Unit :=
theorem carry_ls (b : Bool) (x : Unit → BitStream) : ∀ (n : ℕ),
(ls b).carry x (n+1) = fun _ => x () n
| 0 => by
simp [carry, nextBit, Function.funext_iff, ls]
simp [carry, nextBit, ls]
| n+1 => by
rw [carry, carry_ls _ _ n]
simp [nextBit, eval, ls]
Expand Down Expand Up @@ -433,7 +433,7 @@ def incr : FSM Unit :=
theorem carry_incr (x : Unit → BitStream) : ∀ (n : ℕ),
incr.carry x (n+1) = fun _ => (BitStream.incrAux (x ()) n).2
| 0 => by
simp [carry, nextBit, Function.funext_iff, BitStream.incrAux, incr]
simp [carry, nextBit, BitStream.incrAux, incr]
| n+1 => by
rw [carry, carry_incr _ n]
simp [nextBit, eval, incr, incr, BitStream.incrAux]
Expand All @@ -456,7 +456,7 @@ def decr : FSM Unit :=
theorem carry_decr (x : Unit → BitStream) : ∀ (n : ℕ), decr.carry x (n+1) =
fun _ => (BitStream.decrAux (x ()) n).2
| 0 => by
simp [carry, nextBit, Function.funext_iff, BitStream.decrAux, decr]
simp [carry, nextBit, BitStream.decrAux, decr]
| n+1 => by
rw [carry, carry_decr _ n]
simp [nextBit, eval, decr, BitStream.decrAux]
Expand Down Expand Up @@ -508,7 +508,7 @@ def repeatBit : FSM Unit where

end FSM

structure FSMSolution (t : Term) extends FSM (Fin t.arity) :=
structure FSMSolution (t : Term) extends FSM (Fin t.arity) where
( good : t.evalFinStream = toFSM.eval )

def composeUnary
Expand Down
5 changes: 3 additions & 2 deletions SSA/Experimental/Bits/Fast/BitStream.lean
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,9 @@ theorem ofBitVec_one_eqTo_ofNat : @ofBitVec w 1 ≈ʷ ofNat 1 := by
· simp [EqualUpTo ,h]
· intros n a
simp [ofNat_one n, ofBitVec, a]
sorry
-- omega
rw [← Bool.decide_and]
rw [decide_eq_decide]
omega

theorem ofBitVec_neg : ofBitVec (- x) ≈ʷ - (ofBitVec x) := by
calc
Expand Down
2 changes: 1 addition & 1 deletion SSA/Experimental/Bits/Fast/Decide.lean
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ instance (t₁ t₂ : Term) : Decidable (t₁.eval = t₂.eval) :=
← (termEvalEqFSM (t₁.xor t₂)).good]
simp only [eval_eq_iff_xor_eq_zero]
rw [forall_swap]
simp only [← Function.funext_iff]
simp only [← funext_iff]


open Term
Expand Down
10 changes: 5 additions & 5 deletions SSA/Experimental/Bits/Fast/FiniteStateMachine.lean
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def sub : FSM Bool :=
theorem carry_sub (x : Bool → BitStream) : ∀ (n : ℕ), sub.carry x (n+1) =
fun _ => (BitStream.subAux (x true) (x false) n).2
| 0 => by
simp [carry, nextBit, Function.funext_iff, BitStream.subAux, sub]
simp [carry, nextBit, funext_iff, BitStream.subAux, sub]
| n+1 => by
rw [carry, carry_sub _ n]
simp [nextBit, eval, sub, BitStream.sub, BitStream.subAux, Bool.xor_not_left']
Expand All @@ -329,7 +329,7 @@ def neg : FSM Unit :=
theorem carry_neg (x : Unit → BitStream) : ∀ (n : ℕ), neg.carry x (n+1) =
fun _ => (BitStream.negAux (x ()) n).2
| 0 => by
simp [carry, nextBit, Function.funext_iff, BitStream.negAux, neg]
simp [carry, nextBit, funext_iff, BitStream.negAux, neg]
| n+1 => by
rw [carry, carry_neg _ n]
simp [nextBit, eval, neg, BitStream.neg, BitStream.negAux, Bool.xor_not_left']
Expand Down Expand Up @@ -397,7 +397,7 @@ def ls (b : Bool) : FSM Unit :=
theorem carry_ls (b : Bool) (x : Unit → BitStream) : ∀ (n : ℕ),
(ls b).carry x (n+1) = fun _ => x () n
| 0 => by
simp [carry, nextBit, Function.funext_iff, ls]
simp [carry, nextBit, funext_iff, ls]
| n+1 => by
rw [carry, carry_ls _ _ n]
simp [nextBit, eval, ls]
Expand Down Expand Up @@ -429,7 +429,7 @@ def incr : FSM Unit :=
theorem carry_incr (x : Unit → BitStream) : ∀ (n : ℕ),
incr.carry x (n+1) = fun _ => (BitStream.incrAux (x ()) n).2
| 0 => by
simp [carry, nextBit, Function.funext_iff, BitStream.incrAux, incr]
simp [carry, nextBit, funext_iff, BitStream.incrAux, incr]
| n+1 => by
rw [carry, carry_incr _ n]
simp [nextBit, eval, incr, incr, BitStream.incrAux]
Expand All @@ -452,7 +452,7 @@ def decr : FSM Unit :=
theorem carry_decr (x : Unit → BitStream) : ∀ (n : ℕ), decr.carry x (n+1) =
fun _ => (BitStream.decrAux (x ()) n).2
| 0 => by
simp [carry, nextBit, Function.funext_iff, BitStream.decrAux, decr]
simp [carry, nextBit, funext_iff, BitStream.decrAux, decr]
| n+1 => by
rw [carry, carry_decr _ n]
simp [nextBit, eval, decr, BitStream.decrAux]
Expand Down
4 changes: 2 additions & 2 deletions SSA/Experimental/Bits/Fast/Lemmas.lean
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ lemma evalFin_eq_eval (t : Term) (vars : Nat → BitStream) :

lemma eq_iff_xor_eq_zero (seq₁ seq₂ : BitStream) :
(∀ i, seq₁ i = seq₂ i) ↔ (∀ i, (seq₁ ^^^ seq₂) i = BitStream.zero i) := by
simp [Function.funext_iff]
simp [funext_iff]

lemma eval_eq_iff_xor_eq_zero (t₁ t₂ : Term) :
t₁.eval = t₂.eval ↔ (t₁.xor t₂).evalFin = fun _ => BitStream.zero := by
simp only [Function.funext_iff, Term.eval, Term.evalFin,
simp only [funext_iff, Term.eval, Term.evalFin,
← eq_iff_xor_eq_zero, ← evalFin_eq_eval]
constructor
· intro h seq
Expand Down

0 comments on commit ea7e0f9

Please sign in to comment.