Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

nickswalker
Copy link
Contributor

@nickswalker nickswalker commented Dec 30, 2024

This PR adds language entries for the two types of programs that use the .lp extension; answer set programs and linear programs. They're both common, and they shouldn't be added independently to avoid widespread misclassification.

Description

Adding Answer Set Programming was first suggested in #3867, but it was difficult to assess popularity at the time because GitHub code search didn't support special characters. #3867 (comment) points out that .lp isn't necessarily exclusive to ASP, but fortunately Prolog (the most similar commonly used logic programming language) has coalesced on .pl.

#4860 discussed adding a language group for ASP (the language varies slightly across different solvers). The included grammar is quite generic, so I don't believe there's a need for specific sub-grammars/languages.

#4860 also points at the .lp is also used for "linear programs" (common human-readable input format for LP solvers). These can be told apart by looking for the required objective statement. Gurobi docs:

The first section in an LP file is the objective section. This section begins with one of the following six keywords: minimize, maximize, minimum, maximum, min, or max. Capitalization is ignored. This keyword may appear alone, or it may be immediately followed by multi-objectives, which indicates that the model contains multiple objective functions.

Answer Set Programming

Answer Set Programming is a logic programming paradigm which dates back to the 1990s. The .lp (logic program) file extension has been used for ASP programs since at least 1998, when it was used by lparse and the smodels solver.

Today, there are many ASP-focused repos on GitHub. Here are more than a hundred that opted into the #answer-set-programming topic.

Checklist:

Linear Programming

Linear programs are mathematical models of linearly related variables. The lp file format goes back at least 20 years as part of CPLEX.

Checklist

Pulled from clingo (MIT) and from Draco (BSD 3 Clause)
@nickswalker nickswalker changed the title Add Answer Set Programming Add Answer Set Programming and Linear Programming Jan 4, 2025
Linear programs must have an objective
Exactly match the object line
@lildude lildude enabled auto-merge January 8, 2025 12:13
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

Important

The changes in this PR will not appear on GitHub until the next release has been made and deployed. See here for more details.

@lildude lildude added this pull request to the merge queue Jan 8, 2025
Merged via the queue into github-linguist:main with commit 30c4668 Jan 8, 2025
5 checks passed
NateCyphermax96

This comment was marked as spam.

tgamblin added a commit to spack/spack that referenced this pull request Apr 16, 2025
This reverts a change made in #20639 to have GitHub recognize our
ASP files as Prolog, the closest langauge supported by
[Linguist](https://github.com/github-linguist/linguist) at the time.

Linguist has since
[added support for ASP](github-linguist/linguist#7184),
so we no longer need to force Prolog detection -- our `.lp` files should
be auto-detected as ASP.

Signed-off-by: Todd Gamblin <[email protected]>
tgamblin added a commit to spack/spack that referenced this pull request Apr 16, 2025
This reverts a change made in #20639 to have GitHub recognize our
ASP files as Prolog, the closest langauge supported by
[Linguist](https://github.com/github-linguist/linguist) at the time.

Linguist has since
[added support for ASP](github-linguist/linguist#7184),
so we no longer need to force Prolog detection -- our `.lp` files should
be auto-detected as ASP.

Signed-off-by: Todd Gamblin <[email protected]>
becker33 pushed a commit to spack/spack that referenced this pull request Apr 16, 2025
This reverts a change made in #20639 to have GitHub recognize our
ASP files as Prolog, the closest langauge supported by
[Linguist](https://github.com/github-linguist/linguist) at the time.

Linguist has since
[added support for ASP](github-linguist/linguist#7184),
so we no longer need to force Prolog detection -- our `.lp` files should
be auto-detected as ASP.

Signed-off-by: Todd Gamblin <[email protected]>
@tgamblin
Copy link

Thanks for doing this. Trying this out on our repo, it looks like GitHub correctly detects some files as ASP, but if I click on "Answer Set Programming" under "Languages", the search that generates doesn't find anything and says that "Answer Set Programming" is not a known language. Is there something that needs to happen to make the click-through search work?

Screenshot 2025-04-16 at 2 47 26 PM Screenshot 2025-04-16 at 2 47 17 PM

@lildude
Copy link
Member

lildude commented Apr 16, 2025

@tgamblin see the last sentence in the troubleshooting doc.

@tgamblin
Copy link

Thanks!

For others:

Note: New languages will not appear in GitHub's search results for some time after the pull request has been merged and the new Linguist release deployed to GitHub.com. This is because GitHub's search uses a separate internal library for language detection which tends to lag behind Linguist by a few weeks to months.

climbfuji pushed a commit to climbfuji/spack that referenced this pull request Apr 17, 2025
)

This reverts a change made in spack#20639 to have GitHub recognize our
ASP files as Prolog, the closest langauge supported by
[Linguist](https://github.com/github-linguist/linguist) at the time.

Linguist has since
[added support for ASP](github-linguist/linguist#7184),
so we no longer need to force Prolog detection -- our `.lp` files should
be auto-detected as ASP.

Signed-off-by: Todd Gamblin <[email protected]>
teaguesterling pushed a commit to teaguesterling/spack that referenced this pull request May 20, 2025
)

This reverts a change made in spack#20639 to have GitHub recognize our
ASP files as Prolog, the closest langauge supported by
[Linguist](https://github.com/github-linguist/linguist) at the time.

Linguist has since
[added support for ASP](github-linguist/linguist#7184),
so we no longer need to force Prolog detection -- our `.lp` files should
be auto-detected as ASP.

Signed-off-by: Todd Gamblin <[email protected]>
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jul 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants