Skip to content

feat(Circuit): prove Shannon lower bound - #891

Open
SamuelSchlesinger wants to merge 2 commits into
samschles/lupanovfrom
samschles/shannon
Open

feat(Circuit): prove Shannon lower bound#891
SamuelSchlesinger wants to merge 2 commits into
samschles/lupanovfrom
samschles/shannon

Conversation

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

Add semantic normalization and counting to prove the worst-case 2^n/n lower bound for De Morgan circuits.

Assisted by Codex, adapted from https://github.com/samuelSchlesinger/algebraic-circuits.


variable {n g s : ℕ}

/-- Boolean functions computable with at most `s` De Morgan gates. -/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/-- Boolean functions computable with at most `s` De Morgan gates. -/
/-- Boolean functions on `n` inputs computable with at most `s` De Morgan gates. -/

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied the suggested docstring.

variable {n g s : ℕ}

/-- Boolean functions computable with at most `s` De Morgan gates. -/
noncomputable def computableFunctions (n s : ℕ) : Finset (BooleanFunction n) := by

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be difficult to give an explicit definition (instead of using a tactic)?
I mean mem_computableFunctions gives a good definition so it's not too bad, but still a bit weird.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced both tactic blocks with direct Finset.univ.filter definitions using open scoped Classical in.

classical
simp [computableFunctions]

private noncomputable def irredundantFunctions (n g : ℕ) : Finset (BooleanFunction n) := by

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give some intuition for this definition?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a docstring explaining that the gates compute pairwise distinct functions, giving g! distinct relabelings for the counting bound.

classical
simp [irredundantFunctions]

private instance opFintype : Fintype Op where

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move to definition of Op, could be useful in general

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the Fintype Op instance next to Op in Boolean/Basic.lean and made it public.

intro gate
simp [Wire.Renaming.ofPermutation, Function.comp_def]

private noncomputable def representative (f : ↥(irredundantFunctions n g)) :

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to do this without the ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the explicit here and in the related declarations; Lean infers the coercion.

nlinarith

private theorem eventually_inputs_le_budget :
∀ᶠ n : ℕ in atTop, n + 1 ≤ 2 ^ n / n := by

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

∀ᶠ n : ℕ in atTop, n ≤ 2 ^ n / n could also be a generic theorem

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted public Nat.eventually_add_one_le_pow_div into Foundations/Data/Nat/Asymptotics.lean, retaining the stronger n + 1 bound and generalizing to natural bases greater than one.

Add semantic normalization and counting to prove the worst-case
2^n/n lower bound for De Morgan circuits.
Comment on lines 39 to +43
deriving DecidableEq

instance Op.instFintype : Fintype Op where
elems := {.const false, .const true, .not, .and, .or}
complete := by intro op; cases op <;> simp

@barni120400 barni120400 Sep 12, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can save the instance by deriving also Fintype and proving that the cardinality is 5

Suggested change
deriving DecidableEq
instance Op.instFintype : Fintype Op where
elems := {.const false, .const true, .not, .and, .or}
complete := by intro op; cases op <;> simp
deriving DecidableEq, Fintype
@[simp] theorem Op.card : Fintype.card Op = 5 := rfl

This needs the imports above swapped as well, and changing the proof in Cslib/Computability/Circuit/Boolean/Counting.lean:84 to just simp

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants