All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gapt.proofs.context.update.ProofNameDeclaration.scala Maven / Gradle / Ivy

The newest version!
package gapt.proofs.context.update

import gapt.expr.Apps
import gapt.expr.Const
import gapt.expr.Expr
import gapt.expr.Var
import gapt.expr.ty.TVar
import gapt.expr.util.freeVariables
import gapt.expr.util.typeVariables
import gapt.proofs.HOLSequent
import gapt.proofs.RichFormulaSequent
import gapt.proofs.context.Context
import gapt.proofs.context.facet.ProofNames
import gapt.proofs.context.State

case class ProofNameDeclaration(lhs: Expr, endSequent: HOLSequent) extends Update {
  override def apply(ctx: Context): State = {
    endSequent.foreach(ctx.check(_))
    val Apps(Const(c, _, ps), vs) = lhs: @unchecked
    require(!ctx.get[ProofNames].names.keySet.contains(c), s"proof already defined: $lhs")
    require(vs == vs.distinct)
    require(vs.forall(_.isInstanceOf[Var]))
    require(ps.forall(_.isInstanceOf[TVar]))
    for (fv <- freeVariables(endSequent))
      require(vs.contains(fv))
    for (tv <- typeVariables(endSequent.toImplication))
      require(ps.contains(tv))
    ctx.state.update[ProofNames](_.+(c, lhs, endSequent))
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy